Merge lp:~jaypipes/nova/redirect-stderr-runtests into lp:~hudson-openstack/nova/trunk

Proposed by Jay Pipes
Status: Merged
Approved by: Soren Hansen
Approved revision: 141
Merged at revision: 149
Proposed branch: lp:~jaypipes/nova/redirect-stderr-runtests
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 39 lines (+10/-0)
2 files modified
.bzrignore (+1/-0)
run_tests.py (+9/-0)
To merge this branch: bzr merge lp:~jaypipes/nova/redirect-stderr-runtests
Reviewer Review Type Date Requested Status
Joshua McKenty (community) Approve
Monty Taylor (community) Approve
OpenStack Infra Pending
Review via email: mp+30118@code.launchpad.net

Commit message

Redirect STDERR to output to an errlog file when running run_tests.py.

Adds a flag option for specifying the output file and adds a bzr ignore rule to disregard the generated logfile.

Description of the change

This patch redirects STDERR output to an errlog file when running run_tests.py.

Adds a flag option for specifying the output file and adds a bzr ignore rule to disregard the generated logfile.

To post a comment you must log in.
Revision history for this message
Monty Taylor (mordred) wrote :

Looks good to me. I'll point out that you don't explicitly close that file object- but I also don't fully care. :)

review: Approve
Revision history for this message
Joshua McKenty (joshua-mckenty) wrote :

lgtm - as an enhancement, disable the redirect when tests_stderr is ''? (I'm thinking of being able to see what happened via stdio in a buildbot console, for instance.)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2010-07-16 15:07:42 +0000
4@@ -0,0 +1,1 @@
5+run_tests.err.log
6
7=== modified file 'run_tests.py'
8--- run_tests.py 2010-07-15 15:52:11 +0000
9+++ run_tests.py 2010-07-16 15:07:42 +0000
10@@ -39,6 +39,7 @@
11
12 """
13 import __main__
14+import os
15 import sys
16
17 from nova import vendor
18@@ -66,6 +67,9 @@
19 flags.DEFINE_bool('flush_db', True,
20 'Flush the database before running fake tests')
21
22+flags.DEFINE_string('tests_stderr', 'run_tests.err.log',
23+ 'Path to where to pipe STDERR during test runs. Default = "run_tests.err.log"')
24+
25 if __name__ == '__main__':
26 OptionsClass = twistd.WrapTwistedOptions(trial_script.Options)
27 config = OptionsClass()
28@@ -85,6 +89,11 @@
29 else:
30 from nova.tests.real_flags import *
31
32+ # Establish redirect for STDERR
33+ sys.stderr.flush()
34+ err = open(FLAGS.tests_stderr, 'w+', 0)
35+ os.dup2(err.fileno(), sys.stderr.fileno())
36+
37 if len(argv) == 1 and len(config['tests']) == 0:
38 # If no tests were specified run the ones imported in this file
39 # NOTE(termie): "tests" is not a flag, just some Trial related stuff