<commit_before>/*
 * tests-main.c:  shared main() & friends for SVN test-suite programs
 *
 * ====================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */




#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <apr_pools.h>
#include <apr_strings.h>
#include <apr_general.h>

#include "svn_error.h"


/* All Subversion test programs include an array of function pointers
   (all of our sub-tests) that begins and ends with a NULL entry. */
extern svn_error_t *(*test_funcs[])(const char **msg, 
                                    apr_pool_t *pool);

/* ================================================================= */


/* Determine the array size of test_funcs[], the inelegant way.  :)  */
static int
get_array_size (void)
{
  int i;

  for (i = 1; test_funcs[i]; i++)
    {
    }

  return (i - 1);
}



/* Execute a test number TEST_NUM.  Pretty-print test name and dots
   according to our test-suite spec, and return the result code. */
static int
do_test_num (const char *progname, int test_num, apr_pool_t *pool)
{
  svn_error_t *err;
  int array_size = get_array_size();
  const char *msg = 0;  /* the message this individual test prints out */

  /* Check our array bounds! */
  if ((test_num > array_size) || (test_num <= 0))
    {
      printf ("FAIL: %s: THERE IS NO TEST NUMBER %2d\n", progname, test_num);
      return 1;  /* BAIL, this test number doesn't exist. */
    }

  /* Do test */
  err = test_funcs[test_num](&msg, pool);

  /* If we got an error, print it out.  */
  if (err)
    svn_handle_error (err, stdout, 0);

  printf ("%s: %s %2d: %s\n", 
          err ? "FAIL" : "PASS",
          progname,
          test_num, 
          msg ? msg : "(test did not provide name)");

  return err != SVN_NO_ERROR;
}



/* Standard svn test program */
int
main (int argc, char *argv[])
{
  char *prog_name;
  int test_num;
  int i;
  int got_error = 0;
  apr_pool_t *pool;

  /* How many tests are there? */
  int array_size = get_array_size();
  
  /* Initialize APR (Apache pools) */
  if (apr_initialize () != APR_SUCCESS)
    {
      printf ("apr_initialize() failed.\n");
      exit (1);
    }

  /* set up the global pool */
  pool = svn_pool_create (NULL);

  /* Strip off any leading path components from the program name.  */
  prog_name = strrchr (argv[0], '/');
  if (prog_name)
    prog_name++;
  else
    prog_name = argv[0];

  if (argc >= 2)  /* notice command-line arguments */
    {
      for (i = 1; i < argc; i++)
        {
          test_num = atoi (argv[i]);
          if (do_test_num (prog_name, test_num, pool))
            got_error = 1;

          /* Clear the per-function pool */
          svn_pool_clear (pool);
        }
    }
  else            /* just run all tests */
    {
      for (i = 1; i <= array_size; i++)
        {
          if (do_test_num (prog_name, i, pool))
            got_error = 1;

          /* Clear the per-function pool */
          svn_pool_clear (pool);
        }
    }

  /* Clean up APR */
  svn_pool_destroy (pool);
  apr_terminate();

  return got_error;
}




/* --------------------------------------------------------------
 * local variables:
 * eval: (load-file "../svn-dev.el")
 * end:
 */<commit_msg>(main): watch out for (and skip) the srcdir argument which is passed during   a standard "make check" execution.<commit_after>/*
 * tests-main.c:  shared main() & friends for SVN test-suite programs
 *
 * ====================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */




#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include <apr_pools.h>
#include <apr_strings.h>
#include <apr_general.h>
#include <apr_lib.h>

#include "svn_error.h"


/* All Subversion test programs include an array of function pointers
   (all of our sub-tests) that begins and ends with a NULL entry. */
extern svn_error_t *(*test_funcs[])(const char **msg, 
                                    apr_pool_t *pool);

/* ================================================================= */


/* Determine the array size of test_funcs[], the inelegant way.  :)  */
static int
get_array_size (void)
{
  int i;

  for (i = 1; test_funcs[i]; i++)
    {
    }

  return (i - 1);
}



/* Execute a test number TEST_NUM.  Pretty-print test name and dots
   according to our test-suite spec, and return the result code. */
static int
do_test_num (const char *progname, int test_num, apr_pool_t *pool)
{
  svn_error_t *err;
  int array_size = get_array_size();
  const char *msg = 0;  /* the message this individual test prints out */

  /* Check our array bounds! */
  if ((test_num > array_size) || (test_num <= 0))
    {
      printf ("FAIL: %s: THERE IS NO TEST NUMBER %2d\n", progname, test_num);
      return 1;  /* BAIL, this test number doesn't exist. */
    }

  /* Do test */
  err = test_funcs[test_num](&msg, pool);

  /* If we got an error, print it out.  */
  if (err)
    svn_handle_error (err, stdout, 0);

  printf ("%s: %s %2d: %s\n", 
          err ? "FAIL" : "PASS",
          progname,
          test_num, 
          msg ? msg : "(test did not provide name)");

  return err != SVN_NO_ERROR;
}



/* Standard svn test program */
int
main (int argc, char *argv[])
{
  char *prog_name;
  int test_num;
  int i;
  int got_error = 0;
  apr_pool_t *pool;
  int ran_a_test = 0;

  /* How many tests are there? */
  int array_size = get_array_size();
  
  /* Initialize APR (Apache pools) */
  if (apr_initialize () != APR_SUCCESS)
    {
      printf ("apr_initialize() failed.\n");
      exit (1);
    }

  /* set up the global pool */
  pool = svn_pool_create (NULL);

  /* Strip off any leading path components from the program name.  */
  prog_name = strrchr (argv[0], '/');
  if (prog_name)
    prog_name++;
  else
    prog_name = argv[0];

  if (argc >= 2)  /* notice command-line arguments */
    {
      for (i = 1; i < argc; i++)
        {
          if (apr_isdigit (argv[i][0]))
            {
              ran_a_test = 1;
              test_num = atoi (argv[i]);
              if (do_test_num (prog_name, test_num, pool))
                got_error = 1;

              /* Clear the per-function pool */
              svn_pool_clear (pool);
            }
          else
            {
              /* (probably) a source directory pathname */
              printf ("notice: ignoring argument %d\n", i);
            }
        }
    }

  if (!ran_a_test)
    {
      /* just run all tests */
      for (i = 1; i <= array_size; i++)
        {
          if (do_test_num (prog_name, i, pool))
            got_error = 1;

          /* Clear the per-function pool */
          svn_pool_clear (pool);
        }
    }

  /* Clean up APR */
  svn_pool_destroy (pool);
  apr_terminate();

  return got_error;
}




/* --------------------------------------------------------------
 * local variables:
 * eval: (load-file "../svn-dev.el")
 * end:
 */
{'fraction_non_alphanumeric': 0.18818380743982493, 'fraction_numerical': 0.00707941820054061, 'mean_word_length': 2.3106092884533447, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7371027', 'n_tokens_mistral': 2604, 'n_tokens_neox': 2441, 'n_words': 790}