Skip to content

Commit 750b260

Browse files
peffgitster
authored andcommitted
tests: drop here-doc check from internal chain-linter
Commit 99a64e4 (tests: lint for run-away here-doc, 2017-03-22) tweaked the chain-lint test to catch unclosed here-docs. It works by adding an extra "echo" command after the test snippet, and checking that it is run (if it gets swallowed by a here-doc, naturally it is not run). The downside here is that we introduced an extra $() substitution, which happens in a subshell. This has a measurable performance impact when run for many tests. The tradeoff in safety was undoubtedly worth it when 99a64e4 was written. But since the external chainlint.pl learned to find these recently, we can just rely on it. By switching back to a simpler chain-lint, hyperfine reports a measurable speedup on t3070 (which has 1800 tests): 'HEAD' ran 1.12 ± 0.01 times faster than 'HEAD~1' Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2b61c8d commit 750b260

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

t/test-lib.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,10 @@ test_run_ () {
11011101
trace=
11021102
# 117 is magic because it is unlikely to match the exit
11031103
# code of other programs
1104-
if test "OK-117" != "$(test_eval_ "fail_117 && $1${LF}${LF}echo OK-\$?" 3>&1)"
1104+
test_eval_ "fail_117 && $1"
1105+
if test $? != 117
11051106
then
1106-
BUG "broken &&-chain or run-away HERE-DOC: $1"
1107+
BUG "broken &&-chain: $1"
11071108
fi
11081109
trace=$trace_tmp
11091110
fi

0 commit comments

Comments
 (0)