Skip to content

Commit 9fd9112

Browse files
sunshinecogitster
authored andcommitted
test-lib: retire "lint harder" optimization hack
`test_run_` in test-lib.sh "lints" the body of a test by sending it down a `sed chainlint.sed | grep` pipeline; this happens once for each test run by a test script. Although this pipeline may seem relatively cheap in isolation, it can become expensive when invoked 26800+ times by `make test`, once for each test run, despite the existence of only 16500+ test definitions across all tests scripts. This difference in the number of tests defined in the scripts (16500+) and the number of tests actually run by `make test` (26800+) is explained by the fact that some test scripts run a very large number of small tests, all driven by a series of functions/loops which fill in the test bodies. This means that certain test definitions are being linted repeatedly (tens or hundreds of times) unnecessarily. To avoid such unnecessary work, 2d86a96 (t: avoid sed-based chain-linting in some expensive cases, 2021-05-13) added an optimization hack which allows individual scripts to manually suppress the unnecessary repeated linting of the same test definition. However, unlike chainlint.sed which checks a test body as the test is run, chainlint.pl checks each test definition just once, no matter how many times the test is run, thus the sort of optimization hack introduced by 2d86a96 is no longer needed and can be retired. Therefore, revert 2d86a96. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5606652 commit 9fd9112

File tree

4 files changed

+3
-21
lines changed

4 files changed

+3
-21
lines changed

t/README

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ appropriately before running "make". Short options can be bundled, i.e.
196196
this feature by setting the GIT_TEST_CHAIN_LINT environment
197197
variable to "1" or "0", respectively.
198198

199-
A few test scripts disable some of the more advanced
200-
chain-linting detection in the name of efficiency. You can
201-
override this by setting the GIT_TEST_CHAIN_LINT_HARDER
202-
environment variable to "1".
203-
204199
--stress::
205200
Run the test script repeatedly in multiple parallel jobs until
206201
one of them fails. Useful for reproducing rare failures in

t/t0027-auto-crlf.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,7 @@ test_expect_success 'setup main' '
387387
test_tick
388388
'
389389

390-
# Disable extra chain-linting for the next set of tests. There are many
391-
# auto-generated ones that are not worth checking over and over.
392-
GIT_TEST_CHAIN_LINT_HARDER_DEFAULT=0
390+
393391

394392
warn_LF_CRLF="LF will be replaced by CRLF"
395393
warn_CRLF_LF="CRLF will be replaced by LF"
@@ -606,9 +604,6 @@ do
606604
checkout_files "" "$id" "crlf" true "" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul
607605
done
608606

609-
# The rest of the tests are unique; do the usual linting.
610-
unset GIT_TEST_CHAIN_LINT_HARDER_DEFAULT
611-
612607
# Should be the last test case: remove some files from the worktree
613608
test_expect_success 'ls-files --eol -d -z' '
614609
rm crlf_false_attr__CRLF.txt crlf_false_attr__CRLF_mix_LF.txt crlf_false_attr__LF.txt .gitattributes &&

t/t3070-wildmatch.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ test_description='wildmatch tests'
55
TEST_PASSES_SANITIZE_LEAK=true
66
. ./test-lib.sh
77

8-
# Disable expensive chain-lint tests; all of the tests in this script
9-
# are variants of a few trivial test-tool invocations, and there are a lot of
10-
# them.
11-
GIT_TEST_CHAIN_LINT_HARDER_DEFAULT=0
12-
138
should_create_test_file() {
149
file=$1
1510

t/test-lib.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,11 +1091,8 @@ test_run_ () {
10911091
trace=
10921092
# 117 is magic because it is unlikely to match the exit
10931093
# code of other programs
1094-
if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)" ||
1095-
{
1096-
test "${GIT_TEST_CHAIN_LINT_HARDER:-${GIT_TEST_CHAIN_LINT_HARDER_DEFAULT:-1}}" != 0 &&
1097-
$(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!')
1098-
}
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)"
10991096
then
11001097
BUG "broken &&-chain or run-away HERE-DOC: $1"
11011098
fi

0 commit comments

Comments
 (0)