]> git.ipfire.org Git - thirdparty/git.git/commitdiff
unit tests: add rule for running with test-tool
authorJosh Steadmon <steadmon@google.com>
Mon, 6 May 2024 19:57:35 +0000 (12:57 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 May 2024 21:06:35 +0000 (14:06 -0700)
In the previous commit, we added support in test-tool for running
collections of unit tests. Now, add rules in t/Makefile for running in
this way.

This new rule can be executed from the top-level Makefile via
`make DEFAULT_UNIT_TEST_TARGET=unit-tests-test-tool unit-tests`, or by
setting DEFAULT_UNIT_TEST_TARGET in config.mak.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
t/Makefile

index c69c060cfa7dfa9c9cff1da80d77769ee59d455d..c656b6c989372f993ba1142b36c5bd5860b28ee0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3875,5 +3875,5 @@ $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_DIR)/
 
 .PHONY: build-unit-tests unit-tests
 build-unit-tests: $(UNIT_TEST_PROGS)
-unit-tests: $(UNIT_TEST_PROGS)
+unit-tests: $(UNIT_TEST_PROGS) t/helper/test-tool$X
        $(MAKE) -C t/ unit-tests
index 4861edafe61646370ff577cffa9a3a152d2f22b9..0ae04f1e42caf84481f1ec2d5a00d81c0150019e 100644 (file)
@@ -49,6 +49,7 @@ CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
 UNIT_TEST_SOURCES = $(wildcard unit-tests/t-*.c)
 UNIT_TEST_PROGRAMS = $(patsubst unit-tests/%.c,unit-tests/bin/%$(X),$(UNIT_TEST_SOURCES))
 UNIT_TESTS = $(sort $(UNIT_TEST_PROGRAMS))
+UNIT_TESTS_NO_DIR = $(notdir $(UNIT_TESTS))
 
 # `test-chainlint` (which is a dependency of `test-lint`, `test` and `prove`)
 # checks all tests in all scripts via a single invocation, so tell individual
@@ -76,7 +77,7 @@ $(T):
 $(UNIT_TESTS):
        @echo "*** $@ ***"; $@
 
-.PHONY: unit-tests unit-tests-raw unit-tests-prove
+.PHONY: unit-tests unit-tests-raw unit-tests-prove unit-tests-test-tool
 unit-tests: $(DEFAULT_UNIT_TEST_TARGET)
 
 unit-tests-raw: $(UNIT_TESTS)
@@ -84,6 +85,13 @@ unit-tests-raw: $(UNIT_TESTS)
 unit-tests-prove:
        @echo "*** prove - unit tests ***"; $(PROVE) $(GIT_PROVE_OPTS) $(UNIT_TESTS)
 
+unit-tests-test-tool:
+       @echo "*** test-tool - unit tests **"
+       ( \
+               cd unit-tests/bin && \
+               ../../helper/test-tool$X run-command testsuite $(UNIT_TESTS_NO_DIR)\
+       )
+
 pre-clean:
        $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'