aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-11-18 14:02:02 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2020-11-18 22:49:41 +0200
commitf1ce78d77f178deb7a458235132d1fc8c44d0afe (patch)
treea3cbc63e3483df2adf0576b0ca62ef8d2f669319 /mesonbuild
parentc8af3c8d29df9535b76ce62a8aafdbb0bc9cc10f (diff)
downloadmeson-f1ce78d77f178deb7a458235132d1fc8c44d0afe.zip
meson-f1ce78d77f178deb7a458235132d1fc8c44d0afe.tar.gz
meson-f1ce78d77f178deb7a458235132d1fc8c44d0afe.tar.bz2
mtest: cleanup and fix print_stats
Avoid calling self.collected_failures.append twice, and avoid inflated indentation by adding a "plain" decorator to mlog. Fixes: ba71fde18 ("mtest: collect failures regardless of colorized console", 2020-10-12)
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mlog.py5
-rw-r--r--mesonbuild/mtest.py21
2 files changed, 12 insertions, 14 deletions
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index eefb308..46e2de1 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -124,7 +124,7 @@ class AnsiDecorator:
def get_text(self, with_codes: bool) -> str:
text = self.text
- if with_codes:
+ if with_codes and self.code:
text = self.code + self.text + AnsiDecorator.plain_code
if self.quoted:
text = '"{}"'.format(text)
@@ -133,6 +133,9 @@ class AnsiDecorator:
def bold(text: str, quoted: bool = False) -> AnsiDecorator:
return AnsiDecorator(text, "\033[1m", quoted=quoted)
+def plain(text: str) -> AnsiDecorator:
+ return AnsiDecorator(text, "")
+
def red(text: str) -> AnsiDecorator:
return AnsiDecorator(text, "\033[1;31m")
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 35cb10a..e538992 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -918,20 +918,15 @@ class TestHarness:
dur=result.duration)
if result.res is TestResult.FAIL:
result_str += ' ' + returncode_to_status(result.returncode)
+ if result.res in bad_statuses:
+ self.collected_failures.append(result_str)
if not self.options.quiet or result.res not in ok_statuses:
- if result.res not in ok_statuses:
- self.collected_failures.append(result_str)
- if mlog.colorize_console():
- if result.res in bad_statuses:
- self.collected_failures.append(result_str)
- decorator = mlog.red
- elif result.res is TestResult.SKIP:
- decorator = mlog.yellow
- else:
- sys.exit('Unreachable code was ... well ... reached.')
- print(decorator(result_str).get_text(True))
- else:
- print(result_str)
+ decorator = mlog.plain
+ if result.res in bad_statuses:
+ decorator = mlog.red
+ elif result.res is TestResult.SKIP:
+ decorator = mlog.yellow
+ print(decorator(result_str).get_text(mlog.colorize_console()))
result_str += "\n\n" + result.get_log()
if result.res in bad_statuses:
if self.options.print_errorlogs: