unit tests: add rule for running with test-tool

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>

Josh Steadmon committed May 6, 2024 at 12:57 UTC 5bbc8c927f56dc6f2ff98fb013f4ed0f729f9adc
2 files changed +10 -2
Makefile
+1 -1
@@ -3875,5 +3875,5 @@ $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_DIR)/
3875
3876 .PHONY: build-unit-tests unit-tests
3877 build-unit-tests: $(UNIT_TEST_PROGS)
3878 -unit-tests: $(UNIT_TEST_PROGS)
3878 +unit-tests: $(UNIT_TEST_PROGS) t/helper/test-tool$X
3879 $(MAKE) -C t/ unit-tests
t/Makefile
+9 -1
@@ -49,6 +49,7 @@ CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
49 UNIT_TEST_SOURCES = $(wildcard unit-tests/t-*.c)
50 UNIT_TEST_PROGRAMS = $(patsubst unit-tests/%.c,unit-tests/bin/%$(X),$(UNIT_TEST_SOURCES))
51 UNIT_TESTS = $(sort $(UNIT_TEST_PROGRAMS))
52 +UNIT_TESTS_NO_DIR = $(notdir $(UNIT_TESTS))
53
54 # `test-chainlint` (which is a dependency of `test-lint`, `test` and `prove`)
55 # checks all tests in all scripts via a single invocation, so tell individual
@@ -76,7 +77,7 @@ $(T):
77 $(UNIT_TESTS):
78 @echo "*** $@ ***"; $@
79
79 -.PHONY: unit-tests unit-tests-raw unit-tests-prove
80 +.PHONY: unit-tests unit-tests-raw unit-tests-prove unit-tests-test-tool
81 unit-tests: $(DEFAULT_UNIT_TEST_TARGET)
82
83 unit-tests-raw: $(UNIT_TESTS)
@@ -84,6 +85,13 @@ unit-tests-raw: $(UNIT_TESTS)
85 unit-tests-prove:
86 @echo "*** prove - unit tests ***"; $(PROVE) $(GIT_PROVE_OPTS) $(UNIT_TESTS)
87
88 +unit-tests-test-tool:
89 + @echo "*** test-tool - unit tests **"
90 + ( \
91 + cd unit-tests/bin && \
92 + ../../helper/test-tool$X run-command testsuite $(UNIT_TESTS_NO_DIR)\
93 + )
94 +
95 pre-clean:
96 $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
97