From f0f211f383d08166bfe7978a6642ff41bb674d09 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Sun, 16 Oct 2022 15:30:17 +0200 Subject: [PATCH] coverage.py: only print dist, mode, variant and format for failed jobs if necessary --- coverage.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/coverage.py b/coverage.py index b6681d4..96c35b9 100755 --- a/coverage.py +++ b/coverage.py @@ -119,6 +119,19 @@ def parse_config(confname): return config_order, config_dict +def format_failed(num, total, name, dist, mode, variant, fmt, config_dict): + ret = f"({num}/{total}) {name}" + if len(config_dict[name].get("Dists", [])) > 0: + ret += f" --dist={dist}" + if len(config_dict[name].get("Modes", [])) > 0: + ret += f" --mode={mode}" + if len(config_dict[name].get("Variants", [])) > 0: + ret += f" --variant={variant}" + if len(config_dict[name].get("Formats", [])) > 0: + ret += f" --format={fmt}" + return ret + + def main(): parser = argparse.ArgumentParser() parser.add_argument("test", nargs="*", help="only run these tests") @@ -319,7 +332,9 @@ def main(): print(separator, file=sys.stderr) if proc.returncode != 0: failed.append( - ("(%d/%d) %s" % (i + 1, len(tests), name), dist, mode, variant, fmt) + format_failed( + i + 1, len(tests), name, dist, mode, variant, fmt, config_dict + ) ) print("result: FAILURE", file=sys.stderr) else: @@ -339,11 +354,8 @@ def main(): print(f" {t}", file=sys.stderr) if failed: print("failed %d:" % len(failed), file=sys.stderr) - for name, dist, mode, variant, fmt in failed: - print( - f" {name} --dist={dist} --mode={mode} --variant={variant} --format={fmt}", - file=sys.stderr, - ) + for f in failed: + print(f, file=sys.stderr) exit(1)