Commit 0d57141d authored by Stefan Behnel's avatar Stefan Behnel

use "cerror" tag instead of more verbose "_FAIL_C_COMPILE" special casing in test runner

parent a8d3e827
...@@ -693,9 +693,6 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -693,9 +693,6 @@ class CythonCompileTestCase(unittest.TestCase):
if line.startswith("_ERRORS"): if line.startswith("_ERRORS"):
out.close() out.close()
out = ErrorWriter() out = ErrorWriter()
elif line.startswith('_FAIL_C_COMPILE'):
out.close()
return '_FAIL_C_COMPILE'
else: else:
out.write(line) out.write(line)
finally: finally:
...@@ -839,7 +836,7 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -839,7 +836,7 @@ class CythonCompileTestCase(unittest.TestCase):
finally: finally:
sys.stderr = old_stderr sys.stderr = old_stderr
if expected_errors == '_FAIL_C_COMPILE': if 'cerror' in self.tags['tag']:
if errors: if errors:
print("\n=== Expected C compile error ===") print("\n=== Expected C compile error ===")
print("\n\n=== Got Cython errors: ===") print("\n\n=== Got Cython errors: ===")
...@@ -873,7 +870,7 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -873,7 +870,7 @@ class CythonCompileTestCase(unittest.TestCase):
with captured_fd(2) as get_stderr: with captured_fd(2) as get_stderr:
so_path = self.run_distutils(test_directory, module, workdir, incdir) so_path = self.run_distutils(test_directory, module, workdir, incdir)
except Exception: except Exception:
if expected_errors == '_FAIL_C_COMPILE' and get_stderr and get_stderr(): if 'cerror' in self.tags['tag'] and get_stderr and get_stderr():
pass pass
else: else:
raise raise
...@@ -882,7 +879,7 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -882,7 +879,7 @@ class CythonCompileTestCase(unittest.TestCase):
if c_compiler_stderr: if c_compiler_stderr:
print("\n=== C/C++ compiler error output: ===") print("\n=== C/C++ compiler error output: ===")
print_bytes(c_compiler_stderr) print_bytes(c_compiler_stderr)
if expected_errors == '_FAIL_C_COMPILE': if 'cerror' in self.tags['tag']:
# must raise this outside the try block # must raise this outside the try block
raise RuntimeError('should have failed C compile') raise RuntimeError('should have failed C compile')
return so_path return so_path
......
# cython: optimize.use_switch=True # cython: optimize.use_switch=True
# mode: error # mode: error
# tag: cerror
import cython import cython
...@@ -10,5 +11,3 @@ cdef extern from *: ...@@ -10,5 +11,3 @@ cdef extern from *:
def is_not_one(int i): def is_not_one(int i):
return i != ONE and i != ONE_AGAIN return i != ONE and i != ONE_AGAIN
_FAIL_C_COMPILE = True
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