Skip to content

Commit 4f8f47b

Browse files
committed
chore(scripts): battery diff and stamp guard accept multi-run legs
- `diff` reads the plain union dump and falls back to the incremental leg's fresh dump; unknown labels error with both candidate names - `--incremental` combined with `--runs N` is an explicit error: the two legs are separate invocations, and silently dropping the runs count reported single-run dumps as union sets - the binary-identity guard compares `.runN`-stripped label families; re-runs of one leg share a binary by design, cross-family reuse over one build still refuses
1 parent 322ad46 commit 4f8f47b

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

‎contributing/scripts/e2e-battery.py‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ def builder_commit(workspace):
107107
return None
108108

109109

110+
def leg_family(label):
111+
"""`pre.run1` / `pre.run2` are re-runs of ONE leg; sharing a binary
112+
there is the design. The guard exists for cross-family reuse
113+
(pre vs post over one build)."""
114+
return re.sub(r"\.run\d+$", "", label)
115+
116+
110117
def record_leg_binary(out_dir, label, commit):
111118
"""Record this leg's binary identity and reject a re-used binary.
112119
@@ -132,7 +139,7 @@ def record_leg_binary(out_dir, label, commit):
132139
clash = [
133140
other
134141
for other, seen in ledger.items()
135-
if seen == commit and other != label
142+
if seen == commit and leg_family(other) != leg_family(label)
136143
]
137144
if clash:
138145
raise SystemExit(
@@ -358,6 +365,12 @@ def cmd_run(args):
358365
if not p.is_file():
359366
raise SystemExit(f"{what} {p} is not a file")
360367
semantic_on = args.semantic == "on"
368+
if args.incremental and args.runs != 1:
369+
# The incremental leg replaces the plain leg entirely; silently
370+
# ignoring --runs would report single-run dumps as union sets.
371+
raise SystemExit(
372+
"--incremental and --runs N are separate legs: run them as two invocations"
373+
)
361374
parity_ok = True
362375
for spec in args.corpus:
363376
name, fixture, pin = parse_corpus_spec(spec)
@@ -400,10 +413,22 @@ def cmd_run(args):
400413
raise SystemExit("incremental leg: lane parity broken (see diffs above)")
401414

402415

416+
def leg_dump(out: Path, label: str) -> list[str]:
417+
# Plain legs write {label}.edges (union under --runs N); incremental
418+
# legs write {label}.fresh.edges. Prefer the plain form, fall back to
419+
# the incremental leg's fresh dump rather than crashing on it.
420+
plain = out / f"{label}.edges"
421+
fresh = out / f"{label}.fresh.edges"
422+
target = plain if plain.is_file() else fresh
423+
if not target.is_file():
424+
raise SystemExit(f"no dump for label {label!r} in {out} (looked for {plain.name}, {fresh.name})")
425+
return target.read_text().splitlines()
426+
427+
403428
def cmd_diff(args):
404429
out = Path(args.out).resolve() / args.corpus
405-
old = (out / f"{args.old}.edges").read_text().splitlines()
406-
new = (out / f"{args.new}.edges").read_text().splitlines()
430+
old = leg_dump(out, args.old)
431+
new = leg_dump(out, args.new)
407432
old_set, new_set = set(old), set(new)
408433
dropped = sorted(old_set - new_set)
409434
gained = sorted(new_set - old_set)

0 commit comments

Comments
 (0)