From e5cad7cd20030a712e48d5f8fdb3706d8942a2bc Mon Sep 17 00:00:00 2001 From: jlamothe Date: Tue, 21 Nov 2023 20:02:53 +0000 Subject: [PATCH] display pass/fail/pend status in realtime --- 9unit.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/9unit.c b/9unit.c index ff1cf8d..c9870f1 100644 --- a/9unit.c +++ b/9unit.c @@ -119,10 +119,10 @@ run_tests(void (*tests)(TestState *)) s.report = report; (*tests)(&s); print_log(&s); - printf("Tests run: %d\n", s.run); - printf("Tests passed: %d\n", s.passed); - printf("Tests failed: %d\n", s.failed); - printf("Tests pending: %d\n", s.pending); + print("\n\nTests run: %d\n", s.run); + print("Tests passed: %d\n", s.passed); + print("Tests failed: %d\n", s.failed); + print("Tests pending: %d\n", s.pending); clear_log(&s); if (s.failed) exits("test(s) failed"); } @@ -182,12 +182,15 @@ run_test(TestState *s, TestResult (*t)(TestState *)) { case test_success: s->passed++; + s->report(" [PASS]"); break; case test_failure: s->failed++; + s->report(" [FAIL]"); break; case test_pending: s->pending++; + s->report(" [PEND]"); break; default: exits("test returned an invalid response"); @@ -347,7 +350,7 @@ print_log(TestState *s) TestLogEntry *e = s->first_log; while(e) { - if(e->text) printf("%s\n", e->text); + if(e->text) print("%s\n", e->text); else print("(empty message)\n"); e = e->next; } @@ -419,10 +422,10 @@ build_new_context(TestState *s, ContextData *cd) static void display_context(TestState *s) { + s->report("\n"); for (int i = 1; i < s->depth; i++) s->report("\t"); s->report(s->context); - s->report("\n"); } static void