Skip to content

Commit 23a14f3

Browse files
sunshinecogitster
authored andcommitted
test-lib: replace chainlint.sed with chainlint.pl
By automatically invoking chainlint.sed upon each test it runs, `test_run_` in test-lib.sh ensures that broken &&-chains will be detected early as tests are modified or new are tests created since it is typical to run a test script manually (i.e. `./t1234-test-script.sh`) during test development. Now that the implementation of chainlint.pl is complete, modify test-lib.sh to invoke it automatically instead of chainlint.sed each time a test script is run. This change reduces the number of "linter" invocations from 26800+ (once per test run) down to 1050+ (once per test script), however, a subsequent change will drop the number of invocations to 1 per `make test`, thus fully realizing the benefit of the new linter. Note that the "magic exit code 117" &&-chain checker added by bb79af9 (t/test-lib: introduce --chain-lint option, 2015-03-20) which is built into t/test-lib.sh is retained since it has near zero-cost and (theoretically) may catch a broken &&-chain not caught by chainlint.pl. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9fd9112 commit 23a14f3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

contrib/buildsystems/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
10761076
"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\"\" content \"\${content}\")\n"
10771077
"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
10781078
#misc copies
1079-
file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
1079+
file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.pl DESTINATION ${CMAKE_BINARY_DIR}/t/)
10801080
file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
10811081
file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
10821082
file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)

t/test-lib.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,7 @@ test_run_ () {
10911091
trace=
10921092
# 117 is magic because it is unlikely to match the exit
10931093
# code of other programs
1094-
if $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') ||
1095-
test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
1094+
if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
10961095
then
10971096
BUG "broken &&-chain or run-away HERE-DOC: $1"
10981097
fi
@@ -1588,6 +1587,12 @@ then
15881587
BAIL_OUT_ENV_NEEDS_SANITIZE_LEAK "GIT_TEST_SANITIZE_LEAK_LOG=true"
15891588
fi
15901589

1590+
if test "${GIT_TEST_CHAIN_LINT:-1}" != 0
1591+
then
1592+
"$PERL_PATH" "$TEST_DIRECTORY/chainlint.pl" "$0" ||
1593+
BUG "lint error (see '?!...!? annotations above)"
1594+
fi
1595+
15911596
# Last-minute variable setup
15921597
USER_HOME="$HOME"
15931598
HOME="$TRASH_DIRECTORY"

0 commit comments

Comments
 (0)