From 291dab81c2ec3aa199760a03c00aa48e97d7a2e5 Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Fri, 6 Feb 2026 14:23:47 -0500 Subject: [PATCH 1/4] wip --- test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test.py b/test.py index 01f1026..d81c37b 100644 --- a/test.py +++ b/test.py @@ -89,6 +89,7 @@ def slurp(file): Test = namedtuple("Test", ["file", "specs"]) TestCtx = namedtuple("TestCtx", ["files", "specs", "tests"]) +TestCov = namedtuple("TestCov", ["all", "completed", "missing"]) def index(dir): ctx = TestCtx([], {}, []) @@ -114,7 +115,7 @@ def cov_tasks(states): for _, task in sp["tasks"].items(): if task["state"] == 64: yield id, task["task_spec"] - + def do_cov(specs, states): all = {} completed = {} @@ -130,7 +131,7 @@ def do_cov(specs, states): all[id] = set([t for t in spec["task_specs"]]) missing[id] = all[id] - completed[id] - return { "all": all, "completed": completed, "missing": missing } + return TestCov(all, completed, missing) ### @@ -155,11 +156,10 @@ def do_cov(specs, states): all = 0 completed = 0 for id, f in ctx.files: - c = len(cov["completed"][id]) - a = len(cov["all"][id]) + c = len(cov.completed[id]) + a = len(cov.all[id]) completed += c all += a print(f"{f} - {c}/{a} - {(c/a * 100):.2f}%") print(f"\nTotal - {completed}/{all} - {(completed/all * 100):.2f}%") - From 6fc2dc6a45be8d1830faafce76b55f10eb9a7095 Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Fri, 6 Feb 2026 14:41:00 -0500 Subject: [PATCH 2/4] wip --- test.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/test.py b/test.py index d81c37b..902211f 100644 --- a/test.py +++ b/test.py @@ -90,6 +90,8 @@ def slurp(file): Test = namedtuple("Test", ["file", "specs"]) TestCtx = namedtuple("TestCtx", ["files", "specs", "tests"]) TestCov = namedtuple("TestCov", ["all", "completed", "missing"]) +Tally = namedtuple("Tally", ["c", "a", "p"]) +CovTally = namedtuple("CovTally", ["result", "breakdown"]) def index(dir): ctx = TestCtx([], {}, []) @@ -132,7 +134,20 @@ def do_cov(specs, states): missing[id] = all[id] - completed[id] return TestCov(all, completed, missing) - + +def tally(cov): + completed = 0 + all = 0 + breakdown = {} + for id in cov.all: + c = len(cov.completed[id]) + a = len(cov.all[id]) + breakdown[id] = Tally(c, a, c / a * 100) + completed += c + all += a + result = Tally(completed, all, completed / all * 100) + return CovTally(result, breakdown) + ### if __name__ == "__main__": @@ -152,14 +167,10 @@ def do_cov(specs, states): print("Unit Test Task Coverage:\n") - cov = do_cov(ctx.specs, [t.state for t in test_cases]) - all = 0 - completed = 0 + cov = tally(do_cov(ctx.specs, [t.state for t in test_cases])) for id, f in ctx.files: - c = len(cov.completed[id]) - a = len(cov.all[id]) - completed += c - all += a - print(f"{f} - {c}/{a} - {(c/a * 100):.2f}%") + [c, a, p] = cov.breakdown[id] + print(f"{f} - {c}/{a} - {p:.2f}%") - print(f"\nTotal - {completed}/{all} - {(completed/all * 100):.2f}%") + [c, a, p] = cov.result + print(f"\nTotal - {c}/{a} - {p:.2f}%") From b137b08e3263e3d55729743223e8347ff550c5f3 Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Fri, 6 Feb 2026 14:51:19 -0500 Subject: [PATCH 3/4] wip --- test.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/test.py b/test.py index 902211f..d354603 100644 --- a/test.py +++ b/test.py @@ -90,7 +90,7 @@ def slurp(file): Test = namedtuple("Test", ["file", "specs"]) TestCtx = namedtuple("TestCtx", ["files", "specs", "tests"]) TestCov = namedtuple("TestCov", ["all", "completed", "missing"]) -Tally = namedtuple("Tally", ["c", "a", "p"]) +Tally = namedtuple("Tally", ["completed", "all", "percent"]) CovTally = namedtuple("CovTally", ["result", "breakdown"]) def index(dir): @@ -118,7 +118,20 @@ def cov_tasks(states): if task["state"] == 64: yield id, task["task_spec"] -def do_cov(specs, states): +def tally(cov): + completed = 0 + all = 0 + breakdown = {} + for id in cov.all: + c = len(cov.completed[id]) + a = len(cov.all[id]) + breakdown[id] = Tally(c, a, c / a * 100) + completed += c + all += a + result = Tally(completed, all, completed / all * 100) + return CovTally(result, breakdown) + +def task_coverage(specs, states): all = {} completed = {} missing = {} @@ -132,21 +145,9 @@ def do_cov(specs, states): spec = json.loads(spec)["spec"] all[id] = set([t for t in spec["task_specs"]]) missing[id] = all[id] - completed[id] - - return TestCov(all, completed, missing) -def tally(cov): - completed = 0 - all = 0 - breakdown = {} - for id in cov.all: - c = len(cov.completed[id]) - a = len(cov.all[id]) - breakdown[id] = Tally(c, a, c / a * 100) - completed += c - all += a - result = Tally(completed, all, completed / all * 100) - return CovTally(result, breakdown) + cov = TestCov(all, completed, missing) + return cov, tally(cov) ### @@ -167,10 +168,10 @@ def tally(cov): print("Unit Test Task Coverage:\n") - cov = tally(do_cov(ctx.specs, [t.state for t in test_cases])) + cov, tally = task_coverage(ctx.specs, [t.state for t in test_cases]) for id, f in ctx.files: - [c, a, p] = cov.breakdown[id] - print(f"{f} - {c}/{a} - {p:.2f}%") + [completed, all, percent] = tally.breakdown[id] + print(f"{f} - {completed}/{all} - {percent:.2f}%") - [c, a, p] = cov.result - print(f"\nTotal - {c}/{a} - {p:.2f}%") + [completed, all, percent] = tally.result + print(f"\nTotal - {completed}/{all} - {percent:.2f}%") From 356066a55f2720dae45438677f4413950ed0b1ce Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Fri, 6 Feb 2026 14:52:22 -0500 Subject: [PATCH 4/4] wip --- test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test.py b/test.py index d354603..a891684 100644 --- a/test.py +++ b/test.py @@ -175,3 +175,6 @@ def task_coverage(specs, states): [completed, all, percent] = tally.result print(f"\nTotal - {completed}/{all} - {percent:.2f}%") + + if percent < 10.0: + sys.exit(1)