t/README: add a note about don't saving stderr of compound commands

Explain in 't/README' why it is a bad idea to redirect and verify the
stderr of compound commands, in the hope that future contributions
will follow this advice and the test suite will keep working with '-x'
tracing and /bin/sh.

While at it, since we can now run the test suite with '-x' without
needing a Bash version supporting BASH_XTRACEFD, remove the now
outdated caution note about non-Bash shells from the description of
the '-x' option.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
SZEDER Gábor 2018-02-24 00:39:50 +01:00 committed by Junio C Hamano
parent 5827506928
commit 94201a2b00

View file

@ -84,9 +84,7 @@ appropriately before running "make".
-x::
Turn on shell tracing (i.e., `set -x`) during the tests
themselves. Implies `--verbose`. Note that in non-bash shells,
this can cause failures in some tests which redirect and test
the output of shell functions. Use with caution.
themselves. Implies `--verbose`.
Ignored in test scripts that set the variable 'test_untraceable'
to a non-empty value, unless it's run with a Bash version
supporting BASH_XTRACEFD, i.e. v4.1 or later.
@ -455,6 +453,22 @@ Don't:
causing the next test to start in an unexpected directory. Do so
inside a subshell if necessary.
- save and verify the standard error of compound commands, i.e. group
commands, subshells, and shell functions (except test helper
functions like 'test_must_fail') like this:
( cd dir && git cmd ) 2>error &&
test_cmp expect error
When running the test with '-x' tracing, then the trace of commands
executed in the compound command will be included in standard error
as well, quite possibly throwing off the subsequent checks examining
the output. Instead, save only the relevant git command's standard
error:
( cd dir && git cmd 2>../error ) &&
test_cmp expect error
- Break the TAP output
The raw output from your test may be interpreted by a TAP harness. TAP