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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
bfe3c0a8
Commit
bfe3c0a8
authored
Sep 12, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests of an entire source tree build invocation.
parent
2cde741b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
7 deletions
+53
-7
Cython/TestUtils.py
Cython/TestUtils.py
+8
-6
runtests.py
runtests.py
+45
-1
No files found.
Cython/TestUtils.py
View file @
bfe3c0a8
...
@@ -168,18 +168,20 @@ class TreeAssertVisitor(VisitorTransform):
...
@@ -168,18 +168,20 @@ class TreeAssertVisitor(VisitorTransform):
visit_Node
=
VisitorTransform
.
recurse_to_children
visit_Node
=
VisitorTransform
.
recurse_to_children
def
unpack_source_tree
(
tree_file
):
def
unpack_source_tree
(
tree_file
,
dir
=
None
):
if
dir
is
None
:
dir
=
tempfile
.
mkdtemp
()
dir
=
tempfile
.
mkdtemp
()
header
=
[]
cur_file
=
None
cur_file
=
None
for
line
in
open
(
tree_file
).
readlines
():
for
line
in
open
(
tree_file
).
readlines
():
if
line
[:
5
]
==
'#####'
:
if
line
[:
5
]
==
'#####'
:
filename
=
line
.
strip
().
strip
(
'#'
).
strip
()
filename
=
line
.
strip
().
strip
(
'#'
).
strip
()
.
replace
(
'/'
,
os
.
path
.
sep
)
path
=
os
.
path
.
join
(
dir
,
filename
)
path
=
os
.
path
.
join
(
dir
,
filename
)
print
os
.
path
.
dirname
(
path
)
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
path
)):
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
path
)):
print
" ...creating"
os
.
makedirs
(
os
.
path
.
dirname
(
path
))
os
.
makedirs
(
os
.
path
.
dirname
(
path
))
cur_file
=
open
(
path
,
'w'
)
cur_file
=
open
(
path
,
'w'
)
elif
cur_file
is
not
None
:
elif
cur_file
is
not
None
:
cur_file
.
write
(
line
)
cur_file
.
write
(
line
)
return
dir
else
:
header
.
append
(
line
)
return
dir
,
''
.
join
(
header
)
runtests.py
View file @
bfe3c0a8
...
@@ -28,7 +28,7 @@ from distutils.core import Extension
...
@@ -28,7 +28,7 @@ from distutils.core import Extension
from
distutils.command.build_ext
import
build_ext
as
_build_ext
from
distutils.command.build_ext
import
build_ext
as
_build_ext
distutils_distro
=
Distribution
()
distutils_distro
=
Distribution
()
TEST_DIRS
=
[
'compile'
,
'errors'
,
'run'
,
'wrappers'
,
'pyregr'
]
TEST_DIRS
=
[
'compile'
,
'errors'
,
'run'
,
'wrappers'
,
'pyregr'
,
'build'
]
TEST_RUN_DIRS
=
[
'run'
,
'wrappers'
,
'pyregr'
]
TEST_RUN_DIRS
=
[
'run'
,
'wrappers'
,
'pyregr'
]
# Lists external modules, and a matcher matching tests
# Lists external modules, and a matcher matching tests
...
@@ -162,6 +162,9 @@ class TestBuilder(object):
...
@@ -162,6 +162,9 @@ class TestBuilder(object):
filenames
=
os
.
listdir
(
path
)
filenames
=
os
.
listdir
(
path
)
filenames
.
sort
()
filenames
.
sort
()
for
filename
in
filenames
:
for
filename
in
filenames
:
if
context
==
"build"
and
filename
.
endswith
(
".srctree"
):
suite
.
addTest
(
EndToEndTest
(
filename
,
workdir
,
self
.
cleanup_workdir
))
continue
if
not
(
filename
.
endswith
(
".pyx"
)
or
filename
.
endswith
(
".py"
)):
if
not
(
filename
.
endswith
(
".pyx"
)
or
filename
.
endswith
(
".py"
)):
continue
continue
if
filename
.
startswith
(
'.'
):
continue
# certain emacs backup files
if
filename
.
startswith
(
'.'
):
continue
# certain emacs backup files
...
@@ -623,6 +626,47 @@ def collect_doctests(path, module_prefix, suite, selectors):
...
@@ -623,6 +626,47 @@ def collect_doctests(path, module_prefix, suite, selectors):
except
ValueError
:
# no tests
except
ValueError
:
# no tests
pass
pass
class
EndToEndTest
(
unittest
.
TestCase
):
"""
This is a test of build/*.srctree files, where srctree defines a full
directory structure and its header gives a list of commands to run.
"""
def
__init__
(
self
,
treefile
,
workdir
,
cleanup_workdir
=
True
):
self
.
treefile
=
treefile
self
.
workdir
=
os
.
path
.
join
(
workdir
,
os
.
path
.
splitext
(
treefile
)[
0
])
self
.
cleanup_workdir
=
cleanup_workdir
unittest
.
TestCase
.
__init__
(
self
)
def
shortDescription
(
self
):
return
"End-to-end %s"
%
self
.
treefile
def
setUp
(
self
):
from
Cython.TestUtils
import
unpack_source_tree
_
,
self
.
commands
=
unpack_source_tree
(
os
.
path
.
join
(
'tests'
,
'build'
,
self
.
treefile
),
self
.
workdir
)
self
.
old_dir
=
os
.
getcwd
()
if
not
os
.
path
.
exists
(
self
.
workdir
):
os
.
makedirs
(
self
.
workdir
)
os
.
chdir
(
self
.
workdir
)
if
self
.
workdir
not
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
self
.
workdir
)
def
tearDown
(
self
):
try
:
sys
.
path
.
remove
(
self
.
workdir
)
except
ValueError
:
pass
if
self
.
cleanup_workdir
:
shutil
.
rmtree
(
self
.
workdir
)
os
.
chdir
(
self
.
old_dir
)
def
runTest
(
self
):
commands
=
(
self
.
commands
.
replace
(
"CYTHON"
,
"PYTHON %s"
%
os
.
path
.
join
(
self
.
old_dir
,
'cython.py'
))
.
replace
(
"PYTHON"
,
sys
.
executable
))
self
.
assertEqual
(
0
,
os
.
system
(
commands
))
# TODO: Support cython_freeze needed here as well.
# TODO: Support cython_freeze needed here as well.
# TODO: Windows support.
# TODO: Windows support.
...
...
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