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
b6021cfa
Commit
b6021cfa
authored
Aug 31, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compile all tests as C and C++
parent
6363c558
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
35 deletions
+58
-35
runtests.py
runtests.py
+58
-35
No files found.
runtests.py
View file @
b6021cfa
...
@@ -52,7 +52,8 @@ class ErrorWriter(object):
...
@@ -52,7 +52,8 @@ class ErrorWriter(object):
class
TestBuilder
(
object
):
class
TestBuilder
(
object
):
def
__init__
(
self
,
rootdir
,
workdir
,
selectors
,
exclude_selectors
,
annotate
,
def
__init__
(
self
,
rootdir
,
workdir
,
selectors
,
exclude_selectors
,
annotate
,
cleanup_workdir
,
cleanup_sharedlibs
,
with_pyregr
,
cythononly
):
cleanup_workdir
,
cleanup_sharedlibs
,
with_pyregr
,
cython_only
,
languages
):
self
.
rootdir
=
rootdir
self
.
rootdir
=
rootdir
self
.
workdir
=
workdir
self
.
workdir
=
workdir
self
.
selectors
=
selectors
self
.
selectors
=
selectors
...
@@ -61,7 +62,8 @@ class TestBuilder(object):
...
@@ -61,7 +62,8 @@ class TestBuilder(object):
self
.
cleanup_workdir
=
cleanup_workdir
self
.
cleanup_workdir
=
cleanup_workdir
self
.
cleanup_sharedlibs
=
cleanup_sharedlibs
self
.
cleanup_sharedlibs
=
cleanup_sharedlibs
self
.
with_pyregr
=
with_pyregr
self
.
with_pyregr
=
with_pyregr
self
.
cythononly
=
cythononly
self
.
cython_only
=
cython_only
self
.
languages
=
languages
def
build_suite
(
self
):
def
build_suite
(
self
):
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
@@ -106,49 +108,56 @@ class TestBuilder(object):
...
@@ -106,49 +108,56 @@ class TestBuilder(object):
continue
continue
if
context
in
TEST_RUN_DIRS
:
if
context
in
TEST_RUN_DIRS
:
if
module
.
startswith
(
"test_"
):
if
module
.
startswith
(
"test_"
):
build_test
=
CythonUnitTestCase
test_class
=
CythonUnitTestCase
else
:
else
:
build_test
=
CythonRunTestCase
test_class
=
CythonRunTestCase
test
=
build_test
(
path
,
workdir
,
module
,
annotate
=
self
.
annotate
,
cleanup_workdir
=
self
.
cleanup_workdir
,
cleanup_sharedlibs
=
self
.
cleanup_sharedlibs
,
cythononly
=
self
.
cythononly
)
else
:
else
:
test
=
CythonCompileTestCase
(
test_class
=
CythonCompileTestCase
path
,
workdir
,
module
,
for
test
in
self
.
build_tests
(
test_class
,
path
,
workdir
,
expect_errors
=
expect_errors
,
module
,
expect_errors
):
annotate
=
self
.
annotate
,
suite
.
addTest
(
test
)
cleanup_workdir
=
self
.
cleanup_workdir
,
cleanup_sharedlibs
=
self
.
cleanup_sharedlibs
,
cythononly
=
self
.
cythononly
)
suite
.
addTest
(
test
)
return
suite
return
suite
def
build_tests
(
self
,
test_class
,
path
,
workdir
,
module
,
expect_errors
):
tests
=
[
self
.
build_test
(
test_class
,
path
,
workdir
,
module
,
language
,
expect_errors
)
for
language
in
self
.
languages
]
return
tests
def
build_test
(
self
,
test_class
,
path
,
workdir
,
module
,
language
,
expect_errors
):
return
test_class
(
path
,
workdir
,
module
,
language
=
language
,
expect_errors
=
expect_errors
,
annotate
=
self
.
annotate
,
cleanup_workdir
=
self
.
cleanup_workdir
,
cleanup_sharedlibs
=
self
.
cleanup_sharedlibs
,
cython_only
=
self
.
cython_only
)
class
CythonCompileTestCase
(
unittest
.
TestCase
):
class
CythonCompileTestCase
(
unittest
.
TestCase
):
def
__init__
(
self
,
directory
,
workdir
,
module
,
def
__init__
(
self
,
directory
,
workdir
,
module
,
language
=
'c'
,
expect_errors
=
False
,
annotate
=
False
,
cleanup_workdir
=
True
,
expect_errors
=
False
,
annotate
=
False
,
cleanup_workdir
=
True
,
cleanup_sharedlibs
=
True
,
cythononly
=
False
):
cleanup_sharedlibs
=
True
,
cython
_
only
=
False
):
self
.
directory
=
directory
self
.
directory
=
directory
self
.
workdir
=
workdir
self
.
workdir
=
workdir
self
.
module
=
module
self
.
module
=
module
self
.
language
=
language
self
.
expect_errors
=
expect_errors
self
.
expect_errors
=
expect_errors
self
.
annotate
=
annotate
self
.
annotate
=
annotate
self
.
cleanup_workdir
=
cleanup_workdir
self
.
cleanup_workdir
=
cleanup_workdir
self
.
cleanup_sharedlibs
=
cleanup_sharedlibs
self
.
cleanup_sharedlibs
=
cleanup_sharedlibs
self
.
cython
only
=
cython
only
self
.
cython
_only
=
cython_
only
unittest
.
TestCase
.
__init__
(
self
)
unittest
.
TestCase
.
__init__
(
self
)
def
shortDescription
(
self
):
def
shortDescription
(
self
):
return
"compiling
"
+
self
.
module
return
"compiling
(%s) %s"
%
(
self
.
language
,
self
.
module
)
def
tearDown
(
self
):
def
tearDown
(
self
):
cleanup_c_files
=
WITH_CYTHON
and
self
.
cleanup_workdir
cleanup_c_files
=
WITH_CYTHON
and
self
.
cleanup_workdir
cleanup_lib_files
=
self
.
cleanup_sharedlibs
cleanup_lib_files
=
self
.
cleanup_sharedlibs
if
os
.
path
.
exists
(
self
.
workdir
):
if
os
.
path
.
exists
(
self
.
workdir
):
for
rmfile
in
os
.
listdir
(
self
.
workdir
):
for
rmfile
in
os
.
listdir
(
self
.
workdir
):
if
not
cleanup_c_files
and
rmfile
[
-
2
:]
in
(
".c"
,
".h"
):
if
not
cleanup_c_files
and
rmfile
[
-
2
:]
in
(
".c"
,
".h"
,
".cpp"
):
continue
continue
if
not
cleanup_lib_files
and
rmfile
.
endswith
(
".so"
)
or
rmfile
.
endswith
(
".dll"
):
if
not
cleanup_lib_files
and
rmfile
.
endswith
(
".so"
)
or
rmfile
.
endswith
(
".dll"
):
continue
continue
...
@@ -202,13 +211,15 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -202,13 +211,15 @@ class CythonCompileTestCase(unittest.TestCase):
include_dirs
.
append
(
incdir
)
include_dirs
.
append
(
incdir
)
source
=
self
.
find_module_source_file
(
source
=
self
.
find_module_source_file
(
os
.
path
.
join
(
directory
,
module
+
'.pyx'
))
os
.
path
.
join
(
directory
,
module
+
'.pyx'
))
target
=
os
.
path
.
join
(
targetdir
,
module
+
'.
c'
)
target
=
os
.
path
.
join
(
targetdir
,
module
+
'.
'
+
self
.
language
)
options
=
CompilationOptions
(
options
=
CompilationOptions
(
pyrex_default_options
,
pyrex_default_options
,
include_path
=
include_dirs
,
include_path
=
include_dirs
,
output_file
=
target
,
output_file
=
target
,
annotate
=
annotate
,
annotate
=
annotate
,
use_listing_file
=
False
,
cplus
=
False
,
generate_pxi
=
False
)
use_listing_file
=
False
,
cplus
=
self
.
language
==
'cpp'
,
generate_pxi
=
False
)
cython_compile
(
source
,
options
=
options
,
cython_compile
(
source
,
options
=
options
,
full_module_name
=
module
)
full_module_name
=
module
)
...
@@ -224,7 +235,7 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -224,7 +235,7 @@ class CythonCompileTestCase(unittest.TestCase):
extension
=
Extension
(
extension
=
Extension
(
module
,
module
,
sources
=
[
module
+
'.
c'
],
sources
=
[
module
+
'.
'
+
self
.
language
],
extra_compile_args
=
CFLAGS
,
extra_compile_args
=
CFLAGS
,
)
)
build_extension
.
extensions
=
[
extension
]
build_extension
.
extensions
=
[
extension
]
...
@@ -261,12 +272,12 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -261,12 +272,12 @@ class CythonCompileTestCase(unittest.TestCase):
unexpected_error
=
errors
[
len
(
expected_errors
)]
unexpected_error
=
errors
[
len
(
expected_errors
)]
self
.
assertEquals
(
None
,
unexpected_error
)
self
.
assertEquals
(
None
,
unexpected_error
)
else
:
else
:
if
not
self
.
cythononly
:
if
not
self
.
cython
_
only
:
self
.
run_distutils
(
module
,
workdir
,
incdir
)
self
.
run_distutils
(
module
,
workdir
,
incdir
)
class
CythonRunTestCase
(
CythonCompileTestCase
):
class
CythonRunTestCase
(
CythonCompileTestCase
):
def
shortDescription
(
self
):
def
shortDescription
(
self
):
return
"compiling
and running "
+
self
.
module
return
"compiling
(%s) and running %s"
%
(
self
.
language
,
self
.
module
)
def
run
(
self
,
result
=
None
):
def
run
(
self
,
result
=
None
):
if
result
is
None
:
if
result
is
None
:
...
@@ -274,7 +285,7 @@ class CythonRunTestCase(CythonCompileTestCase):
...
@@ -274,7 +285,7 @@ class CythonRunTestCase(CythonCompileTestCase):
result
.
startTest
(
self
)
result
.
startTest
(
self
)
try
:
try
:
self
.
runCompileTest
()
self
.
runCompileTest
()
if
not
self
.
cythononly
:
if
not
self
.
cython
_
only
:
sys
.
stderr
.
write
(
'running doctests in %s ...
\
n
'
%
self
.
module
)
sys
.
stderr
.
write
(
'running doctests in %s ...
\
n
'
%
self
.
module
)
doctest
.
DocTestSuite
(
self
.
module
).
run
(
result
)
doctest
.
DocTestSuite
(
self
.
module
).
run
(
result
)
except
Exception
:
except
Exception
:
...
@@ -287,7 +298,7 @@ class CythonRunTestCase(CythonCompileTestCase):
...
@@ -287,7 +298,7 @@ class CythonRunTestCase(CythonCompileTestCase):
class
CythonUnitTestCase
(
CythonCompileTestCase
):
class
CythonUnitTestCase
(
CythonCompileTestCase
):
def
shortDescription
(
self
):
def
shortDescription
(
self
):
return
"compiling
tests in "
+
self
.
module
return
"compiling
(%s) tests in %s"
%
(
self
.
language
,
self
.
module
)
def
run
(
self
,
result
=
None
):
def
run
(
self
,
result
=
None
):
if
result
is
None
:
if
result
is
None
:
...
@@ -394,6 +405,12 @@ if __name__ == '__main__':
...
@@ -394,6 +405,12 @@ if __name__ == '__main__':
parser
.
add_option
(
"--no-cython"
,
dest
=
"with_cython"
,
parser
.
add_option
(
"--no-cython"
,
dest
=
"with_cython"
,
action
=
"store_false"
,
default
=
True
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the Cython compiler, only the C compiler"
)
help
=
"do not run the Cython compiler, only the C compiler"
)
parser
.
add_option
(
"--no-c"
,
dest
=
"use_c"
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not test C compilation"
)
parser
.
add_option
(
"--no-cpp"
,
dest
=
"use_cpp"
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not test C++ compilation"
)
parser
.
add_option
(
"--no-unit"
,
dest
=
"unittests"
,
parser
.
add_option
(
"--no-unit"
,
dest
=
"unittests"
,
action
=
"store_false"
,
default
=
True
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the unit tests"
)
help
=
"do not run the unit tests"
)
...
@@ -406,7 +423,7 @@ if __name__ == '__main__':
...
@@ -406,7 +423,7 @@ if __name__ == '__main__':
parser
.
add_option
(
"--no-pyregr"
,
dest
=
"pyregr"
,
parser
.
add_option
(
"--no-pyregr"
,
dest
=
"pyregr"
,
action
=
"store_false"
,
default
=
True
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the regression tests of CPython in tests/pyregr/"
)
help
=
"do not run the regression tests of CPython in tests/pyregr/"
)
parser
.
add_option
(
"--cython-only"
,
dest
=
"cythononly"
,
parser
.
add_option
(
"--cython-only"
,
dest
=
"cython
_
only"
,
action
=
"store_true"
,
default
=
False
,
action
=
"store_true"
,
default
=
False
,
help
=
"only compile pyx to c, do not run C compiler or run the tests"
)
help
=
"only compile pyx to c, do not run C compiler or run the tests"
)
parser
.
add_option
(
"--sys-pyregr"
,
dest
=
"system_pyregr"
,
parser
.
add_option
(
"--sys-pyregr"
,
dest
=
"system_pyregr"
,
...
@@ -482,6 +499,12 @@ if __name__ == '__main__':
...
@@ -482,6 +499,12 @@ if __name__ == '__main__':
if
options
.
exclude
:
if
options
.
exclude
:
exclude_selectors
+=
[
re
.
compile
(
r
,
re
.
I
|
re
.
U
).
search
for
r
in
options
.
exclude
]
exclude_selectors
+=
[
re
.
compile
(
r
,
re
.
I
|
re
.
U
).
search
for
r
in
options
.
exclude
]
languages
=
[]
if
options
.
use_c
:
languages
.
append
(
'c'
)
if
options
.
use_cpp
:
languages
.
append
(
'cpp'
)
test_suite
=
unittest
.
TestSuite
()
test_suite
=
unittest
.
TestSuite
()
if
options
.
unittests
:
if
options
.
unittests
:
...
@@ -490,18 +513,18 @@ if __name__ == '__main__':
...
@@ -490,18 +513,18 @@ if __name__ == '__main__':
if
options
.
doctests
:
if
options
.
doctests
:
collect_doctests
(
UNITTEST_ROOT
,
UNITTEST_MODULE
+
"."
,
test_suite
,
selectors
)
collect_doctests
(
UNITTEST_ROOT
,
UNITTEST_MODULE
+
"."
,
test_suite
,
selectors
)
if
options
.
filetests
:
if
options
.
filetests
and
languages
:
filetests
=
TestBuilder
(
ROOTDIR
,
WORKDIR
,
selectors
,
exclude_selectors
,
filetests
=
TestBuilder
(
ROOTDIR
,
WORKDIR
,
selectors
,
exclude_selectors
,
options
.
annotate_source
,
options
.
cleanup_workdir
,
options
.
annotate_source
,
options
.
cleanup_workdir
,
options
.
cleanup_sharedlibs
,
options
.
pyregr
,
options
.
cleanup_sharedlibs
,
options
.
pyregr
,
options
.
cython
only
)
options
.
cython
_only
,
languages
)
test_suite
.
addTest
(
filetests
.
build_suite
())
test_suite
.
addTest
(
filetests
.
build_suite
())
if
options
.
system_pyregr
:
if
options
.
system_pyregr
and
languages
:
filetests
=
TestBuilder
(
ROOTDIR
,
WORKDIR
,
selectors
,
exclude_selectors
,
filetests
=
TestBuilder
(
ROOTDIR
,
WORKDIR
,
selectors
,
exclude_selectors
,
options
.
annotate_source
,
options
.
cleanup_workdir
,
options
.
annotate_source
,
options
.
cleanup_workdir
,
options
.
cleanup_sharedlibs
,
True
,
options
.
cleanup_sharedlibs
,
True
,
options
.
cython
only
)
options
.
cython
_only
,
languages
)
test_suite
.
addTest
(
test_suite
.
addTest
(
filetests
.
handle_directory
(
filetests
.
handle_directory
(
os
.
path
.
join
(
sys
.
prefix
,
'lib'
,
'python'
+
sys
.
version
[:
3
],
'test'
),
os
.
path
.
join
(
sys
.
prefix
,
'lib'
,
'python'
+
sys
.
version
[:
3
],
'test'
),
...
...
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