From 11c1491e5abb7860adac889ff0725353dc9c8b38 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 15 Mar 2020 16:43:06 -0700 Subject: [PATCH] Import latest littlecheck Commit b2f40783a2b5b0663409c4daa90b794b02dd37a6 This has better progress reporting, and the exit status of littlecheck indicates how many test failures there were. --- build_tools/littlecheck.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/build_tools/littlecheck.py b/build_tools/littlecheck.py index ef36c111e..a9c080689 100755 --- a/build_tools/littlecheck.py +++ b/build_tools/littlecheck.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals from __future__ import print_function import argparse +import datetime import io import re import shlex @@ -182,10 +183,7 @@ class TestFailure(object): ] if self.after: fields["additional_output"] = " ".join(self.after[:afterlines]) - fmtstrs += [ - " additional output:", - " {BOLD}{additional_output}{RESET}", - ] + fmtstrs += [" additional output:", " {BOLD}{additional_output}{RESET}"] fmtstrs += [" when running command:", " {subbed_command}"] return "\n".join(fmtstrs).format(**fields) @@ -470,7 +468,7 @@ def main(): def_subs = {"%": "%"} def_subs.update(parse_subs(args.substitute)) - success = True + failure_count = 0 config = Config() config.colorize = sys.stdout.isatty() config.progress = args.progress @@ -480,13 +478,21 @@ def main(): fields["path"] = path if config.progress: print("Testing file {path} ... ".format(**fields), end="") + sys.stdout.flush() subs = def_subs.copy() subs["s"] = path + starttime = datetime.datetime.now() if not check_path(path, subs, config, TestFailure.print_message): - success = False + failure_count += 1 elif config.progress: - print("{GREEN}ok{RESET}".format(**fields)) - sys.exit(0 if success else 1) + endtime = datetime.datetime.now() + duration_ms = round((endtime - starttime).total_seconds() * 1000) + print( + "{GREEN}ok{RESET} ({duration} ms)".format( + duration=duration_ms, **fields + ) + ) + sys.exit(failure_count) if __name__ == "__main__":