/*----------------------------------------------------------------------*/ static bool run_tests_in_library(const char *suite_name_option, const char *test_name, const char *test_library, bool verbose, bool no_run) { int status; char *suite_name; suite_name = get_a_suite_name(suite_name_option, test_library); status = runner(reporter, test_library, suite_name, test_name, verbose, no_run); free((void*)suite_name); return status != 0; }
int main(int argc, const char **argv) { int status, i; bool verbose = false; bool no_run = false; const char *prefix_option; const char *suite_option = NULL; const char *tmp; atexit(cleanup); options = gopt_sort(&argc, argv, gopt_start( gopt_option('x', GOPT_ARG, gopt_shorts('x'), gopt_longs("xml") ), gopt_option('s', GOPT_ARG, gopt_shorts('s'), gopt_longs("suite") ), gopt_option('v', GOPT_NOARG, gopt_shorts('v'), gopt_longs("verbose") ), gopt_option('c', GOPT_NOARG, gopt_shorts('c'), gopt_longs("colours") ), gopt_option('c', GOPT_NOARG, gopt_shorts('c'), gopt_longs("colors") ), gopt_option('n', GOPT_NOARG, gopt_shorts('n'), gopt_longs("no-run") ), gopt_option('h', GOPT_NOARG, gopt_shorts('h'), gopt_longs("help") ) ) ); if (gopt_arg(options, 'x', &prefix_option)) reporter = create_xml_reporter(prefix_option); else reporter = create_text_reporter(); gopt_arg(options, 's', &suite_option); if (gopt_arg(options, 'v', &tmp)) verbose = true; if (gopt_arg(options, 'n', &tmp)) no_run = true; if (gopt_arg(options, 'c', &tmp)) reporter_options.use_colours = true; else reporter_options.use_colours = false; if (gopt_arg(options, 'h', &tmp)) { usage(argv); return EXIT_SUCCESS; } if (argc < 2) { usage(argv); return EXIT_FAILURE; } set_reporter_options(reporter, &reporter_options); i = 1; while(i < argc) { const char *suite_name = suite_option; const char *test_name = NULL; const char *test_library = argv[i++]; if (!file_exists(test_library)) { printf("Couldn't find library: %s\n", test_library); return EXIT_FAILURE; } suite_name = get_a_suite_name(suite_option, test_library); /* Check if the next argument is not a filename, thus a test name */ if (!file_exists(argv[i])) { test_name = argv[i++]; } status = runner(reporter, test_library, suite_name, test_name, verbose, no_run); if (status != 0) { printf("Library %s resulted in error status: %i\n", test_library, status); return status; } } return EXIT_SUCCESS; }