]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: drop here-doc check from internal chain-linter
authorJeff King <peff@peff.net>
Thu, 30 Mar 2023 19:30:47 +0000 (15:30 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Mar 2023 20:07:29 +0000 (13:07 -0700)
Commit 99a64e4b73c (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 99a64e4b73c 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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh

index cfcbd899c5a4bd136f9976dfccda92e8fda76639..0048ec7b6f6759641ec0e5265b067d739d74b6ba 100644 (file)
@@ -1101,9 +1101,10 @@ test_run_ () {
                trace=
                # 117 is magic because it is unlikely to match the exit
                # code of other programs
-               if test "OK-117" != "$(test_eval_ "fail_117 && $1${LF}${LF}echo OK-\$?" 3>&1)"
+               test_eval_ "fail_117 && $1"
+               if test $? != 117
                then
-                       BUG "broken &&-chain or run-away HERE-DOC: $1"
+                       BUG "broken &&-chain: $1"
                fi
                trace=$trace_tmp
        fi