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.
pull/5228/head
Paolo Bonzini 6 years ago committed by Jussi Pakkanen
parent e8a688428d
commit a2c3ba474a
  1. 15
      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:
if stderr is None or stderr is stdout:
stde = ''
else:
stderr.seek(0)
stde = decode(stderr.read())
else:
stde = ""
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)

Loading…
Cancel
Save