summaryrefslogtreecommitdiffstats
path: root/runtest.py
diff options
context:
space:
mode:
authoranatoly techtonik <techtonik@gmail.com>2012-12-18 11:40:36 (GMT)
committeranatoly techtonik <techtonik@gmail.com>2012-12-18 11:40:36 (GMT)
commit02cae725ed116ae6cd996fe3bf5888f7f8f61b97 (patch)
treede7781d298241c4c982cd8a23c25d6e3695fb5e7 /runtest.py
parent15d633a7931591f1829bfb9e0d29c79dfb26a1be (diff)
downloadSCons-02cae725ed116ae6cd996fe3bf5888f7f8f61b97.zip
SCons-02cae725ed116ae6cd996fe3bf5888f7f8f61b97.tar.gz
SCons-02cae725ed116ae6cd996fe3bf5888f7f8f61b97.tar.bz2
runtest.py: Enable -o, --output to save stdout/stderr into a file
Diffstat (limited to 'runtest.py')
-rw-r--r--runtest.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/runtest.py b/runtest.py
index 4c12298..6beb4ba 100644
--- a/runtest.py
+++ b/runtest.py
@@ -113,7 +113,6 @@ print_passed_summary = None
python3incompatibilities = None
scons = None
scons_exec = None
-outputfile = None
qmtest = None
testlistfile = None
version = ''
@@ -199,6 +198,8 @@ class PassThroughOptionParser(OptionParser):
parser = PassThroughOptionParser(add_help_option=False)
parser.add_option('-a', '--all', action='store_true',
help="Run all tests.")
+parser.add_option('-o', '--output',
+ help="Save the output from a test run to the log file.")
parser.add_option('--xml',
help="Save results to file in SCons XML format.")
(options, args) = parser.parse_args()
@@ -207,11 +208,11 @@ parser.add_option('--xml',
#print "args:", args
-opts, args = getopt.getopt(args, "3b:def:hj:klno:P:p:qsv:Xx:t",
+opts, args = getopt.getopt(args, "3b:def:hj:klnP:p:qsv:Xx:t",
['baseline=', 'builddir=',
'debug', 'external', 'file=', 'help', 'no-progress',
'jobs=',
- 'list', 'no-exec', 'nopipefiles', 'output=',
+ 'list', 'no-exec', 'nopipefiles',
'package=', 'passed', 'python=', 'qmtest',
'quiet', 'short-progress', 'time',
'version=', 'exec=',
@@ -251,10 +252,6 @@ for o, a in opts:
execute_tests = None
elif o in ['--nopipefiles']:
allow_pipe_files = False
- elif o in ['-o', '--output']:
- if a != '-' and not os.path.isabs(a):
- a = os.path.join(cwd, a)
- outputfile = a
elif o in ['-p', '--package']:
package = a
elif o in ['--passed']:
@@ -311,6 +308,17 @@ class Unbuffered(object):
sys.stdout = Unbuffered(sys.stdout)
sys.stderr = Unbuffered(sys.stderr)
+if options.output:
+ logfile = open(options.output, 'w')
+ class Tee(object):
+ def __init__(self, openfile, stream):
+ self.file = openfile
+ self.stream = stream
+ def write(self, data):
+ self.file.write(data)
+ self.stream.write(data)
+ sys.stdout = Tee(logfile, sys.stdout)
+ sys.stderr = Tee(logfile, sys.stderr)
# --- define helpers ----
if sys.platform in ('win32', 'cygwin'):