Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
uwdkn
mjtest
Commits
ea7827ba
Commit
ea7827ba
authored
Nov 19, 2016
by
Johannes Bechberger
Browse files
Add `--no_color` option for uncolored output
parent
3a47e3cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.mdwn
View file @
ea7827ba
...
...
@@ -127,7 +127,7 @@ Output of the `./mjt.py --help`
```
usage: mjt.py [-h] [--only_incorrect_tests] [--produce_no_reports]
[--produce_all_reports] [--parallel]
[--output_no_incorrect_reports] [--ci_testing]
[--output_no_incorrect_reports]
[--no_color]
[--ci_testing]
[--log_level LOG_LEVEL]
{all,lexer,syntax,ast,semantic,exec} MJ_RUN
...
...
@@ -151,6 +151,7 @@ optional arguments:
--parallel Run the tests in parallel
--output_no_incorrect_reports
Output the long report for every incorrect test case
--no_color Output no color codes
--ci_testing In mode X the succeeding test cases of later
modes/phases should also succeed in this mode, and
failing test cases of prior modes/phases should also
...
...
mjtest/cli.py
View file @
ea7827ba
...
...
@@ -48,6 +48,8 @@ if True:#__name__ == '__main__':
help
=
"Run the tests in parallel"
)
parser
.
add_argument
(
"--output_no_incorrect_reports"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Output the long report for every incorrect test case"
)
parser
.
add_argument
(
"--no_color"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Output no color codes"
)
parser
.
add_argument
(
"--ci_testing"
,
action
=
"store_true"
,
default
=
False
,
help
=
"In mode X the succeeding test cases of later modes/phases should also succeed in "
"this mode, and failing test cases of prior modes/phases should also fail in this phase."
)
...
...
mjtest/environment.py
View file @
ea7827ba
...
...
@@ -6,7 +6,8 @@ import tempfile
from
datetime
import
datetime
import
time
from
mjtest.util.shell
import
execute
from
mjtest.util.utils
import
get_mjtest_basedir
from
mjtest.util.utils
import
get_mjtest_basedir
,
disable_colored_output
import
mjtest.util.utils
from
typing
import
Tuple
,
List
from
preproc.preproc.preprocessor
import
PreProcessor
,
PreProcessorError
,
is_importable_file
...
...
@@ -45,7 +46,9 @@ class Environment:
timeout
:
int
=
30
,
report_dir
:
str
=
""
,
log_level
:
str
=
"warn"
,
produce_no_reports
:
bool
=
True
,
output_no_incorrect_reports
:
bool
=
False
,
produce_all_reports
:
bool
=
False
,
report_subdir
:
str
=
None
,
ci_testing
:
bool
=
False
):
ci_testing
:
bool
=
False
,
no_color
:
bool
=
False
):
if
no_color
:
disable_colored_output
()
self
.
mode
=
mode
self
.
mj_run_cmd
=
os
.
path
.
realpath
(
mj_run
)
...
...
mjtest/util/utils.py
View file @
ea7827ba
...
...
@@ -3,6 +3,18 @@ from os import path
import
sys
from
typing
import
Tuple
COLOR_OUTPUT_IF_POSSIBLE
=
True
try
:
import
termcolor
except
ImportError
:
COLOR_OUTPUT_IF_POSSIBLE
=
False
def
disable_colored_output
():
global
COLOR_OUTPUT_IF_POSSIBLE
COLOR_OUTPUT_IF_POSSIBLE
=
False
def
get_mjtest_basedir
()
->
str
:
return
path
.
dirname
(
path
.
dirname
(
path
.
dirname
(
path
.
realpath
(
__file__
))))
...
...
@@ -12,10 +24,10 @@ def colored(text: str, *args, **kwargs):
"""
Wrapper around termcolor.colored (if it's loadable)
"""
try
:
from
termcolor
import
colored
return
colored
(
text
,
*
args
,
**
kwargs
)
e
xcept
ImportError
:
global
COLOR_OUTPUT_IF_POSSIBLE
if
COLOR_OUTPUT_IF_POSSIBLE
:
return
termcolor
.
colored
(
text
,
*
args
,
**
kwargs
)
e
lse
:
return
text
...
...
@@ -23,8 +35,8 @@ def cprint(text: str, *args, **kwargs):
"""
Wrapper around termcolor.cprint (if it's loadable)
"""
try
:
from
termcolor
import
cprint
cprint
(
text
,
*
args
,
**
kwargs
)
e
xcept
ImportError
:
global
COLOR_OUTPUT_IF_POSSIBLE
if
COLOR_OUTPUT_IF_POSSIBLE
:
termcolor
.
cprint
(
text
,
*
args
,
**
kwargs
)
e
lse
:
print
(
text
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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