From 94809b08a26acf3e35d6c2a6c57a093fedc254c0 Mon Sep 17 00:00:00 2001 From: David Stanek Date: Thu, 20 Mar 2014 17:34:45 +0000 Subject: [PATCH] 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 --- .testr.conf | 8 +++++--- doc/source/developing.rst | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.testr.conf b/.testr.conf index 33297a1ca..5475610f4 100644 --- a/.testr.conf +++ b/.testr.conf @@ -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 diff --git a/doc/source/developing.rst b/doc/source/developing.rst index ddea69b06..bd096e2e0 100644 --- a/doc/source/developing.rst +++ b/doc/source/developing.rst @@ -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 ==============