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
c57798fc
Commit
c57798fc
authored
Mar 26, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testrunner.py: split spawn_subprocesses in 2 functions
parent
aed40b50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
38 deletions
+50
-38
greentest/testrunner.py
greentest/testrunner.py
+50
-38
No files found.
greentest/testrunner.py
View file @
c57798fc
...
...
@@ -45,6 +45,7 @@ import sys
import
os
import
glob
import
re
import
traceback
from
unittest
import
_TextTestResult
,
defaultTestLoader
,
TextTestRunner
import
platform
...
...
@@ -273,56 +274,67 @@ def run_subprocess(arg, options):
return
retcode
[
0
],
output
def
spawn_subprocess
(
arg
,
options
):
success
=
False
if
options
.
db
:
module_name
=
arg
if
module_name
.
endswith
(
'.py'
):
module_name
=
module_name
[:
-
3
]
from
datetime
import
datetime
params
=
{
'started_at'
:
datetime
.
now
(),
'runid'
:
options
.
runid
,
'test'
:
module_name
,
'python'
:
'%s.%s.%s'
%
sys
.
version_info
[:
3
],
'changeset'
:
get_changeset
(),
'libevent_version'
:
get_libevent_version
(),
'libevent_method'
:
get_libevent_method
(),
'uname'
:
options
.
uname
,
'retcode'
:
'TIMEOUT'
}
row_id
=
store_record
(
options
.
db
,
'test'
,
params
)
params
[
'id'
]
=
row_id
retcode
,
output
=
run_subprocess
(
arg
,
options
)
if
len
(
output
)
>
OUTPUT_LIMIT
:
output
=
output
[:
OUTPUT_LIMIT
]
+
'<AbridgedOutputWarning>'
if
retcode
:
sys
.
stdout
.
write
(
output
)
print
'%s failed with code %s'
%
(
arg
,
retcode
)
elif
retcode
==
0
:
if
options
.
verbosity
==
1
:
# // if verbosity is 2 then output is always printed by run_subprocess
sys
.
stdout
.
write
(
output
)
print
'%s passed'
%
arg
success
=
True
else
:
print
'%s timed out'
%
arg
if
options
.
db
:
params
[
'output'
]
=
output
params
[
'retcode'
]
=
retcode
store_record
(
options
.
db
,
'test'
,
params
)
return
success
def
spawn_subprocesses
(
options
,
args
):
success
=
True
if
not
args
:
args
=
glob
.
glob
(
'test_*.py'
)
args
.
remove
(
'test_support.py'
)
fail
=
False
uname
=
platform
.
uname
()[
0
]
options
.
uname
=
platform
.
uname
()[
0
]
for
arg
in
args
:
if
options
.
db
:
module_name
=
arg
if
module_name
.
endswith
(
'.py'
):
module_name
=
module_name
[:
-
3
]
from
datetime
import
datetime
params
=
{
'started_at'
:
datetime
.
now
(),
'runid'
:
options
.
runid
,
'test'
:
module_name
,
'python'
:
'%s.%s.%s'
%
sys
.
version_info
[:
3
],
'changeset'
:
get_changeset
(),
'libevent_version'
:
get_libevent_version
(),
'libevent_method'
:
get_libevent_method
(),
'uname'
:
uname
,
'retcode'
:
'TIMEOUT'
}
row_id
=
store_record
(
options
.
db
,
'test'
,
params
)
params
[
'id'
]
=
row_id
retcode
,
output
=
run_subprocess
(
arg
,
options
)
if
len
(
output
)
>
OUTPUT_LIMIT
:
output
=
output
[:
OUTPUT_LIMIT
]
+
'<AbridgedOutputWarning>'
if
retcode
:
sys
.
stdout
.
write
(
output
)
print
'%s failed with code %s'
%
(
arg
,
retcode
)
fail
=
True
elif
retcode
==
0
:
if
options
.
verbosity
==
1
:
# // if verbosity is 2 then output is always printed by run_subprocess
sys
.
stdout
.
write
(
output
)
print
'%s passed'
%
arg
else
:
print
'%s timed out'
%
arg
fail
=
True
if
options
.
db
:
params
[
'output'
]
=
output
params
[
'retcode'
]
=
retcode
store_record
(
options
.
db
,
'test'
,
params
)
try
:
success
=
spawn_subprocess
(
arg
,
options
)
and
success
except
Exception
:
try
:
traceback
.
print_exc
()
except
Exception
:
pass
if
options
.
db
:
try
:
print
'-'
*
80
if
print_stats
(
options
):
fail
=
Tru
e
success
=
Fals
e
except
sqlite3
.
OperationalError
,
ex
:
print
ex
print
'To view stats again for this run, use %s --stats --runid %s --db %s'
%
(
sys
.
argv
[
0
],
options
.
runid
,
options
.
db
)
if
fail
:
if
not
success
:
sys
.
exit
(
1
)
...
...
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