summaryrefslogtreecommitdiff
path: root/runtests.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2021-07-31 20:43:48 +0200
committerStefan Behnel <stefan_ml@behnel.de>2021-07-31 20:44:03 +0200
commitc7dc24bc0a39af708976fb0a4bf63d2ee407badb (patch)
tree3152ecf11549e40b620f15b9faff39d3903bec44 /runtests.py
parentd9adf77d2eb997808120440ba09f65d2e609f722 (diff)
downloadcython-c7dc24bc0a39af708976fb0a4bf63d2ee407badb.tar.gz
runtests: include the C compiler error output in the compile exception to show it at the end of the test run.
Diffstat (limited to 'runtests.py')
-rwxr-xr-xruntests.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/runtests.py b/runtests.py
index e23fc41be..b0218ff81 100755
--- a/runtests.py
+++ b/runtests.py
@@ -1277,10 +1277,25 @@ class CythonCompileTestCase(unittest.TestCase):
extension.language = 'c++'
if IS_PY2:
workdir = str(workdir) # work around type check in distutils that disallows unicode strings
+
build_extension.extensions = [extension]
build_extension.build_temp = workdir
build_extension.build_lib = workdir
- build_extension.run()
+
+ from Cython.Utils import captured_fd, prepare_captured
+ from distutils.errors import CompileError
+
+ error = None
+ with captured_fd(2) as get_stderr:
+ try:
+ build_extension.run()
+ except CompileError as exc:
+ error = exc
+ stderr = prepare_captured(get_stderr())
+ if stderr:
+ print("Compiler output for module %s:\n%s" % (module, stderr))
+ if error is not None:
+ raise CompileError("%s\nCompiler output:\n%s" % (error, stderr))
finally:
os.chdir(cwd)