diff options
author | R. David Murray <rdmurray@bitdance.com> | 2009-10-19 15:26:16 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2009-10-19 15:26:16 (GMT) |
commit | 2714460ac0126908782dde4f3afd27e5ce5dccd4 (patch) | |
tree | 67dc1d5f4fed195de636331b0e433c6f05b1e299 /Lib | |
parent | 1d93c87d734d1caba69dc873ed5fecb158d3dc86 (diff) | |
download | cpython-2714460ac0126908782dde4f3afd27e5ce5dccd4.zip cpython-2714460ac0126908782dde4f3afd27e5ce5dccd4.tar.gz cpython-2714460ac0126908782dde4f3afd27e5ce5dccd4.tar.bz2 |
Merged revisions 75503 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75503 | r.david.murray | 2009-10-18 17:12:37 -0400 (Sun, 18 Oct 2009) | 11 lines
Issue #7151: regrtest would generate a JSON failure if there was output
to stderr during the test run and it happened to get emitted after the
worker thread emitted the result JSON. Now we capture stdout and stderr
separately, which avoids that problem. It also means that _all_ stderr
output is after all stdout output when we print the test results, but
that seems acceptable, since output ordering is not guaranteed anyway.
The patch also moves the emit of the test name into the output block
generated after the test completes. Otherwise test names and test
output/errors were mixed in the terminal display, making it difficult
to determine which test generated the output.
........
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/test/regrtest.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 3f6bea7..586b8da 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -464,38 +464,38 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, try: test, args_tuple = pending.popleft() except IndexError: - output.put((None, None, None)) + output.put((None, None, None, None)) return - if not quiet: - with print_lock: - print(test) - sys.stdout.flush() # -E is needed by some tests, e.g. test_import popen = Popen([sys.executable, '-E', '-m', 'test.regrtest', '--slaveargs', json.dumps(args_tuple)], - stdout=PIPE, stderr=STDOUT, + stdout=PIPE, stderr=PIPE, universal_newlines=True, close_fds=True) - out = popen.communicate()[0].strip() - out = debug_output_pat.sub("", out) - out, _, result = out.strip().rpartition("\n") + stdout, stderr = popen.communicate() + # Strip last refcount output line if it exists, since it + # comes from the shutdown of the interpreter in the subcommand. + stderr = debug_output_pat.sub("", stderr) + stdout, _, result = stdout.strip().rpartition("\n") result = json.loads(result) - output.put((test, out.strip(), result)) + if not quiet: + stdout = test+'\n'+stdout + output.put((test, stdout.rstrip(), stderr.rstrip(), result)) except BaseException: - output.put((None, None, None)) + output.put((None, None, None, None)) raise workers = [Thread(target=work) for i in range(use_mp)] for worker in workers: worker.start() finished = 0 while finished < use_mp: - test, out, result = output.get() - if out: - with print_lock: - print(out) - sys.stdout.flush() + test, stdout, stderr, result = output.get() if test is None: finished += 1 continue + if stdout: + print(stdout) + if stderr: + print(stderr, file=sys.stderr) if result[0] == -4: assert result[1] == 'KeyboardInterrupt' pending.clear() |