Commit c0cd9896 authored by Stefan Behnel's avatar Stefan Behnel

merge

--HG--
rename : bin/cythonrun => Cython/Build/BuildExecutable.py
parents 615b02ad 457f38f9
...@@ -38,6 +38,7 @@ Options: ...@@ -38,6 +38,7 @@ Options:
-2 Compile based on Python-2 syntax and code semantics. -2 Compile based on Python-2 syntax and code semantics.
-3 Compile based on Python-3 syntax and code semantics. -3 Compile based on Python-3 syntax and code semantics.
--fast-fail Abort the compilation on the first error --fast-fail Abort the compilation on the first error
--warning-error, -Werror Make all warnings into errors
-X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive -X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
""" """
...@@ -131,6 +132,8 @@ def parse_command_line(args): ...@@ -131,6 +132,8 @@ def parse_command_line(args):
options.language_level = 3 options.language_level = 3
elif option == "--fast-fail": elif option == "--fast-fail":
Options.fast_fail = True Options.fast_fail = True
elif option in ('-Werror', '--warning-errors'):
Options.warning_errors = True
elif option == "--disable-function-redefinition": elif option == "--disable-function-redefinition":
Options.disable_function_redefinition = True Options.disable_function_redefinition = True
elif option == "--directive" or option.startswith('-X'): elif option == "--directive" or option.startswith('-X'):
......
...@@ -176,6 +176,8 @@ def message(position, message, level=1): ...@@ -176,6 +176,8 @@ def message(position, message, level=1):
def warning(position, message, level=0): def warning(position, message, level=0):
if level < LEVEL: if level < LEVEL:
return return
if Options.warning_errors and position:
return error(position, message)
warn = CompileWarning(position, message) warn = CompileWarning(position, message)
line = "warning: %s\n" % warn line = "warning: %s\n" % warn
if listing_file: if listing_file:
......
...@@ -22,6 +22,9 @@ annotate = False ...@@ -22,6 +22,9 @@ annotate = False
# to keep going and printing further error messages. # to keep going and printing further error messages.
fast_fail = False fast_fail = False
# Make all warnings into errors.
warning_errors = False
# This will convert statements of the form "for i in range(...)" # This will convert statements of the form "for i in range(...)"
# to "for i from ..." when i is a cdef'd integer type, and the direction # to "for i from ..." when i is a cdef'd integer type, and the direction
# (i.e. sign of step) can be determined. # (i.e. sign of step) can be determined.
......
...@@ -290,6 +290,11 @@ class TestBuilder(object): ...@@ -290,6 +290,11 @@ class TestBuilder(object):
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):
if 'werror' in tags['tags']:
warning_errors = True
else:
warning_errors = False
if expect_errors: if expect_errors:
if 'cpp' in tags['tag'] and 'cpp' in self.languages: if 'cpp' in tags['tag'] and 'cpp' in self.languages:
languages = ['cpp'] languages = ['cpp']
...@@ -301,12 +306,12 @@ class TestBuilder(object): ...@@ -301,12 +306,12 @@ class TestBuilder(object):
languages = list(languages) languages = list(languages)
languages.remove('c') languages.remove('c')
tests = [ self.build_test(test_class, path, workdir, module, tests = [ self.build_test(test_class, path, workdir, module,
language, expect_errors) language, expect_errors, warning_errors)
for language in languages ] for language in languages ]
return tests return tests
def build_test(self, test_class, path, workdir, module, def build_test(self, test_class, path, workdir, module,
language, expect_errors): language, expect_errors, warning_errors):
workdir = os.path.join(workdir, language) workdir = os.path.join(workdir, language)
if not os.path.exists(workdir): if not os.path.exists(workdir):
os.makedirs(workdir) os.makedirs(workdir)
...@@ -318,13 +323,14 @@ class TestBuilder(object): ...@@ -318,13 +323,14 @@ class TestBuilder(object):
cleanup_sharedlibs=self.cleanup_sharedlibs, cleanup_sharedlibs=self.cleanup_sharedlibs,
cython_only=self.cython_only, cython_only=self.cython_only,
fork=self.fork, fork=self.fork,
language_level=self.language_level) language_level=self.language_level,
warning_errors=warning_errors)
class CythonCompileTestCase(unittest.TestCase): class CythonCompileTestCase(unittest.TestCase):
def __init__(self, test_directory, workdir, module, language='c', def __init__(self, test_directory, workdir, module, language='c',
expect_errors=False, annotate=False, cleanup_workdir=True, expect_errors=False, annotate=False, cleanup_workdir=True,
cleanup_sharedlibs=True, cython_only=False, fork=True, cleanup_sharedlibs=True, cython_only=False, fork=True,
language_level=2): language_level=2, warning_errors=False):
self.test_directory = test_directory self.test_directory = test_directory
self.workdir = workdir self.workdir = workdir
self.module = module self.module = module
...@@ -336,16 +342,23 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -336,16 +342,23 @@ class CythonCompileTestCase(unittest.TestCase):
self.cython_only = cython_only self.cython_only = cython_only
self.fork = fork self.fork = fork
self.language_level = language_level self.language_level = language_level
self.warning_errors = warning_errors
unittest.TestCase.__init__(self) unittest.TestCase.__init__(self)
def shortDescription(self): def shortDescription(self):
return "compiling (%s) %s" % (self.language, self.module) return "compiling (%s) %s" % (self.language, self.module)
def setUp(self): def setUp(self):
from Cython.Compiler import Options
Options.warning_errors = self.warning_errors
if self.workdir not in sys.path: if self.workdir not in sys.path:
sys.path.insert(0, self.workdir) sys.path.insert(0, self.workdir)
def tearDown(self): def tearDown(self):
from Cython.Compiler import Options
Options.warning_errors = False
try: try:
sys.path.remove(self.workdir) sys.path.remove(self.workdir)
except ValueError: except ValueError:
......
# mode: error
# tags: werror
cdef foo():
pass
def foo():
pass
_ERRORS = u"""
7:0: 'foo' redeclared
7:0: Overriding cdef method with def method.
"""
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