diff options
Diffstat (limited to 'tests/minicheck.c')
-rw-r--r-- | tests/minicheck.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/tests/minicheck.c b/tests/minicheck.c index a5a1efb1..ab0c35fd 100644 --- a/tests/minicheck.c +++ b/tests/minicheck.c @@ -141,11 +141,18 @@ _check_set_test_info(char const *function, char const *filename, int lineno) { } static void -add_failure(SRunner *runner, int verbosity) { - runner->nfailures++; +handle_success(int verbosity) { if (verbosity >= CK_VERBOSE) { - printf("%s:%d: %s\n", _check_current_filename, _check_current_lineno, - _check_current_function); + printf("PASS: %s\n", _check_current_function); + } +} + +static void +handle_failure(SRunner *runner, int verbosity, const char *phase_info) { + runner->nfailures++; + if (verbosity != CK_SILENT) { + printf("FAIL: %s (%s at %s:%d)\n", _check_current_function, phase_info, + _check_current_filename, _check_current_lineno); } } @@ -164,14 +171,14 @@ srunner_run_all(SRunner *runner, int verbosity) { if (tc->setup != NULL) { /* setup */ if (setjmp(env)) { - add_failure(runner, verbosity); + handle_failure(runner, verbosity, "during setup"); continue; } tc->setup(); } /* test */ if (setjmp(env)) { - add_failure(runner, verbosity); + handle_failure(runner, verbosity, "during actual test"); continue; } (tc->tests[i])(); @@ -179,15 +186,17 @@ srunner_run_all(SRunner *runner, int verbosity) { /* teardown */ if (tc->teardown != NULL) { if (setjmp(env)) { - add_failure(runner, verbosity); + handle_failure(runner, verbosity, "during teardown"); continue; } tc->teardown(); } + + handle_success(verbosity); } tc = tc->next_tcase; } - if (verbosity) { + if (verbosity != CK_SILENT) { int passed = runner->nchecks - runner->nfailures; double percentage = ((double)passed) / runner->nchecks; int display = (int)(percentage * 100); @@ -203,8 +212,8 @@ _fail_unless(int condition, const char *file, int line, const char *msg) { it is. */ UNUSED_P(condition); - UNUSED_P(file); - UNUSED_P(line); + _check_current_filename = file; + _check_current_lineno = line; if (msg != NULL) { const int has_newline = (msg[strlen(msg) - 1] == '\n'); fprintf(stderr, "ERROR: %s%s", msg, has_newline ? "" : "\n"); |