Commit e8c85867 authored by Stefan Behnel's avatar Stefan Behnel

send C compiler output in tests to same output stream (stderr) as unittest's output

parent cb9c9a5b
...@@ -836,12 +836,13 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -836,12 +836,13 @@ class CythonCompileTestCase(unittest.TestCase):
finally: finally:
sys.stderr = old_stderr sys.stderr = old_stderr
tostderr = sys.stderr.write
if 'cerror' in self.tags['tag']: if 'cerror' in self.tags['tag']:
if errors: if errors:
print("\n=== Expected C compile error ===") tostderr("\n=== Expected C compile error ===\n")
print("\n\n=== Got Cython errors: ===") tostderr("\n=== Got Cython errors: ===\n")
print('\n'.join(errors)) tostderr('\n'.join(errors))
print('\n') tostderr('\n\n')
raise RuntimeError('should have generated extension code') raise RuntimeError('should have generated extension code')
elif errors or expected_errors: elif errors or expected_errors:
try: try:
...@@ -854,11 +855,11 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -854,11 +855,11 @@ class CythonCompileTestCase(unittest.TestCase):
unexpected_error = errors[len(expected_errors)] unexpected_error = errors[len(expected_errors)]
self.assertEquals(None, unexpected_error) self.assertEquals(None, unexpected_error)
except AssertionError: except AssertionError:
print("\n=== Expected errors: ===") tostderr("\n=== Expected errors: ===\n")
print('\n'.join(expected_errors)) tostderr('\n'.join(expected_errors))
print("\n\n=== Got errors: ===") tostderr("\n\n=== Got errors: ===\n")
print('\n'.join(errors)) tostderr('\n'.join(errors))
print('\n') tostderr('\n\n')
raise raise
return None return None
...@@ -883,14 +884,14 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -883,14 +884,14 @@ class CythonCompileTestCase(unittest.TestCase):
if show_output: if show_output:
stdout = get_stdout and get_stdout().strip() stdout = get_stdout and get_stdout().strip()
if stdout: if stdout:
print("\n=== C/C++ compiler output: ===") tostderr("\n=== C/C++ compiler output: ===\n")
print_bytes(stdout, end=None) print_bytes(stdout, end=None, file=sys.stderr)
stderr = get_stderr and get_stderr().strip() stderr = get_stderr and get_stderr().strip()
if stderr: if stderr:
print("\n=== C/C++ compiler error output: ===") tostderr("\n=== C/C++ compiler error output: ===\n")
print_bytes(stderr, end=None) print_bytes(stderr, end=None, file=sys.stderr)
if stdout or stderr: if stdout or stderr:
print("\n==============================") tostderr("\n==============================\n")
return so_path return so_path
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment