]> git.notmuchmail.org Git - notmuch/commit
test: prepare test-lib.sh for possible test system debug session
authorTomi Ollila <tomi.ollila@iki.fi>
Sun, 21 Sep 2014 18:06:20 +0000 (21:06 +0300)
committerDavid Bremner <david@tethera.net>
Mon, 19 Jan 2015 07:15:39 +0000 (08:15 +0100)
commit7fcd100a2f4fcc3762f2f73bcca3c30cc971b67a
tree59a7ed98c8e1120029c1721f585a7a1aaebf2beb
parentef5b4947d8eaea745764e11fe346f67ca2e4a988
test: prepare test-lib.sh for possible test system debug session

When something in tests fails one possibility to test is to run
the test script as `bash -x TXXX-testname.sh`. As stderr (fd 2) was
redirected to separate file during test execution also this set -x
(xtrace) output would also go there.
test-lib.sh saves the stderr to fd 7 from where it can be restored,
and bash has BASH_XTRACEFD variable, which is now given the same value
7, making bash to output all xtrade information (consistently) there.

This lib file used to save fd's 1 & 2 to 6 & 7 (respectively) in
test_begin_subtest(), but as those needs to be set *before* XTRACEFD
variable is set those are now saved at the beginning of the lib (once).
This is safe and simple thing to do.
To make xtrace output more verbose PS4 variable was set to contain the
source file, line number and if execution is in function, that function
name. Setting this variable has no effect when not xtracing.

As it is known that fd 6 is redirected stdout, printing status can now
use that fd, instead of saving stdout to fd 5 and use it.
test/test-lib-common.sh
test/test-lib.sh