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
This commit is contained in:
Junio C Hamano 2021-05-20 08:55:00 +09:00
Родитель 02112fcb70 2d86a96220
Коммит cb227d5cd6
4 изменённых файлов: 21 добавлений и 3 удалений

Просмотреть файл

@ -196,6 +196,11 @@ appropriately before running "make". Short options can be bundled, i.e.
this feature by setting the GIT_TEST_CHAIN_LINT environment
variable to "1" or "0", respectively.
A few test scripts disable some of the more advanced
chain-linting detection in the name of efficiency. You can
override this by setting the GIT_TEST_CHAIN_LINT_HARDER
environment variable to "1".
--stress::
Run the test script repeatedly in multiple parallel jobs until
one of them fails. Useful for reproducing rare failures in

Просмотреть файл

@ -386,7 +386,9 @@ test_expect_success 'setup main' '
test_tick
'
# Disable extra chain-linting for the next set of tests. There are many
# auto-generated ones that are not worth checking over and over.
GIT_TEST_CHAIN_LINT_HARDER_DEFAULT=0
warn_LF_CRLF="LF will be replaced by CRLF"
warn_CRLF_LF="CRLF will be replaced by LF"
@ -597,6 +599,9 @@ do
checkout_files auto "$id" "" false native $NL CRLF CRLF_mix_LF LF_mix_CR LF_nul
done
# The rest of the tests are unique; do the usual linting.
unset GIT_TEST_CHAIN_LINT_HARDER_DEFAULT
# Should be the last test case: remove some files from the worktree
test_expect_success 'ls-files --eol -d -z' '
rm crlf_false_attr__CRLF.txt crlf_false_attr__CRLF_mix_LF.txt crlf_false_attr__LF.txt .gitattributes &&

Просмотреть файл

@ -4,6 +4,11 @@ test_description='wildmatch tests'
. ./test-lib.sh
# Disable expensive chain-lint tests; all of the tests in this script
# are variants of a few trivial test-tool invocations, and there are a lot of
# them.
GIT_TEST_CHAIN_LINT_HARDER_DEFAULT=0
should_create_test_file() {
file=$1

Просмотреть файл

@ -947,8 +947,11 @@ test_run_ () {
trace=
# 117 is magic because it is unlikely to match the exit
# code of other programs
if $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') ||
test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)" ||
{
test "${GIT_TEST_CHAIN_LINT_HARDER:-${GIT_TEST_CHAIN_LINT_HARDER_DEFAULT:-1}}" != 0 &&
$(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!')
}
then
BUG "broken &&-chain or run-away HERE-DOC: $1"
fi