diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-05-31 14:08:27 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-05-31 14:08:27 -0700 |
commit | 68a6e976a821ebf2b3766efb167fa716cbf8c188 (patch) | |
tree | 5232a164b8b372e34062ac73ff32be9f93b0de28 /t/test-lib.sh | |
parent | 9ee8f9409cab2a52e133c63bdd0acce24f99e73f (diff) | |
parent | d88785e424aaf18aa3ca291c2299c599c000c6cb (diff) | |
download | git-68a6e976a821ebf2b3766efb167fa716cbf8c188.tar.gz |
Merge branch 'jk/test-send-sh-x-trace-elsewhere' into maint
Running tests with '-x' option to trace the individual command
executions is a useful way to debug test scripts, but some tests
that capture the standard error stream and check what the command
said can be broken with the trace output mixed in. When running
our tests under "bash", however, we can redirect the trace output
to another file descriptor to keep the standard error of programs
being tested intact.
* jk/test-send-sh-x-trace-elsewhere:
test-lib: set BASH_XTRACEFD automatically
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index 79afa8748e..39c70f0326 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -322,6 +322,19 @@ else exec 4>/dev/null 3>/dev/null fi +# Send any "-x" output directly to stderr to avoid polluting tests +# which capture stderr. We can do this unconditionally since it +# has no effect if tracing isn't turned on. +# +# Note that this sets up the trace fd as soon as we assign the variable, so it +# must come after the creation of descriptor 4 above. Likewise, we must never +# unset this, as it has the side effect of closing descriptor 4, which we +# use to show verbose tests to the user. +# +# Note also that we don't need or want to export it. The tracing is local to +# this shell, and we would not want to influence any shells we exec. +BASH_XTRACEFD=4 + test_failure=0 test_count=0 test_fixed=0 |