Subject: Re: [PATCH v2 2/6] unit-tests: add for_test

From: René Scharfe <[email-masked]>
Date: Tue, 23 Jul 2024 15:58:18 +0200

Am 23.07.24 um 15:23 schrieb Phillip Wood:
> On 23/07/2024 13:37, René Scharfe wrote:
>>
>> In which ways can for_test break?
>
> Using a "break" statement to exit the test early will exit the loop
> without calling test__run_end()
Good point!  That will only be caught at runtime by the asserts at the
start of test__run_begin() or test_done() depending on whether it was
the last test:

 Assertion failed: (!ctx.running), function test_done, file test-lib.c, line 128.

 Assertion failed: (!ctx.running), function test__run_begin, file test-lib.c, line 172.

These messages could be more helpful.  And the use of the unsupported
break with a first-class for-like keyword would yield a compiler error.
But at least it won't go unnoticed even with this limited look-alike.
Deserves a comment in test-lib.h.

René