Skip to content

Commit

Permalink
Disable the use of ANSI sequences in logging when --nocolor is passed
Browse files Browse the repository at this point in the history
--nocolor is an existing option defined in e3.main. e3-testsuite has
heuristics in order to detect if it is safe to use ANSI sequences in
logging in order to colorize the output in the console, but --nocolor
should have precedence over these heuristics.

No testcase added as tests run without TTYs, and so colors are always
disabled there.

For #113
  • Loading branch information
pmderodat committed Dec 1, 2022
1 parent 5082ea4 commit 1757087
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
26.0 (Not released yet)
=======================

* Disable the use of ANSI sequences in logging when `--nocolor` is passed.
* Make `DiffTestDriver` perform a full match for regexp baselines.
* Fix memory leaks for test driver data.
* Include total testsuite and testcase durations in XUnit reports.
Expand Down
5 changes: 5 additions & 0 deletions src/e3/testsuite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ def testsuite_main(self, args: Optional[List[str]] = None) -> int:
else: # interactive-only
enable_colors = True
self.main.args.show_error_output = True

# If explicitly requested, disable colors
if self.main.args.nocolor:
enable_colors = False

self.colors = ColorConfig(enable_colors)
self.Fore = self.colors.Fore
self.Style = self.colors.Style
Expand Down

0 comments on commit 1757087

Please sign in to comment.