aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mtest.py
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2019-04-07 01:42:44 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2019-04-07 02:42:44 +0300
commita2c3ba474a5ad47539b5ecf7218db272fab8359f (patch)
tree129c69bfe8b39b9814136b7934fc71be1a179080 /mesonbuild/mtest.py
parente8a688428de096ba9cc7e82614a68aebe855dabf (diff)
downloadmeson-a2c3ba474a5ad47539b5ecf7218db272fab8359f.zip
meson-a2c3ba474a5ad47539b5ecf7218db272fab8359f.tar.gz
meson-a2c3ba474a5ad47539b5ecf7218db272fab8359f.tar.bz2
mtest: fix TAP with --verbose (#5160)
* 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. * Prefer "stderr is stdout" to "==" The previous commit used "==" in accordance with the preexisting code, but reviewers preferred using "is" instead. Fix both occurrences.
Diffstat (limited to 'mesonbuild/mtest.py')
-rw-r--r--mesonbuild/mtest.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index dc82084..0f15690 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 stderr is stdout:
+ 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 is 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)