aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2019-03-27 12:46:42 +0100
committerNirbheek Chauhan <nirbheek@centricular.com>2019-04-17 00:04:11 +0530
commit3d734645b7c567b9f2178b1b3dccf46c96b2ee6b (patch)
tree4aac0d6ae6c00c80aa2f26bf8f10bd31c3cdccfd
parentf6757408f7295e4da675c519f24f6bc34ab931e2 (diff)
downloadmeson-3d734645b7c567b9f2178b1b3dccf46c96b2ee6b.zip
meson-3d734645b7c567b9f2178b1b3dccf46c96b2ee6b.tar.gz
meson-3d734645b7c567b9f2178b1b3dccf46c96b2ee6b.tar.bz2
mtest: fix TAP with --verbose
TAP needs to process the test stdout even if --verbose is passed. Capture it to a separate temporary file, and print it at the end of the test if --verbose was passed. In the future, we could parse it on the fly and print the result of each TAP test point in verbose mode.
-rw-r--r--mesonbuild/mtest.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 77a0f82..3b723f8 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -490,7 +490,9 @@ class SingleTestRunner:
stderr = None
if not self.options.verbose:
stdout = tempfile.TemporaryFile("wb+")
- stderr = tempfile.TemporaryFile("wb+") if self.options and self.options.split else stdout
+ stderr = tempfile.TemporaryFile("wb+") if self.options.split else stdout
+ if self.test.protocol == 'tap' and stdout == stderr:
+ stdout = tempfile.TemporaryFile("wb+")
# Let gdb handle ^C instead of us
if self.options.gdb:
@@ -570,17 +572,16 @@ class SingleTestRunner:
endtime = time.time()
duration = endtime - starttime
if additional_error is None:
- if stdout is None: # if stdout is None stderr should be as well
+ if stdout is None:
stdo = ''
- stde = ''
else:
stdout.seek(0)
stdo = decode(stdout.read())
- if stderr != stdout:
- stderr.seek(0)
- stde = decode(stderr.read())
- else:
- stde = ""
+ if stderr is None or stderr == stdout:
+ stde = ''
+ else:
+ stderr.seek(0)
+ stde = decode(stderr.read())
else:
stdo = ""
stde = additional_error
@@ -590,6 +591,8 @@ class SingleTestRunner:
if self.test.protocol == 'exitcode':
return TestRun.make_exitcode(self.test, p.returncode, duration, stdo, stde, cmd)
else:
+ if self.options.verbose:
+ print(stdo, end='')
return TestRun.make_tap(self.test, p.returncode, duration, stdo, stde, cmd)