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
cfaf3c73
Commit
cfaf3c73
authored
Apr 09, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testrunner.py: replace all prints with logging to stderr; do not assume that newline is \n
parent
b4e647b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
20 deletions
+39
-20
greentest/testrunner.py
greentest/testrunner.py
+39
-20
No files found.
greentest/testrunner.py
View file @
cfaf3c73
...
...
@@ -86,7 +86,7 @@ def store_record(database_path, table, dictionary, _added_colums_per_db={}):
try
:
cursor
.
execute
(
sql
,
dictionary
)
except
sqlite3
.
Error
:
print
(
'sql=%r
\
n
dictionary=%r'
%
(
sql
,
dictionary
)
)
log
(
'sql=%r
\
n
dictionary=%r'
,
sql
,
dictionary
)
raise
conn
.
commit
()
return
cursor
.
lastrowid
...
...
@@ -97,13 +97,13 @@ def delete_record(database_path, table, dictionary, _added_colums_per_db={}):
return
keys
=
dictionary
.
keys
()
conn
=
sqlite3
.
connect
(
database_path
)
print
(
'deleting %s from database'
%
(
dictionary
,
))
#
print ('deleting %s from database' % (dictionary, ))
sql
=
'delete from %s where %s'
%
(
table
,
' AND '
.
join
(
'%s=:%s'
%
(
key
,
key
)
for
key
in
keys
))
cursor
=
conn
.
cursor
()
try
:
cursor
.
execute
(
sql
,
dictionary
)
except
sqlite3
.
Error
:
print
(
'sql=%r
\
n
dictionary=%r'
%
(
sql
,
dictionary
)
)
log
(
'sql=%r
\
n
dictionary=%r'
,
sql
,
dictionary
)
raise
conn
.
commit
()
return
cursor
.
lastrowid
...
...
@@ -322,15 +322,15 @@ def spawn_subprocess(args, options, base_params):
else
:
if
not
output_printed
and
options
.
verbosity
>=
-
1
:
sys
.
stdout
.
write
(
output
)
print
(
'%s failed with code %s'
%
(
' '
.
join
(
args
),
retcode
)
)
log
(
'%s failed with code %s'
,
' '
.
join
(
args
),
retcode
)
elif
retcode
==
0
:
if
not
output_printed
and
options
.
verbosity
>=
1
:
sys
.
stdout
.
write
(
output
)
if
options
.
verbosity
>=
0
:
print
(
'%s passed'
%
' '
.
join
(
args
))
log
(
'%s passed'
,
' '
.
join
(
args
))
success
=
True
else
:
print
(
'%s timed out'
%
' '
.
join
(
args
))
log
(
'%s timed out'
,
' '
.
join
(
args
))
sys
.
stdout
.
flush
()
if
options
.
db
:
params
[
'output'
]
=
output
...
...
@@ -363,12 +363,12 @@ def spawn_subprocesses(options, args):
traceback
.
print_exc
()
if
options
.
db
:
try
:
print
(
'-'
*
80
)
log
(
'-'
*
80
)
if
print_stats
(
options
):
success
=
False
except
sqlite3
.
OperationalError
:
traceback
.
print_exc
()
print
(
'To view stats again for this run, use %s --stats --runid %s --db %s'
%
(
sys
.
argv
[
0
],
options
.
runid
,
options
.
db
)
)
log
(
'To view stats again for this run, use %s --stats --runid %s --db %s'
,
sys
.
argv
[
0
],
options
.
runid
,
options
.
db
)
if
not
success
:
sys
.
exit
(
1
)
...
...
@@ -409,6 +409,8 @@ def get_warnings(output):
return
_warning_re
.
findall
(
output
[:
OUTPUT_LIMIT
])
+
[
'AbridgedOutputWarning'
]
newline_re
=
re
.
compile
(
'[
\
r
\
n
]+'
)
def
get_exceptions
(
output
):
"""
>>> get_exceptions('''test$ python -c "1/0"
...
...
@@ -419,7 +421,7 @@ def get_exceptions(output):
"""
errors
=
[]
readtb
=
False
for
line
in
output
.
split
(
'
\
n
'
):
for
line
in
newline_re
.
split
(
output
):
if
'Traceback (most recent call last):'
in
line
:
readtb
=
True
else
:
...
...
@@ -500,14 +502,14 @@ def print_stats(options):
cursor
=
db
.
cursor
()
if
options
.
runid
is
None
:
options
.
runid
=
cursor
.
execute
(
'select runid from test order by started_at desc limit 1'
).
fetchall
()[
0
][
0
]
print
(
'Using the latest runid: %s'
%
options
.
runid
)
log
(
'Using the latest runid: %s'
,
options
.
runid
)
total
=
len
(
get_testcases
(
cursor
,
options
.
runid
))
failed
,
errors
=
get_failed_testcases
(
cursor
,
options
.
runid
)
timedout
=
get_testcases
(
cursor
,
options
.
runid
,
'TIMEOUT'
)
for
test
,
output
,
retcode
in
cursor
.
execute
(
'select test, output, retcode from test where runid=?'
,
(
options
.
runid
,
)):
info
,
skipped
=
get_info
(
output
or
''
,
test
)
if
info
:
print
(
'%s: %s'
%
(
test
,
info
)
)
log
(
'%s: %s'
,
test
,
info
)
if
retcode
==
'TIMEOUT'
:
for
testcase
in
timedout
:
if
testcase
.
startswith
(
test
+
'.'
):
...
...
@@ -525,18 +527,18 @@ def print_stats(options):
total
+=
1
if
failed
:
failed
.
sort
()
print
(
'FAILURES: '
)
log
(
'FAILURES: '
)
for
testcase
in
failed
:
error
=
errors
.
get
(
testcase
)
if
error
:
error
=
repr
(
error
)[
1
:
-
1
][:
100
]
print
(
' - %s: %s'
%
(
testcase
,
error
)
)
log
(
' - %s: %s'
,
testcase
,
error
)
else
:
print
(
' - %s'
%
(
testcase
,
)
)
log
(
' - %s'
,
testcase
)
if
timedout
:
print
(
'TIMEOUTS: '
)
print
(
' - '
+
'
\
n
- '
.
join
(
timedout
))
print
(
'%s testcases passed; %s failed; %s timed out'
%
(
total
,
len
(
failed
),
len
(
timedout
)
))
log
(
'TIMEOUTS: '
)
log
(
' - '
+
'
\
n
- '
.
join
(
timedout
))
log
(
'%s testcases passed; %s failed; %s timed out'
,
total
,
len
(
failed
),
len
(
timedout
))
if
failed
or
timedout
:
return
True
return
False
...
...
@@ -562,9 +564,9 @@ def main():
if
options
.
db
:
if
sqlite3
:
options
.
db
=
os
.
path
.
abspath
(
options
.
db
)
print
(
'Using the database: %s'
%
options
.
db
)
log
(
'Using the database: %s'
,
options
.
db
)
else
:
sys
.
stderr
.
write
(
'Cannot access the database %r: no sqlite3 module found.
\
n
'
%
(
options
.
db
,
)
)
log
(
'Cannot access the database %r: no sqlite3 module found.'
,
options
.
db
)
options
.
db
=
False
if
options
.
db
:
...
...
@@ -583,12 +585,29 @@ def main():
except
ImportError
:
import
random
options
.
runid
=
str
(
random
.
random
())[
2
:]
print
(
'Generated runid: %s'
%
(
options
.
runid
,
)
)
log
(
'Generated runid: %s'
,
options
.
runid
)
if
options
.
record
:
run_tests
(
options
,
args
)
else
:
spawn_subprocesses
(
options
,
args
)
def
log
(
message
,
*
args
):
try
:
string
=
message
%
args
except
Exception
:
traceback
.
print_exc
()
try
:
message
=
'%r %% %r
\
n
\
n
'
%
(
message
,
args
)
except
Exception
:
pass
try
:
sys
.
stderr
.
write
(
message
)
except
Exception
:
traceback
.
print_exc
()
else
:
sys
.
stderr
.
write
(
string
+
'
\
n
'
)
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