diff options
author | sanine <sanine.not@pm.me> | 2022-05-11 12:11:08 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-05-11 12:11:08 -0500 |
commit | 7d9364384a5c763c9c6ca4fad3b27536df2091b2 (patch) | |
tree | deab63c92cb78c004091a1561b30e53657f60af1 | |
parent | 703576b11ceaad617b05b0b60a300a6281b25a43 (diff) |
fix setjmp bug in lily_run_test()
-rw-r--r-- | lily-test.c | 16 | ||||
-rw-r--r-- | lily-test.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lily-test.c b/lily-test.c index 65b5efb..20728fe 100644 --- a/lily-test.c +++ b/lily-test.c @@ -60,19 +60,19 @@ void _lily_run_test(const char *name, lily_test_t test) _lily_globals.error_location = ""; int val = setjmp(_lily_globals.env); - test(); - - if (val == 0) { - /* test succeeded */ - printf("OK\n"); - } - else { - /* test failed */ + if (val) { + /* test failed */ printf("FAIL - %s (%s)\n", _lily_globals.error_msg, _lily_globals.error_location); free(_lily_globals.error_msg); /* error message was allocated! */ + return; } + + test(); + + /* test succeeded */ + printf("OK\n"); } /* run a suite */ diff --git a/lily-test.h b/lily-test.h index 68d08e9..90fc2c8 100644 --- a/lily-test.h +++ b/lily-test.h @@ -76,7 +76,7 @@ typedef void (*lily_test_t)(void); void _lily_run_test(const char *name, lily_test_t test); /** run a suite */ -#define lily_run_suite(suite) _lily_run_suite(#suite, suite); +#define lily_run_suite(suite) _lily_run_suite(#suite, suite) void _lily_run_suite(const char *name, lily_test_t suite); |