Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
edb10a47
Commit
edb10a47
authored
Apr 24, 2014
by
Alok Singhal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better logic for C compile failure support in runtests.py
parent
d9b3c477
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
17 deletions
+20
-17
runtests.py
runtests.py
+19
-14
tests/errors/e_switch_transform.pyx
tests/errors/e_switch_transform.pyx
+1
-3
No files found.
runtests.py
View file @
edb10a47
...
@@ -399,7 +399,6 @@ class ErrorWriter(object):
...
@@ -399,7 +399,6 @@ class ErrorWriter(object):
def _collect(self, collect_errors, collect_warnings):
def _collect(self, collect_errors, collect_warnings):
s = ''.join(self.output)
s = ''.join(self.output)
result = []
result = []
runtime_error = False
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:
...
@@ -407,10 +406,8 @@ class ErrorWriter(object):
...
@@ -407,10 +406,8 @@ class ErrorWriter(object):
if (is_warning and collect_warnings) or
\
if (is_warning and collect_warnings) or
\
(not is_warning and collect_errors):
(not is_warning and collect_errors):
result.append( (int(line), int(column), message.strip()) )
result.append( (int(line), int(column), message.strip()) )
elif 'runtime error' in line:
runtime_error = True
result.sort()
result.sort()
return [ "
%
d
:
%
d
:
%
s
" % values for values in result ]
, runtime_error
return [ "
%
d
:
%
d
:
%
s
" % values for values in result ]
def geterrors(self):
def geterrors(self):
return self._collect(True, False)
return self._collect(True, False)
...
@@ -696,15 +693,19 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -696,15 +693,19 @@ 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:
source_and_output.close()
source_and_output.close()
try:
try:
geterrors = out.geterrors
geterrors = out.geterrors
except AttributeError:
except AttributeError:
out.close()
out.close()
return []
, False
return []
else:
else:
return geterrors()
return geterrors()
...
@@ -825,7 +826,7 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -825,7 +826,7 @@ class CythonCompileTestCase(unittest.TestCase):
expect_errors, annotate):
expect_errors, annotate):
expected_errors = errors = ()
expected_errors = errors = ()
if expect_errors:
if expect_errors:
expected_errors
, runtime_error
= self.split_source_and_output(
expected_errors = self.split_source_and_output(
test_directory, module, workdir)
test_directory, module, workdir)
test_directory = workdir
test_directory = workdir
...
@@ -834,11 +835,18 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -834,11 +835,18 @@ class CythonCompileTestCase(unittest.TestCase):
try:
try:
sys.stderr = ErrorWriter()
sys.stderr = ErrorWriter()
self.run_cython(test_directory, module, workdir, incdir, annotate)
self.run_cython(test_directory, module, workdir, incdir, annotate)
errors
, _
= sys.stderr.geterrors()
errors = sys.stderr.geterrors()
finally:
finally:
sys.stderr = old_stderr
sys.stderr = old_stderr
if errors or expected_errors:
if expected_errors == '_FAIL_C_COMPILE':
if errors:
print("
\
n
===
Expected
C
compile
error
===
")
print("
\
n
\
n
===
Got
Cython
errors
:
===
")
print('
\
n
'.join(errors))
print('
\
n
')
raise RuntimeError('should have generated extension code')
elif errors or expected_errors:
try:
try:
for expected, error in zip(expected_errors, errors):
for expected, error in zip(expected_errors, errors):
self.assertEquals(expected, error)
self.assertEquals(expected, error)
...
@@ -857,15 +865,12 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -857,15 +865,12 @@ class CythonCompileTestCase(unittest.TestCase):
raise
raise
return None
return None
if self.cython_only:
so_path = None
so_path = None
if not self.cython_only:
else:
try:
try:
so_path = self.run_distutils(test_directory, module, workdir, incdir)
so_path = self.run_distutils(test_directory, module, workdir, incdir)
except:
except:
if runtime_error:
if expected_errors != '_FAIL_C_COMPILE':
return None
else:
raise
raise
return so_path
return so_path
...
...
tests/errors/e_switch_transform.pyx
View file @
edb10a47
...
@@ -11,6 +11,4 @@ cdef extern from "../run/includes/switch_transform_support.h":
...
@@ -11,6 +11,4 @@ cdef extern from "../run/includes/switch_transform_support.h":
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
_ERRORS
=
u'''
_FAIL_C_COMPILE
=
True
runtime error
'''
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment