From 42687a36162026fb771553e06d6aa792593e61ac Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 9 Dec 2013 16:04:08 +0100 Subject: [PATCH] Add --output switch to the test runner refs #5223 --- test/jenkins/run_tests.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/jenkins/run_tests.py b/test/jenkins/run_tests.py index f0a180cd9..739aacab8 100755 --- a/test/jenkins/run_tests.py +++ b/test/jenkins/run_tests.py @@ -84,15 +84,15 @@ class TestSuite(object): def _remove_file(self, path): command = self._config['commands']['clean'].format(path) - subprocess.call(command, stdout=DEVNULL, stderr=DEVNULL, shell=True) + subprocess.call(command, stdout=DEVNULL, shell=True) def _exec_command(self, command): command = self._config['commands']['exec'].format(command) - subprocess.call(command, stdout=DEVNULL, stderr=DEVNULL, shell=True) + subprocess.call(command, stdout=DEVNULL, shell=True) def _copy_file(self, source, destination): command = self._config['commands']['copy'].format(source, destination) - subprocess.call(command, stdout=DEVNULL, stderr=DEVNULL, shell=True) + subprocess.call(command, stdout=DEVNULL, shell=True) def _copy_test(self, path): self._copy_file(path, os.path.join(self._config['settings']['test_root'], @@ -117,6 +117,9 @@ def parse_commandline(): parser = OptionParser(version='0.1') parser.add_option('-C', '--config', default="run_tests.conf", help='The path to the config file to use [%default]') + parser.add_option('-O', '--output', + help='The file which to save the test results. ' + '(By default this goes to stdout)') return parser.parse_args() @@ -128,7 +131,14 @@ def main(): suite.add_test(path) suite.run() - print suite.get_report().encode('utf-8') + + report = suite.get_report() + if options.output is None: + print report.encode('utf-8') + else: + with open(options.output, 'w') as f: + f.write(report.encode('utf-8')) + return 0 -- 2.40.0