diff options
author | David Robillard <d@drobilla.net> | 2019-11-10 17:20:31 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-11-10 17:20:31 +0100 |
commit | c87cc53c643c60867665b333d5999fe07196d543 (patch) | |
tree | 7a8714199c0c20f01154ce4cbea71564808927bd /extras | |
parent | a99c1c3a95609aea3f025659709afef375097646 (diff) | |
download | autowaf-c87cc53c643c60867665b333d5999fe07196d543.tar.gz autowaf-c87cc53c643c60867665b333d5999fe07196d543.tar.bz2 autowaf-c87cc53c643c60867665b333d5999fe07196d543.zip |
Print stderr of failed tests
Diffstat (limited to 'extras')
-rw-r--r-- | extras/autowaf.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/extras/autowaf.py b/extras/autowaf.py index 5d08658..9831353 100644 --- a/extras/autowaf.py +++ b/extras/autowaf.py @@ -914,6 +914,8 @@ class TestScope: stdout=None, stderr=None, verbosity=1): + import tempfile + def stream(s): return open(s, 'wb') if type(s) == str else s @@ -927,11 +929,25 @@ class TestScope: output = TestOutput(expected) with open(os.devnull, 'wb') as null: out = null if verbosity < 3 and not stdout else stdout - err = null if verbosity < 2 and not stderr else stderr + tmp_err = None + if stderr or verbosity >= 2: + err = stderr + else: + tmp_err = tempfile.TemporaryFile() + err = tmp_err + proc = subprocess.Popen(test, stdin=stdin, stdout=out, stderr=err) output.stdout, output.stderr = proc.communicate() output.result = proc.returncode + if tmp_err is not None: + if output.result != expected: + tmp_err.seek(0) + for line in tmp_err: + sys.stderr.write(line.decode('utf-8')) + + tmp_err.close() + if output and verbosity > 0: self.tst.log_good(' OK', name) |