Re: [PATCH v2 2/6] unit-tests: add for_test
- From
René Scharfe <l.s.r@web.de>
- Date
- Jul 30, 2024, 14:00 UTC
- Message-ID
- <ce00cc56-4671-4ef6-9a43-db13acec3e46@web.de>
- In-Reply-To
- <c7d280d5-6bc8-41c1-ae85-418e20b38a25@gmail.com>
Am 25.07.24 um 11:45 schrieb Phillip Wood:
Show 12 quoted lines
> On 23/07/2024 14:24, Phillip Wood wrote: > >> For example in test-ctype.c where testing the ctype macros leads to >> a lot of repetition or a giant macro with a function based >> approach. > > Having re-read the history of t/unit-tests/t-ctype.c I don't think > the repetition in the original version was really that bad. The > objection to it seems to have been that one had to write the class > name (for example isalpha()) twice - once when defining the test > function and again when calling it. I'm not sure that is really worth > worrying about.
I can't see the purpose of requiring repetition like that. It's an unnecessary obstacle, small as it may be. In the case of t-ctype it was a regression to the original test helper code. It's easy to avoid with existing functions, except that those are off-limits to allow for future changes. So it's just a matter of packaging them nicely.
> So overall I'm less convinced that adding something like for_test() > is necessary and I'm very convinced that calling it for_test() and > using "continue" to exit a test early is going to confuse > contributors.
I didn't expect anybody would want to use continue or break in a test, but that's probably naive. I got carried away there by the prospect of a trivial macro-only solution, but alas, it's too clunky. Two steps back..
René