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
e8ae53c9
Commit
e8ae53c9
authored
Jul 10, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support running CPython unit tests in tests/pyregr/ from runtests.py
parent
f952904c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
8 deletions
+42
-8
runtests.py
runtests.py
+42
-8
No files found.
runtests.py
View file @
e8ae53c9
...
@@ -9,8 +9,8 @@ from distutils.core import Extension
...
@@ -9,8 +9,8 @@ from distutils.core import Extension
from
distutils.command.build_ext
import
build_ext
from
distutils.command.build_ext
import
build_ext
distutils_distro
=
Distribution
()
distutils_distro
=
Distribution
()
TEST_DIRS
=
[
'compile'
,
'errors'
,
'run'
]
TEST_DIRS
=
[
'compile'
,
'errors'
,
'run'
,
'pyregr'
]
TEST_RUN_DIRS
=
[
'run'
]
TEST_RUN_DIRS
=
[
'run'
,
'pyregr'
]
INCLUDE_DIRS
=
[
d
for
d
in
os
.
getenv
(
'INCLUDE'
,
''
).
split
(
os
.
pathsep
)
if
d
]
INCLUDE_DIRS
=
[
d
for
d
in
os
.
getenv
(
'INCLUDE'
,
''
).
split
(
os
.
pathsep
)
if
d
]
CFLAGS
=
os
.
getenv
(
'CFLAGS'
,
''
).
split
()
CFLAGS
=
os
.
getenv
(
'CFLAGS'
,
''
).
split
()
...
@@ -78,15 +78,19 @@ class TestBuilder(object):
...
@@ -78,15 +78,19 @@ class TestBuilder(object):
filenames
=
os
.
listdir
(
path
)
filenames
=
os
.
listdir
(
path
)
filenames
.
sort
()
filenames
.
sort
()
for
filename
in
filenames
:
for
filename
in
filenames
:
if
not
filename
.
endswith
(
".pyx"
):
if
not
(
filename
.
endswith
(
".pyx"
)
or
filename
.
endswith
(
".py"
)
):
continue
continue
module
=
filename
[:
-
4
]
module
=
os
.
path
.
splitext
(
filename
)[
0
]
fqmodule
=
"%s.%s"
%
(
context
,
module
)
fqmodule
=
"%s.%s"
%
(
context
,
module
)
if
not
[
1
for
match
in
self
.
selectors
if
not
[
1
for
match
in
self
.
selectors
if
match
(
fqmodule
)
]:
if
match
(
fqmodule
)
]:
continue
continue
if
context
in
TEST_RUN_DIRS
:
if
context
in
TEST_RUN_DIRS
:
test
=
CythonRunTestCase
(
if
module
.
startswith
(
"test_"
):
build_test
=
CythonUnitTestCase
else
:
build_test
=
CythonRunTestCase
test
=
build_test
(
path
,
workdir
,
module
,
path
,
workdir
,
module
,
annotate
=
self
.
annotate
,
annotate
=
self
.
annotate
,
cleanup_workdir
=
self
.
cleanup_workdir
)
cleanup_workdir
=
self
.
cleanup_workdir
)
...
@@ -133,11 +137,21 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -133,11 +137,21 @@ class CythonCompileTestCase(unittest.TestCase):
os
.
makedirs
(
self
.
workdir
)
os
.
makedirs
(
self
.
workdir
)
def
runTest
(
self
):
def
runTest
(
self
):
self
.
runCompileTest
()
def
runCompileTest
(
self
):
self
.
compile
(
self
.
directory
,
self
.
module
,
self
.
workdir
,
self
.
compile
(
self
.
directory
,
self
.
module
,
self
.
workdir
,
self
.
directory
,
self
.
expect_errors
,
self
.
annotate
)
self
.
directory
,
self
.
expect_errors
,
self
.
annotate
)
def
find_module_source_file
(
self
,
source_file
):
if
not
os
.
path
.
exists
(
source_file
):
source_file
=
source_file
[:
-
1
]
return
source_file
def
split_source_and_output
(
self
,
directory
,
module
,
workdir
):
def
split_source_and_output
(
self
,
directory
,
module
,
workdir
):
source_and_output
=
open
(
os
.
path
.
join
(
directory
,
module
+
'.pyx'
),
'rU'
)
source_file
=
os
.
path
.
join
(
directory
,
module
)
source_and_output
=
open
(
self
.
find_module_source_file
(
source_file
),
'rU'
)
out
=
open
(
os
.
path
.
join
(
workdir
,
module
+
'.pyx'
),
'w'
)
out
=
open
(
os
.
path
.
join
(
workdir
,
module
+
'.pyx'
),
'w'
)
for
line
in
source_and_output
:
for
line
in
source_and_output
:
last_line
=
line
last_line
=
line
...
@@ -157,7 +171,8 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -157,7 +171,8 @@ class CythonCompileTestCase(unittest.TestCase):
include_dirs
=
INCLUDE_DIRS
[:]
include_dirs
=
INCLUDE_DIRS
[:]
if
incdir
:
if
incdir
:
include_dirs
.
append
(
incdir
)
include_dirs
.
append
(
incdir
)
source
=
os
.
path
.
join
(
directory
,
module
+
'.pyx'
)
source
=
self
.
find_module_source_file
(
os
.
path
.
join
(
directory
,
module
+
'.pyx'
))
target
=
os
.
path
.
join
(
targetdir
,
module
+
'.c'
)
target
=
os
.
path
.
join
(
targetdir
,
module
+
'.c'
)
options
=
CompilationOptions
(
options
=
CompilationOptions
(
pyrex_default_options
,
pyrex_default_options
,
...
@@ -228,7 +243,7 @@ class CythonRunTestCase(CythonCompileTestCase):
...
@@ -228,7 +243,7 @@ class CythonRunTestCase(CythonCompileTestCase):
result
=
self
.
defaultTestResult
()
result
=
self
.
defaultTestResult
()
result
.
startTest
(
self
)
result
.
startTest
(
self
)
try
:
try
:
self
.
runTest
()
self
.
run
Compile
Test
()
doctest
.
DocTestSuite
(
self
.
module
).
run
(
result
)
doctest
.
DocTestSuite
(
self
.
module
).
run
(
result
)
except
Exception
:
except
Exception
:
result
.
addError
(
self
,
sys
.
exc_info
())
result
.
addError
(
self
,
sys
.
exc_info
())
...
@@ -238,6 +253,25 @@ class CythonRunTestCase(CythonCompileTestCase):
...
@@ -238,6 +253,25 @@ class CythonRunTestCase(CythonCompileTestCase):
except
Exception
:
except
Exception
:
pass
pass
class
CythonUnitTestCase
(
CythonCompileTestCase
):
def
shortDescription
(
self
):
return
"compiling and running unit tests in "
+
self
.
module
def
run
(
self
,
result
=
None
):
if
result
is
None
:
result
=
self
.
defaultTestResult
()
result
.
startTest
(
self
)
try
:
self
.
runCompileTest
()
unittest
.
loadTestsFromName
(
self
.
module
).
run
(
result
)
except
Exception
:
result
.
addError
(
self
,
sys
.
exc_info
())
result
.
stopTest
(
self
)
try
:
self
.
tearDown
()
except
Exception
:
pass
def
collect_unittests
(
path
,
suite
,
selectors
):
def
collect_unittests
(
path
,
suite
,
selectors
):
def
file_matches
(
filename
):
def
file_matches
(
filename
):
return
filename
.
startswith
(
"Test"
)
and
filename
.
endswith
(
".py"
)
return
filename
.
startswith
(
"Test"
)
and
filename
.
endswith
(
".py"
)
...
...
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