From f1ce78d77f178deb7a458235132d1fc8c44d0afe Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 18 Nov 2020 14:02:02 +0100 Subject: 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) --- mesonbuild/mlog.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mesonbuild/mlog.py') 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") -- cgit v1.1