summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2022-01-25 12:45:05 -0800
committerEli Bendersky <eliben@gmail.com>2022-01-25 12:45:05 -0800
commit6a7edee64c13d06e02b5eef554d9d6d10dcb71c0 (patch)
treee5bad3566299c849bf8b0bf0b0e7b043d7adab75
parent7999dde25706e8a2b4bc63634b058d79bdb6417f (diff)
downloadpycparser-6a7edee64c13d06e02b5eef554d9d6d10dcb71c0.tar.gz
Improve error reporting from test_examples
Emit stderr as well as stdout from the example in case of failure
-rw-r--r--tests/test_examples.py4
-rw-r--r--tests/test_util.py6
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_examples.py b/tests/test_examples.py
index 3c516e1..7fb2ad3 100644
--- a/tests/test_examples.py
+++ b/tests/test_examples.py
@@ -21,12 +21,12 @@ class TestExamplesSucceed(unittest.TestCase):
# Use it when we finally drop Python 2...
path = os.path.join(root, filename)
t1 = time.time()
- rc, stdout = run_exe(path)
+ rc, stdout, stderr = run_exe(path)
elapsed = time.time() - t1
if EMIT_ELAPSED_TIME:
print('{}... elapsed: {}'.format(filename, elapsed))
self.assertEqual(
- rc, 0, 'example "{}" failed with stdout =\n{}'.format(filename, stdout))
+ rc, 0, 'example "{}" failed with stdout =\n{}\nstderr =\n{}'.format(filename, stdout, stderr))
if __name__ == '__main__':
diff --git a/tests/test_util.py b/tests/test_util.py
index 38dfdf5..a945c29 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -42,7 +42,7 @@ def _bytes2str(b):
def run_exe(exe_path, args=[], echo=False):
""" Runs the given executable as a subprocess, given the
list of arguments. Captures its return code (rc) and stdout and
- returns a pair: rc, stdout_str
+ returns a tuple: rc, stdout, stderr
"""
popen_cmd = [exe_path] + args
if os.path.splitext(exe_path)[1] == '.py':
@@ -50,5 +50,5 @@ def run_exe(exe_path, args=[], echo=False):
if echo:
print('[cmd]', ' '.join(popen_cmd))
proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- proc_stdout = proc.communicate()[0]
- return proc.returncode, _bytes2str(proc_stdout)
+ stdout, stderr = proc.communicate()
+ return proc.returncode, _bytes2str(stdout), _bytes2str(stderr)