Skip to content

Commit 5fc98e7

Browse files
szedergitster
authored andcommitted
t: add means to disable '-x' tracing for individual test scripts
The previous patch resolved most of the test failures caused by running our test suite with '-x' tracing and /bin/sh, and the following patches in this series will resolve almost all of the remaining failures. Unfortunately, not yet all. Add means to disable '-x' tracing for individual test scripts by setting the $test_untraceable variable to a non-empty value in the test script before sourcing 'test-lib.sh'. However, since '-x' tracing is not an issue with recent Bash versions supporting BASH_XTRACEFD, i.e. v4.1 and later, don't disable tracing when the test script is run with such a Bash version even when $test_untraceable is set. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5bf824 commit 5fc98e7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

t/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ appropriately before running "make".
8787
themselves. Implies `--verbose`. Note that in non-bash shells,
8888
this can cause failures in some tests which redirect and test
8989
the output of shell functions. Use with caution.
90+
Ignored in test scripts that set the variable 'test_untraceable'
91+
to a non-empty value, unless it's run with a Bash version
92+
supporting BASH_XTRACEFD, i.e. v4.1 or later.
9093

9194
-d::
9295
--debug::

t/test-lib.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,24 @@ do
263263
GIT_TEST_CHAIN_LINT=0
264264
shift ;;
265265
-x)
266-
trace=t
266+
# Some test scripts can't be reliably traced with '-x',
267+
# unless the test is run with a Bash version supporting
268+
# BASH_XTRACEFD (introduced in Bash v4.1). Check whether
269+
# this test is marked as such, and ignore '-x' if it
270+
# isn't executed with a suitable Bash version.
271+
if test -z "$test_untraceable" || {
272+
test -n "$BASH_VERSION" && {
273+
test ${BASH_VERSINFO[0]} -gt 4 || {
274+
test ${BASH_VERSINFO[0]} -eq 4 &&
275+
test ${BASH_VERSINFO[1]} -ge 1
276+
}
277+
}
278+
}
279+
then
280+
trace=t
281+
else
282+
echo >&2 "warning: ignoring -x; '$0' is untraceable without BASH_XTRACEFD"
283+
fi
267284
shift ;;
268285
--verbose-log)
269286
verbose_log=t

0 commit comments

Comments
 (0)