From eb64ac8a4b7ad6e7d9d73851a8d26845681ed4ce Mon Sep 17 00:00:00 2001 From: felix Date: Sun, 22 Nov 2026 14:16:33 +0000 Subject: [PATCH] fix(id): make the nixos-integration partition guard check disjointness (#1372) The coverage guard added by #4913 claims to prove the group filters partition the suite exactly, but its overlap term counted matches within each group's own hit list. --list names are unique, so that count can never exceed one and duplicated= was always empty: a test matched by two groups (e.g. a serve_tests test whose name also hits a harness_unit bare-name filter) would run twice, silently, and the guard would still pass. Count matches across groups instead. Also remove the unreachable print left after the final failed-groups raise (dead since cc96cc489). Evidence (bounded exercise of the exact emitted testScript, python3, no VM build): before, an overlapping fixture passed the guard; after, it is rejected naming the duplicated test. Disjoint and uncovered fixtures behave identically before and after, and the emitted testScript compiles. --- pkgs/id/nix/tests/integration-test.nix | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/id/nix/tests/integration-test.nix b/pkgs/id/nix/tests/integration-test.nix index 2f421d7906..1116e12906 100644 --- a/pkgs/id/nix/tests/integration-test.nix +++ b/pkgs/id/nix/tests/integration-test.nix @@ -128,8 +128,16 @@ ) covered.append((name, hits)) - overlap = sorted({t for _name, hits in covered for t in hits if hits.count(t) > 1}) - missing = sorted(set(all_tests) - {t for _name, hits in covered for t in hits}) + # Count matches across groups: a test two groups match would run twice + # and silently inflate the suite. Counting within one group's hits can + # never exceed one (--list names are unique), so the disjointness half + # of the partition has to be computed over all groups at once. + match_counts = {} + for _name, hits in covered: + for t in hits: + match_counts[t] = match_counts.get(t, 0) + 1 + overlap = sorted(t for t, count in match_counts.items() if count > 1) + missing = sorted(set(all_tests) - set(match_counts)) if overlap or missing: raise AssertionError( "[id-integration] group filters must partition the suite exactly; " @@ -199,10 +207,5 @@ raise AssertionError( "[id-integration] failed groups: " + ", ".join(failed_groups) ) - print( - f"[id-integration] group '{name}' finished in " - f"{time.monotonic() - group_started:.1f}s", - flush=True, - ) ''; }