From 7d9364384a5c763c9c6ca4fad3b27536df2091b2 Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 11 May 2022 12:11:08 -0500 Subject: fix setjmp bug in lily_run_test() --- lily-test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lily-test.c') 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 */ -- cgit v1.2.1