Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Kirill Smelkov
gevent
Commits
c0650562
Commit
c0650562
authored
Sep 26, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
re-use testrunner code in test___monkey_patching
parent
0203a083
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
37 deletions
+33
-37
greentest/test___monkey_patching.py
greentest/test___monkey_patching.py
+4
-21
greentest/testrunner.py
greentest/testrunner.py
+29
-16
No files found.
greentest/test___monkey_patching.py
View file @
c0650562
...
...
@@ -2,15 +2,14 @@ import sys
import
os
import
glob
import
util
import
gevent
TIMEOUT
=
120
directory
=
'%s.%s'
%
sys
.
version_info
[:
2
]
version
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
def
TESTRUNNER
(
tests
=
None
):
directory
=
'%s.%s'
%
sys
.
version_info
[:
2
]
version
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
preferred_version
=
open
(
os
.
path
.
join
(
directory
,
'version'
)).
read
().
strip
()
if
preferred_version
!=
version
:
util
.
log
(
'WARNING: The tests in %s/ are from version %s and your Python is %s'
,
directory
,
preferred_version
,
version
)
...
...
@@ -18,9 +17,6 @@ def TESTRUNNER(tests=None):
env
=
os
.
environ
.
copy
()
env
[
'PYTHONPATH'
]
=
os
.
getcwd
()
+
':'
+
os
.
environ
.
get
(
'PYTHONPATH'
,
''
)
for
filename
in
glob
.
glob
(
'%s/@test_*_tmp'
%
directory
):
os
.
unlink
(
filename
)
if
not
tests
:
tests
=
sorted
(
glob
.
glob
(
'%s/test_*.py'
%
directory
))
...
...
@@ -33,21 +29,8 @@ def TESTRUNNER(tests=None):
def
main
():
from
testrunner
import
pool
import
time
failed
=
[]
def
run
(
name
,
cmd
,
**
kwargs
):
if
util
.
run
(
cmd
,
**
kwargs
):
failed
.
append
(
name
)
start
=
time
.
time
()
total
=
0
for
name
,
cmd
,
options
in
TESTRUNNER
(
sys
.
argv
[
1
:]):
total
+=
1
pool
.
spawn
(
run
,
name
,
cmd
,
**
options
)
gevent
.
run
()
util
.
report
(
total
,
failed
,
took
=
time
.
time
()
-
start
)
import
testrunner
return
testrunner
.
run_many
(
TESTRUNNER
())
if
__name__
==
'__main__'
:
...
...
greentest/testrunner.py
View file @
c0650562
...
...
@@ -33,17 +33,13 @@ def spawn(*args, **kwargs):
return
g
def
main
(
):
def
run_many
(
tests
):
global
NWORKERS
,
pool
start
=
time
.
time
()
total
=
0
failed
=
{}
tests
=
sys
.
argv
[
1
:]
if
not
tests
:
tests
=
set
(
glob
.
glob
(
'test_*.py'
))
-
set
([
'test_support.py'
])
tests
=
sorted
(
tests
)
tests
=
list
(
tests
)
NWORKERS
=
min
(
len
(
tests
),
NWORKERS
)
pool
=
Pool
(
NWORKERS
)
util
.
BUFFER_OUTPUT
=
NWORKERS
>
1
...
...
@@ -61,17 +57,9 @@ def main():
try
:
try
:
for
filename
in
tests
:
for
name
,
cmd
,
options
in
tests
:
total
+=
1
if
'TESTRUNNER'
in
open
(
filename
).
read
():
module
=
__import__
(
filename
.
rsplit
(
'.'
,
1
)[
0
])
for
name
,
cmd
,
options
in
module
.
TESTRUNNER
():
total
+=
1
name
=
filename
+
' '
+
name
spawn
(
run_one
,
name
,
cmd
,
**
options
).
name
=
' '
.
join
(
cmd
)
else
:
cmd
=
[
sys
.
executable
,
'-u'
,
filename
]
spawn
(
run_one
,
filename
,
cmd
,
timeout
=
TIMEOUT
).
name
=
' '
.
join
(
cmd
)
spawn
(
run_one
,
name
,
cmd
,
**
options
).
name
=
' '
.
join
(
cmd
)
gevent
.
run
()
except
KeyboardInterrupt
:
try
:
...
...
@@ -103,6 +91,31 @@ def main():
util
.
log
(
'- '
+
'
\
n
- '
.
join
(
failed_then_succeeded
))
assert
not
pool
,
pool
os
.
system
(
'rm -f */@test*_tmp'
)
def
discover
(
tests
):
if
not
tests
:
tests
=
set
(
glob
.
glob
(
'test_*.py'
))
-
set
([
'test_support.py'
])
tests
=
sorted
(
tests
)
to_process
=
[]
default_options
=
{
'timeout'
:
TIMEOUT
}
for
filename
in
tests
:
if
'TESTRUNNER'
in
open
(
filename
).
read
():
module
=
__import__
(
filename
.
rsplit
(
'.'
,
1
)[
0
])
for
name
,
cmd
,
options
in
module
.
TESTRUNNER
():
to_process
.
append
((
filename
+
' '
+
name
,
cmd
,
options
))
else
:
to_process
.
append
((
filename
,
[
sys
.
executable
,
'-u'
,
filename
],
default_options
))
return
to_process
def
main
():
run_many
(
discover
(
sys
.
argv
[
1
:]))
if
__name__
==
'__main__'
:
main
()
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