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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Dec 13, 2024 at 11:41 UTC
0ed15121419e802476c17f904a499c6806acd710
1 file changed
+36
t/meson.build
+36
@@ -1092,6 +1092,42 @@ integration_tests = [
1092
't9903-bash-prompt.sh',
1093
]
1094
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
+
1131
# GIT_BUILD_DIR needs to be Unix-style without drive prefixes as it get added
1132
# to the PATH variable. And given that drive prefixes contain a colon we'd
1133
# otherwise end up with a broken PATH if we didn't convert it.