]> git.ipfire.org Git - thirdparty/git.git/commit
Makefile: wire up the clar unit testing framework
authorPatrick Steinhardt <ps@pks.im>
Wed, 4 Sep 2024 14:17:12 +0000 (16:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Sep 2024 15:41:37 +0000 (08:41 -0700)
commit8bc5d33bd86cd21be975522a54f4fa6e1e646a16
treeda72361d14852362ff03e7c3b8f29c994e9ffdfd
parent416f4585d6f6e991a929a9d0b8b987a8815c77b8
Makefile: wire up the clar unit testing framework

Wire up the clar unit testing framework by introducing a new
"unit-tests" executable. In contrast to the existing framework, this
will result in a single executable for all test suites. The ability to
pick specific tests to execute is retained via functionality built into
the clar itself.

Note that we need to be a bit careful about how we need to invalidate
our Makefile rules. While we obviously have to regenerate the clar suite
when our test suites change, we also have to invalidate it in case any
of the test suites gets removed. We do so by using our typical pattern
of creating a `GIT-TEST-SUITES` file that gets updated whenever the set
of test suites changes, so that we can easily depend on that file.

Another specialty is that we generate a "clar-decls.h" file. The test
functions are neither static, nor do they have external declarations.
This is because they are getting parsed via "generate.py", which then
creates the external generations that get populated into an array. These
declarations are only seen by the main function though.

The consequence is that we will get a bunch of "missing prototypes"
errors from our compiler for each of these test functions. To fix those
errors, we extract the `extern` declarations from "clar.suite" and put
them into a standalone header that then gets included by each of our
unit tests. This gets rid of compiler warnings for every function which
has been extracted by "generate.py". More importantly though, it does
_not_ get rid of warnings in case a function really isn't being used by
anything. Thus, it would cause a compiler error if a function name was
mistyped and thus not picked up by "generate.py".

The test driver "unit-test.c" is an empty stub for now. It will get
implemented in the next commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
.gitignore
Makefile
t/Makefile
t/unit-tests/.gitignore
t/unit-tests/clar-generate.awk [new file with mode: 0644]
t/unit-tests/unit-test.c [new file with mode: 0644]
t/unit-tests/unit-test.h [new file with mode: 0644]