Commit 4e2592b0 authored by Stefan Behnel's avatar Stefan Behnel

enable warning output in tests (currently unused)

parent 24635506
...@@ -17,20 +17,31 @@ CFLAGS = os.getenv('CFLAGS', '').split() ...@@ -17,20 +17,31 @@ CFLAGS = os.getenv('CFLAGS', '').split()
class ErrorWriter(object): class ErrorWriter(object):
match_error = re.compile('(?:.*:)?([-0-9]+):([-0-9]+):(.*)').match match_error = re.compile('(warning:)?(?:.*:)?([-0-9]+):([-0-9]+):(.*)').match
def __init__(self): def __init__(self):
self.output = [] self.output = []
self.write = self.output.append self.write = self.output.append
def geterrors(self): def _collect(self, collect_errors, collect_warnings):
s = ''.join(self.output) s = ''.join(self.output)
errors = [] result = []
for line in s.split('\n'): for line in s.split('\n'):
match = self.match_error(line) match = self.match_error(line)
if match: if match:
line, column, message = match.groups() is_warning, line, column, message = match.groups()
errors.append( "%d:%d:%s" % (int(line), int(column), message.strip()) ) if (is_warning and collect_warnings) or \
return errors (not is_warning and collect_errors):
result.append( "%d:%d:%s" % (int(line), int(column), message.strip()) )
return result
def geterrors(self):
return self._collect(True, False)
def getwarnings(self):
return self._collect(False, True)
def getall(self):
return self._collect(True, True)
class TestBuilder(object): class TestBuilder(object):
def __init__(self, rootdir, workdir, selectors, annotate, cleanup_workdir): def __init__(self, rootdir, workdir, selectors, annotate, cleanup_workdir):
...@@ -259,6 +270,8 @@ if __name__ == '__main__': ...@@ -259,6 +270,8 @@ if __name__ == '__main__':
CompilationOptions, \ CompilationOptions, \
default_options as pyrex_default_options, \ default_options as pyrex_default_options, \
compile as cython_compile compile as cython_compile
from Cython.Compiler import Errors
Errors.LEVEL = 0 # show all warnings
# RUN ALL TESTS! # RUN ALL TESTS!
ROOTDIR = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'tests') ROOTDIR = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'tests')
......
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