Allows override of stdout/stderr/log capturing

During a test run stdout, stderr and log messages are being captured. If
the test fails all three will be printed out so that can be inspected.
Each stream has an environment variable that can be used to stop it from
being printed at the end of a test run by setting its value to 0. This
is in line with what many of the other project are already doing.

Environment variables:

 - OS_STDOUT_CAPTURE for stdout
 - OS_STDERR_CAPTURE for stderr
 - OS_LOG_CAPTURE for logging

Change-Id: I2fed99069950b839e060297026c8e06cbd45bb98
This commit is contained in:
David Stanek 2014-03-20 17:34:45 +00:00
parent a2e08781ce
commit 94809b08a2
2 changed files with 22 additions and 3 deletions

View File

@ -1,7 +1,9 @@
[DEFAULT]
test_command=${PYTHON:-python} -m subunit.run discover \
-t ./ ./keystone/tests \
$LISTOPT $IDOPTION
test_command=
OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
${PYTHON:-python} -m subunit.run discover -t ./ ./keystone/tests $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -214,6 +214,23 @@ you'll normally only want to run the test that hits your breakpoint::
For reference, the ``debug`` tox environment implements the instructions
here: https://wiki.openstack.org/wiki/Testr#Debugging_.28pdb.29_Tests
Disabling Stream Capture
~~~~~~~~~~~~~~~~~~~~~~~~
The stdout, stderr and log messages generated during a test are captured and
in the event of a test failure those streams will be printed to the terminal
along with the traceback. The data is discarded for passing tests.
Each stream has an environment variable that can be used to force captured
data to be discarded even if the test fails: `OS_STDOUT_CAPTURE` for stdout,
`OS_STDERR_CAPTURE` for stderr and `OS_LOG_CAPTURE` for logging. If the value
of the environment variable is not one of (True, true, 1, yes) the stream will
be discarded. All three variables default to 1.
For example, to discard logging data during a test run::
$ OS_LOG_CAPTURE=0 tox -e py27
Test Structure
==============