Skip to content

Commit 154ce05

Browse files
pks-tgitster
authored andcommitted
Makefile: detect missing Meson tests
In the preceding commit, we have introduced consistency checks to Meson to detect any discrepancies with missing or extraneous tests in its build instructions. These checks only get executed in Meson though, so any users of our Makefiles wouldn't be alerted of the fact that they have to modify the Meson build instructions in case they add or remove any tests. Add a comparable test target to our Makefile to plug this gap. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0ed1512 commit 154ce05

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

t/Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ CHAINLINTSUPPRESS = GIT_TEST_EXT_CHAIN_LINT=0 && export GIT_TEST_EXT_CHAIN_LINT
5959

6060
all:: $(DEFAULT_TEST_TARGET)
6161

62-
test: pre-clean check-chainlint $(TEST_LINT)
62+
test: pre-clean check-chainlint check-meson $(TEST_LINT)
6363
$(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
6464

6565
failed:
@@ -114,6 +114,22 @@ check-chainlint:
114114
{ $(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests >'$(CHAINLINTTMP_SQ)'/actual || true; } && \
115115
diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
116116

117+
check-meson:
118+
@# awk acts up when trying to match single quotes, so we use \047 instead.
119+
@printf "%s\n" \
120+
"integration_tests t[0-9][0-9][0-9][0-9]-*.sh" \
121+
"unit_test_programs unit-tests/t-*.c" \
122+
"clar_test_suites unit-tests/u-*.c" | \
123+
while read -r variable pattern; do \
124+
meson_tests=$$(awk "/^$$variable = \[\$$/ {flag=1 ; next } /^]$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047,\$$/, \"\"); print }" meson.build) && \
125+
actual_tests=$$(ls $$pattern) && \
126+
if test "$$meson_tests" != "$$actual_tests"; then \
127+
echo "Meson tests differ from actual tests:"; \
128+
diff -u <(echo "$$meson_tests") <(echo "$$actual_tests"); \
129+
exit 1; \
130+
fi; \
131+
done
132+
117133
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
118134
test-lint-filenames
119135
ifneq ($(GIT_TEST_CHAIN_LINT),0)

0 commit comments

Comments
 (0)