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
d8e3b6c5
Commit
d8e3b6c5
authored
Apr 26, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Colorize testrunner output.
parent
3056db5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
5 deletions
+70
-5
src/greentest/greentest/testrunner.py
src/greentest/greentest/testrunner.py
+3
-3
src/greentest/greentest/util.py
src/greentest/greentest/util.py
+67
-2
No files found.
src/greentest/greentest/testrunner.py
View file @
d8e3b6c5
...
...
@@ -150,7 +150,7 @@ def run_many(tests, configured_failing_tests=(), failfast=False, quiet=False):
try
:
try
:
log
(
"Running tests in parallel with concurrency %s"
%
(
NWORKERS
,))
log
(
"Running tests in parallel with concurrency %s"
%
(
NWORKERS
,)
,
)
for
cmd
,
options
in
tests
:
total
+=
1
options
=
options
or
{}
...
...
@@ -297,7 +297,7 @@ def report(total, failed, passed, exit=True, took=None,
passed_unexpected
.
append
(
name
)
if
passed_unexpected
:
log
(
'
\
n
%s/%s unexpected passes'
,
len
(
passed_unexpected
),
total
)
log
(
'
\
n
%s/%s unexpected passes'
,
len
(
passed_unexpected
),
total
,
color
=
'error'
)
print_list
(
passed_unexpected
)
if
failed
:
...
...
@@ -314,7 +314,7 @@ def report(total, failed, passed, exit=True, took=None,
print_list
(
failed_expected
)
if
failed_unexpected
:
log
(
'
\
n
%s/%s unexpected failures'
,
len
(
failed_unexpected
),
total
)
log
(
'
\
n
%s/%s unexpected failures'
,
len
(
failed_unexpected
),
total
,
color
=
'error'
)
print_list
(
failed_unexpected
)
else
:
log
(
'
\
n
%s tests passed%s'
,
total
,
took
)
...
...
src/greentest/greentest/util.py
View file @
d8e3b6c5
...
...
@@ -24,7 +24,70 @@ class Popen(subprocess.Popen):
kill
(
self
)
def
log
(
message
,
*
args
):
# Coloring code based on zope.testrunner
# These colors are carefully chosen to have enough contrast
# on terminals with both black and white background.
_colorscheme
=
{
'normal'
:
'normal'
,
'default'
:
'default'
,
'info'
:
'normal'
,
'suboptimal-behaviour'
:
'magenta'
,
'error'
:
'brightred'
,
'number'
:
'green'
,
'slow-test'
:
'brightmagenta'
,
'ok-number'
:
'green'
,
'error-number'
:
'brightred'
,
'filename'
:
'lightblue'
,
'lineno'
:
'lightred'
,
'testname'
:
'lightcyan'
,
'failed-example'
:
'cyan'
,
'expected-output'
:
'green'
,
'actual-output'
:
'red'
,
'character-diffs'
:
'magenta'
,
'diff-chunk'
:
'magenta'
,
'exception'
:
'red'
,
'skipped'
:
'brightyellow'
,
}
_prefixes
=
[
(
'dark'
,
'0;'
),
(
'light'
,
'1;'
),
(
'bright'
,
'1;'
),
(
'bold'
,
'1;'
),
]
_colorcodes
=
{
'default'
:
0
,
'normal'
:
0
,
'black'
:
30
,
'red'
:
31
,
'green'
:
32
,
'brown'
:
33
,
'yellow'
:
33
,
'blue'
:
34
,
'magenta'
:
35
,
'cyan'
:
36
,
'grey'
:
37
,
'gray'
:
37
,
'white'
:
37
}
def
_color_code
(
color
):
prefix_code
=
''
for
prefix
,
code
in
_prefixes
:
if
color
.
startswith
(
prefix
):
color
=
color
[
len
(
prefix
):]
prefix_code
=
code
break
color_code
=
_colorcodes
[
color
]
return
'
\
033
[%s%sm'
%
(
prefix_code
,
color_code
)
def
_color
(
what
):
return
_color_code
(
_colorscheme
[
what
])
def
_colorize
(
what
,
message
,
normal
=
'normal'
):
return
_color
(
what
)
+
message
+
_color
(
normal
)
def
log
(
message
,
*
args
,
**
kwargs
):
color
=
kwargs
.
pop
(
'color'
,
'normal'
)
try
:
if
args
:
string
=
message
%
args
...
...
@@ -37,10 +100,12 @@ def log(message, *args):
except
Exception
:
pass
try
:
string
=
_colorize
(
'exception'
,
string
)
sys
.
stderr
.
write
(
string
)
except
Exception
:
traceback
.
print_exc
()
else
:
string
=
_colorize
(
color
,
string
)
sys
.
stderr
.
write
(
string
+
'
\
n
'
)
...
...
@@ -225,7 +290,7 @@ def run(command, **kwargs):
out
+=
'
\
n
'
log
(
'| %s
\
n
%s'
,
name
,
out
)
if
result
:
log
(
'! %s [code %s] [took %.1fs]'
,
name
,
result
,
took
)
log
(
'! %s [code %s] [took %.1fs]'
,
name
,
result
,
took
,
color
=
'error'
)
elif
not
nested
:
log
(
'- %s [took %.1fs]'
,
name
,
took
)
if
took
>=
MIN_RUNTIME
:
...
...
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