Repository navigation
fix(verify): reject stale performance reports on reruns #2930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
richiemcilroy
merged 5 commits into
CapSoftware:main
from
AksharP5:fix/verify-stale-perf-reports
Oct 23, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5a63119
fix(verify): reject stale performance reports on reruns
AksharP5 f6f8631
test(verify): use kebab-case for the performance regression test
AksharP5 1296367
Merge branch 'main' into fix/verify-stale-perf-reports
richiemcilroy 379691d
Merge main into fix/verify-stale-perf-reports
AksharP5 e35eff9
Merge branch 'main' into fix/verify-stale-perf-reports
richiemcilroy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import importlib.util | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
| import unittest | ||
|
|
||
|
|
||
| SCRIPT = Path(__file__).with_name("perf-ab.py").resolve() | ||
| SPEC = importlib.util.spec_from_file_location("perf_ab", SCRIPT) | ||
| PERF = importlib.util.module_from_spec(SPEC) | ||
| SPEC.loader.exec_module(PERF) | ||
|
|
||
|
|
||
| @unittest.skipUnless(hasattr(os, "wait4"), "The performance runner requires POSIX wait4") | ||
| class PerformanceReportTests(unittest.TestCase): | ||
| def setUp(self): | ||
| self.temporary = tempfile.TemporaryDirectory() | ||
| self.addCleanup(self.temporary.cleanup) | ||
| self.root = Path(self.temporary.name).resolve() | ||
| (self.root / "crates" / "verify").mkdir(parents=True) | ||
|
|
||
| def side(self, records, exit_code=0): | ||
| binary = self.root / "fixture.py" | ||
| binary.with_suffix(".json").write_text(json.dumps({"records": records, "exit": exit_code})) | ||
| binary.write_text(f"#!{sys.executable}\n" + r"""import json | ||
| import os | ||
| from pathlib import Path | ||
| import sys | ||
|
|
||
| Path(__file__).with_suffix(".started").touch() | ||
| fixture = json.loads(Path(__file__).with_suffix(".json").read_text()) | ||
| if fixture["records"]: | ||
| report = Path(os.environ["CAP_VERIFY_REPORT_DIR"]) | ||
| path = report / f"cap-verify-{os.getpid()}.jsonl" | ||
| path.write_text("".join(json.dumps(row) + "\n" for row in fixture["records"])) | ||
| print("fixture completed") | ||
| sys.exit(fixture["exit"]) | ||
| """) | ||
| binary.chmod(0o700) | ||
| return { | ||
| "worktree": str(self.root), | ||
| "binaries": {target: str(binary) for _, target, _, _, _ in PERF.WORKLOADS}, | ||
| } | ||
|
|
||
| def test_existing_reports_are_preserved_and_never_used(self): | ||
| side = self.side([]) | ||
| report = self.root / "reports" | ||
| report.mkdir() | ||
| stale = report / "cap-verify-123.jsonl" | ||
| previous = json.dumps({"case": "export/basic/output/mp4/native", "outcome": "pass"}) + "\n" | ||
| stale.write_text(previous) | ||
| log = report / "test.log" | ||
| log.write_text("previous run\n") | ||
| with self.assertRaises(FileExistsError): | ||
| PERF.run_once(side, "export", "export/basic/*", "fast", self.root / "fixtures", report) | ||
| self.assertEqual(stale.read_text(), previous) | ||
| self.assertEqual(log.read_text(), "previous run\n") | ||
| self.assertFalse((self.root / "fixture.started").exists()) | ||
|
|
||
| def test_fresh_reports_preserve_exit_status_and_outcomes(self): | ||
| outcomes = ["pass", "xfail", "xpass", "fail", "unsupported", "inconclusive"] | ||
| rows = [{"case": f"export/basic/{outcome}", "outcome": outcome} for outcome in outcomes] | ||
| result = PERF.run_once( | ||
| self.side(rows, 101), "export", "export/basic/*", "fast", | ||
| self.root / "fixtures", self.root / "reports", | ||
| ) | ||
| self.assertEqual(result["exit"], 101) | ||
| self.assertEqual(result["outcomes"], { | ||
| f"export/basic/{outcome}": "ran" if outcome in {"pass", "xfail", "xpass"} else outcome | ||
| for outcome in outcomes | ||
| }) | ||
|
|
||
| def test_cli_rejects_fresh_runs_that_report_no_cases(self): | ||
| manifest = self.root / "binaries.json" | ||
| manifest.write_text(json.dumps(self.side([]))) | ||
| output = self.root / "output" | ||
| output.mkdir() | ||
| result = subprocess.run([ | ||
| sys.executable, "-B", str(SCRIPT), "--base", str(manifest), "--head", str(manifest), | ||
| "--fixtures", str(self.root / "fixtures"), "--out", str(output), "--pairs", "1", | ||
| ], capture_output=True, text=True, timeout=30) | ||
| self.assertEqual(result.returncode, 1, result.stdout + result.stderr) | ||
| self.assertIn("not measured:", result.stdout) | ||
| self.assertEqual((output / "perf-budget.md").read_text().count("BROKEN:"), len(PERF.WORKLOADS)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.