Skip to content

Commit cb227d5

Browse files
committed
Merge branch 'jk/test-chainlint-softer'
The "chainlint" feature in the test framework is a handy way to catch common mistakes in writing new tests, but tends to get expensive. An knob to selectively disable it has been introduced to help running tests that the developer has not modified. * jk/test-chainlint-softer: t: avoid sed-based chain-linting in some expensive cases
2 parents 02112fc + 2d86a96 commit cb227d5

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

t/README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ 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+
199204
--stress::
200205
Run the test script repeatedly in multiple parallel jobs until
201206
one of them fails. Useful for reproducing rare failures in

t/t0027-auto-crlf.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ test_expect_success 'setup main' '
386386
test_tick
387387
'
388388

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

391393
warn_LF_CRLF="LF will be replaced by CRLF"
392394
warn_CRLF_LF="CRLF will be replaced by LF"
@@ -597,6 +599,9 @@ do
597599
checkout_files auto "$id" "" false native $NL CRLF CRLF_mix_LF LF_mix_CR LF_nul
598600
done
599601

602+
# The rest of the tests are unique; do the usual linting.
603+
unset GIT_TEST_CHAIN_LINT_HARDER_DEFAULT
604+
600605
# Should be the last test case: remove some files from the worktree
601606
test_expect_success 'ls-files --eol -d -z' '
602607
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ test_description='wildmatch tests'
44

55
. ./test-lib.sh
66

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

t/test-lib.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,11 @@ test_run_ () {
947947
trace=
948948
# 117 is magic because it is unlikely to match the exit
949949
# code of other programs
950-
if $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') ||
951-
test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
950+
if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)" ||
951+
{
952+
test "${GIT_TEST_CHAIN_LINT_HARDER:-${GIT_TEST_CHAIN_LINT_HARDER_DEFAULT:-1}}" != 0 &&
953+
$(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!')
954+
}
952955
then
953956
BUG "broken &&-chain or run-away HERE-DOC: $1"
954957
fi

0 commit comments

Comments
 (0)