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
39bf23cc
Commit
39bf23cc
authored
May 03, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve presentation of C compiler stderr/stdout output in test runner
parent
6008ea90
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
15 deletions
+27
-15
Cython/Utils.py
Cython/Utils.py
+8
-6
runtests.py
runtests.py
+19
-9
No files found.
Cython/Utils.py
View file @
39bf23cc
...
...
@@ -388,12 +388,14 @@ def captured_fd(stream=2, encoding=None):
os
.
close
(
orig_stream
)
def
print_bytes
(
s
,
stream
=
sys
.
stdout
):
stream
.
flush
()
def
print_bytes
(
s
,
end
=
b'
\
n
'
,
file
=
sys
.
stdout
,
flush
=
True
):
file
.
flush
()
try
:
out
=
stream
.
buffer
# Py3
out
=
file
.
buffer
# Py3
except
AttributeError
:
out
=
stream
# Py2
out
=
file
# Py2
out
.
write
(
s
)
out
.
write
(
b'
\
n
'
)
if
end
:
out
.
write
(
end
)
if
flush
:
out
.
flush
()
runtests.py
View file @
39bf23cc
...
...
@@ -865,25 +865,35 @@ class CythonCompileTestCase(unittest.TestCase):
so_path = None
if not self.cython_only:
from Cython.Utils import captured_fd, print_bytes
get_stderr = None
show_output = True
get_stderr = get_stdout = None
try:
with captured_fd(1) as get_stdout:
with captured_fd(2) as get_stderr:
so_path = self.run_distutils(test_directory, module, workdir, incdir)
except Exception:
if 'cerror' in self.tags['tag'] and get_stderr and get_stderr():
pass
show_output = False # expected C compiler failure
else:
raise
else:
c_compiler_stderr = get_stderr().strip()
if c_compiler_stderr:
print("
\
n
===
C
/
C
++
compiler
error
output
:
===
")
print_bytes(c_compiler_stderr)
if 'cerror' in self.tags['tag']:
# must raise this outside the try block
raise RuntimeError('should have failed C compile')
finally:
if show_output:
stdout = get_stdout and get_stdout().strip()
if stdout:
print("
\
n
===
C
/
C
++
compiler
output
:
===
")
print_bytes(stdout, end=None)
stderr = get_stderr and get_stderr().strip()
if stderr:
print("
\
n
===
C
/
C
++
compiler
error
output
:
===
")
print_bytes(stderr, end=None)
if stdout or stderr:
print("
\
n
==============================
")
return so_path
class CythonRunTestCase(CythonCompileTestCase):
def setUp(self):
CythonCompileTestCase.setUp(self)
...
...
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