Re: [PATCH v3 3/7] unit-tests: add for_test
- From
Kyle Lippincott <spectral@google.com>
- Date
- Jul 25, 2024, 21:31 UTC
- Message-ID
- <CAO_smVhq=MkQV3a6qJtDiFykvR4im7AX4hMfKMNcL5SegnOSLA@mail.gmail.com>
- In-Reply-To
- <xmqqfrrxjw8f.fsf@gitster.g>
On Thu, Jul 25, 2024 at 9:02 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> > Kyle Lippincott <spectral@google.com> writes: > > > Maybe it's because I'm coming from a C++ environment at > > $JOB that's using Google's gunit and gmock frameworks, where every > > test is in its own function and we usually don't even write the main > > function ourselves, but I have a preference for the separate > > functions. > > If we do not have to write the main at all, then it would make the > separate function that implements a single test a lot more palatable, > and we do not even have to implement and call TEST() macro ;-).
I feel like you're trying to bait me into coming up with a way of avoiding the main function ;) But I don't think it can really be done in portable/vanilla C, unfortunately. I tried to think of a way to do this, and they all involved some other system coming along and identifying the tests and code-generating a main function, which also seems like too much magic to me.