Skip to content

Commit 0ed1512

Browse files
pks-tgitster
authored andcommitted
meson: detect missing tests at configure time
It is quite easy for the list of integration tests to go out-of-sync without anybody noticing. Introduce a new configure-time check that verifies that all tests are wired up properly. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c081e73 commit 0ed1512

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

t/meson.build

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,42 @@ integration_tests = [
10921092
't9903-bash-prompt.sh',
10931093
]
10941094

1095+
# Sanity check that we are not missing any tests present in 't/'. This check
1096+
# only runs once at configure time and is thus best-effort, only. It is
1097+
# sufficient to catch missing test suites in our CI though.
1098+
foreach glob, tests : {
1099+
't[0-9][0-9][0-9][0-9]-*.sh': integration_tests,
1100+
'unit-tests/t-*.c': unit_test_programs,
1101+
'unit-tests/u-*.c': clar_test_suites,
1102+
}
1103+
actual_tests = run_command(shell, '-c', 'ls ' + glob,
1104+
check: true,
1105+
env: script_environment,
1106+
).stdout().strip().split('\n')
1107+
1108+
if tests != actual_tests
1109+
missing_tests = [ ]
1110+
foreach actual_test : actual_tests
1111+
if actual_test not in tests
1112+
missing_tests += actual_test
1113+
endif
1114+
endforeach
1115+
if missing_tests.length() > 0
1116+
error('Test files found, but not configured:\n\n - ' + '\n - '.join(missing_tests))
1117+
endif
1118+
1119+
superfluous_tests = [ ]
1120+
foreach integration_test : tests
1121+
if integration_test not in actual_tests
1122+
superfluous_tests += integration_test
1123+
endif
1124+
endforeach
1125+
if superfluous_tests.length() > 0
1126+
error('Test files configured, but not found:\n\n - ' + '\n - '.join(superfluous_tests))
1127+
endif
1128+
endif
1129+
endforeach
1130+
10951131
# GIT_BUILD_DIR needs to be Unix-style without drive prefixes as it get added
10961132
# to the PATH variable. And given that drive prefixes contain a colon we'd
10971133
# otherwise end up with a broken PATH if we didn't convert it.

0 commit comments

Comments
 (0)