diff --git a/scripts/diff_truth.py b/scripts/diff_truth.py index 266f636c..d1f42733 100644 --- a/scripts/diff_truth.py +++ b/scripts/diff_truth.py @@ -207,7 +207,8 @@ def main() -> None: json.dump(reports, sys.stdout, indent=2) print() - if compared < len(platforms) and (args.platform or not compared): + # A named platform must be compared; --all must compare at least one. + if compared < (len(platforms) if args.platform else 1): print(f"compared {compared} of {len(platforms)} platform(s)", file=sys.stderr) sys.exit(1) diff --git a/scripts/exporter/baseline.py b/scripts/exporter/baseline.py index e9458eaa..5bad4103 100644 --- a/scripts/exporter/baseline.py +++ b/scripts/exporter/baseline.py @@ -90,16 +90,12 @@ class NativeFile: return platform_values if source == "truth": return truth_values - if truth_values and platform_values and not set(truth_values) & set( - platform_values - ): + if not truth_values: + return platform_values + if not set(truth_values) & set(platform_values): return truth_values - if truth_values: - # Keep the platform's extra accepted revisions alongside ours. - merged = list(truth_values) - merged.extend(v for v in platform_values if v not in merged) - return merged - return platform_values + # Keep the platform's extra accepted revisions alongside ours. + return truth_values + [v for v in platform_values if v not in truth_values] def hash(self, field_name: str) -> str: values = self.hashes(field_name) diff --git a/scripts/pipeline.py b/scripts/pipeline.py index 6d5897ab..792b0420 100644 --- a/scripts/pipeline.py +++ b/scripts/pipeline.py @@ -71,6 +71,14 @@ def parse_verify_counts(output: str) -> dict[str, tuple[int, int]]: return counts +def _full_pack_label(label: str) -> str: + """The pack name, or "" for a reduced variant such as [source=platform].""" + meta = re.search(r"\s+\[([^\]]+)\]$", label) + if meta is None: + return label + return label[: meta.start()] if meta.group(1) == "source=full" else "" + + def parse_pack_counts(output: str) -> dict[str, tuple[int, int]]: """Extract per-pack OK/total from generate_pack output. @@ -85,11 +93,7 @@ def parse_pack_counts(output: str) -> dict[str, tuple[int, int]]: # the full, unreduced pack is what verify describes: with # --all-variants the six variants shared one label and the last # (platform, required) was compared to the full report. - label = m.group(1).strip() - meta = re.search(r"\s+\[([^\]]+)\]$", label) - current_label = label[: meta.start()] if meta else label - if meta and meta.group(1) != "source=full": - current_label = "" + current_label = _full_pack_label(m.group(1).strip()) continue if not current_label: continue @@ -99,7 +103,6 @@ def parse_pack_counts(output: str) -> dict[str, tuple[int, int]]: base_m = re.search(r"\((\d+) baseline", line) ok_m = re.search(r"(\d+)/(\d+) files OK", line) if base_m and ok_m: - int(base_m.group(1)) ok, total = int(ok_m.group(1)), int(ok_m.group(2)) counts[current_label] = (ok, total) elif ok_m: diff --git a/scripts/slots.py b/scripts/slots.py index 18c4ba49..52aa623e 100644 --- a/scripts/slots.py +++ b/scripts/slots.py @@ -350,6 +350,14 @@ def arbitrate(conflict: Conflict, mode: str, addressee: str = "platform") -> Dec return Decision(conflict, conflict.platform_claim, FRONTEND_CHECKS_CONTENT) +def _pinned_elsewhere(claims: list[Claim], winner: str | None) -> set[str]: + """Emulators that pin content the served file does not carry.""" + return { + c.emulator for c in claims + if c.emulator and c.local_path != winner and resolution_is_hash_exact(c.status) + } + + def format_decision(decision: Decision) -> str: """One line naming the contested slot, the winner and the ground for it.""" conflict = decision.conflict @@ -357,11 +365,7 @@ def format_decision(decision: Decision) -> str: winner = decision.winner.local_path # A claim that only matched a path is answered by whatever file sits # there; only one that pins content can be left wanting. - pinned_elsewhere = { - c.emulator for c in conflict.profile_claims - if c.emulator and c.local_path != winner - and resolution_is_hash_exact(c.status) - } + pinned_elsewhere = _pinned_elsewhere(conflict.profile_claims, winner) served = sorted({ c.emulator for c in conflict.profile_claims if c.emulator } - pinned_elsewhere)