Commit 96e2c88b authored by Robert Bradshaw's avatar Robert Bradshaw

Fail test when expected C compiler error not encountered.

parent a72e23ea
...@@ -481,7 +481,7 @@ class TestBuilder(object): ...@@ -481,7 +481,7 @@ class TestBuilder(object):
if match(fqmodule, tags) ]: if match(fqmodule, tags) ]:
continue continue
if self.exclude_selectors: if self.exclude_selectors:
if [1 for match in self.exclude_selectors if [1 for match in self.exclude_selectors
if match(fqmodule, tags)]: if match(fqmodule, tags)]:
continue continue
...@@ -515,7 +515,7 @@ class TestBuilder(object): ...@@ -515,7 +515,7 @@ class TestBuilder(object):
if mode == 'run' and ext == '.py' and not self.cython_only: if mode == 'run' and ext == '.py' and not self.cython_only:
# additionally test file in real Python # additionally test file in real Python
suite.addTest(PureDoctestTestCase(module, os.path.join(path, filename))) suite.addTest(PureDoctestTestCase(module, os.path.join(path, filename)))
return suite return suite
def build_tests(self, test_class, path, workdir, module, expect_errors, tags): def build_tests(self, test_class, path, workdir, module, expect_errors, tags):
...@@ -869,9 +869,14 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -869,9 +869,14 @@ class CythonCompileTestCase(unittest.TestCase):
if not self.cython_only: if not self.cython_only:
try: try:
so_path = self.run_distutils(test_directory, module, workdir, incdir) so_path = self.run_distutils(test_directory, module, workdir, incdir)
except: compiled = True
except Exception:
compiled = False
if expected_errors != '_FAIL_C_COMPILE': if expected_errors != '_FAIL_C_COMPILE':
raise raise
if compiled and expected_errors == '_FAIL_C_COMPILE':
# must raise this outside the try block
raise RuntimeError('should have failed C compile')
return so_path return so_path
class CythonRunTestCase(CythonCompileTestCase): class CythonRunTestCase(CythonCompileTestCase):
...@@ -1418,7 +1423,7 @@ class TagsSelector: ...@@ -1418,7 +1423,7 @@ class TagsSelector:
def __init__(self, tag, value): def __init__(self, tag, value):
self.tag = tag self.tag = tag
self.value = value self.value = value
def __call__(self, testname, tags=None): def __call__(self, testname, tags=None):
if tags is None: if tags is None:
return False return False
...@@ -1426,7 +1431,7 @@ class TagsSelector: ...@@ -1426,7 +1431,7 @@ class TagsSelector:
return self.value in tags[self.tag] return self.value in tags[self.tag]
class RegExSelector: class RegExSelector:
def __init__(self, pattern_string): def __init__(self, pattern_string):
try: try:
self.pattern = re.compile(pattern_string, re.I|re.U) self.pattern = re.compile(pattern_string, re.I|re.U)
...@@ -1454,7 +1459,7 @@ class ShardExcludeSelector: ...@@ -1454,7 +1459,7 @@ class ShardExcludeSelector:
def __call__(self, testname, tags=None): def __call__(self, testname, tags=None):
return abs(hash(testname)) % self.shard_count != self.shard_num return abs(hash(testname)) % self.shard_count != self.shard_num
def refactor_for_py3(distdir, cy3_dir): def refactor_for_py3(distdir, cy3_dir):
# need to convert Cython sources first # need to convert Cython sources first
...@@ -1659,7 +1664,7 @@ def main(): ...@@ -1659,7 +1664,7 @@ def main():
options, cmd_args = parser.parse_args() options, cmd_args = parser.parse_args()
WORKDIR = os.path.abspath(options.work_dir) WORKDIR = os.path.abspath(options.work_dir)
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
options.doctests = False options.doctests = False
if options.with_cython: if options.with_cython:
...@@ -1758,7 +1763,7 @@ def runtests(options, cmd_args, coverage=None): ...@@ -1758,7 +1763,7 @@ def runtests(options, cmd_args, coverage=None):
if options.shard_num > -1: if options.shard_num > -1:
WORKDIR = os.path.join(WORKDIR, str(options.shard_num)) WORKDIR = os.path.join(WORKDIR, str(options.shard_num))
# RUN ALL TESTS! # RUN ALL TESTS!
UNITTEST_MODULE = "Cython" UNITTEST_MODULE = "Cython"
UNITTEST_ROOT = os.path.join(os.path.dirname(__file__), UNITTEST_MODULE) UNITTEST_ROOT = os.path.join(os.path.dirname(__file__), UNITTEST_MODULE)
......
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