aboutsummaryrefslogtreecommitdiffstats
path: root/t/helper/test-example-tap.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2024-07-30 16:07:00 +0200
committerJunio C Hamano <gitster@pobox.com>2024-07-30 13:32:43 -0700
commit1f452d6c6835e41d25e163616d8ee75aa91b5b17 (patch)
treec72df49319cbd8de494a8abe0c697a12837ecc0f /t/helper/test-example-tap.c
parent4575ba6a7c579ab5ac46d929c7c5de20013938cf (diff)
downloadgit-1f452d6c6835e41d25e163616d8ee75aa91b5b17.tar.gz
unit-tests: show location of checks outside of tests
Checks outside of tests are caught at runtime and reported like this: Assertion failed: (ctx.running), function test_assert, file test-lib.c, line 267. The assert() call aborts the unit test and doesn't reveal the location or even the type of the offending check, as test_assert() is called by all of them. Handle it like the opposite case, a test without any checks: Don't abort, but report the location of the actual check, along with a message explaining the situation. The output for example above becomes: # BUG: check outside of test at t/helper/test-example-tap.c:75 ... and the unit test program continues and indicates the error in its exit code at the end. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper/test-example-tap.c')
-rw-r--r--t/helper/test-example-tap.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/t/helper/test-example-tap.c b/t/helper/test-example-tap.c
index d072ad559f..79c12b01cd 100644
--- a/t/helper/test-example-tap.c
+++ b/t/helper/test-example-tap.c
@@ -72,6 +72,8 @@ static void t_empty(void)
int cmd__example_tap(int argc, const char **argv)
{
+ check(1);
+
test_res = TEST(check_res = check_int(1, ==, 1), "passing test");
TEST(t_res(1), "passing test and assertion return 1");
test_res = TEST(check_res = check_int(1, ==, 2), "failing test");