From 37626c0ace0ec01e207e9882c9b17776204f361b Mon Sep 17 00:00:00 2001 From: fiestorra Date: Sun, 29 Nov 2026 23:23:16 +0100 Subject: [PATCH 1/3] tests: the local-baseline case does not measure CPU contention test_a_local_baseline_replaces_the_committed_one asks that a locally written baseline replaces the committed one; the 5x limit was incidental to that, and on a shared runner it turned the case into a performance test whose only observed failure was a contended box (macos-python on #2641: returncode 1 with empty stderr, i.e. the tool's own over-limit verdict). The over-limit behaviour keeps its deterministic coverage: --max-slowdown 0.01 must report one, and that case asserts it. Written with an AI assistant. --- tests/test_bench_translate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_bench_translate.py b/tests/test_bench_translate.py index 4a94c8d6bf..d76ef1f1eb 100644 --- a/tests/test_bench_translate.py +++ b/tests/test_bench_translate.py @@ -102,7 +102,10 @@ def test_a_local_baseline_replaces_the_committed_one(self): written = run("--runs", "1", "--size", "20", "--write-baseline", path) self.assertEqual(written.returncode, 0, written.stderr) self.assertTrue(os.path.isfile(path)) - result = run("--runs", "1", "--size", "20", "--baseline", path, "--max-slowdown", "5", "--json") + # The limit is not what this case is about: it checks that a local baseline replaces the committed one, and + # the over-limit behaviour has its own test (--max-slowdown 0.01 must report one). A 5x threshold on a + # shared runner measures CPU contention rather than this code, and produced its only observed failure. + result = run("--runs", "1", "--size", "20", "--baseline", path, "--max-slowdown", "1000", "--json") self.assertEqual(result.returncode, 0, result.stderr) report = json.loads(result.stdout) self.assertEqual(report["baseline_source"], os.path.abspath(path)) From 7c99b8e504897a802971cdbccdf656f26080a63f Mon Sep 17 00:00:00 2001 From: fiestorra Date: Sun, 29 Nov 2026 23:44:44 +0100 Subject: [PATCH 2/3] tests: compare the local baseline's numbers, not a timing threshold merzleckeier measured what a bigger limit buys and it is not enough: at a 1024x slowdown the 1000x draft still failed 0/3, while comparing the run's baseline back against the file it was given passed 3/3. A limit measures the runner; the numbers do not. So the case now reads the measured values out of the baseline it just wrote and asserts the second run used exactly those, with no --max-slowdown on that invocation. The over-limit behaviour keeps its own deterministic test (--max-slowdown 0.01 must report one), untouched. Verified here: 10 passed, 5 subtests; and substituting a different baseline makes the case fail (1 failed), which is what the assertion is for. Written with an AI assistant. --- tests/test_bench_translate.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_bench_translate.py b/tests/test_bench_translate.py index d76ef1f1eb..4228a758dc 100644 --- a/tests/test_bench_translate.py +++ b/tests/test_bench_translate.py @@ -102,15 +102,18 @@ def test_a_local_baseline_replaces_the_committed_one(self): written = run("--runs", "1", "--size", "20", "--write-baseline", path) self.assertEqual(written.returncode, 0, written.stderr) self.assertTrue(os.path.isfile(path)) - # The limit is not what this case is about: it checks that a local baseline replaces the committed one, and - # the over-limit behaviour has its own test (--max-slowdown 0.01 must report one). A 5x threshold on a - # shared runner measures CPU contention rather than this code, and produced its only observed failure. - result = run("--runs", "1", "--size", "20", "--baseline", path, "--max-slowdown", "1000", "--json") + # What this case is about is that a local baseline replaces the committed one, and the way to say that without + # measuring CPU contention is to compare the numbers back against the file that was just written. The limit + # behaviour has its own deterministic test (--max-slowdown 0.01 must report one). + with open(path, encoding="utf-8") as handle: + written = json.load(handle)["measured"] + result = run("--runs", "1", "--size", "20", "--baseline", path, "--json") self.assertEqual(result.returncode, 0, result.stderr) report = json.loads(result.stdout) self.assertEqual(report["baseline_source"], os.path.abspath(path)) self.assertEqual(sorted(report["baseline"]), sorted(report["measured"])) - self.assertEqual(report["over_limit"], []) + # The baseline is that file's own numbers, not the committed ones: substituting the latter fails here. + self.assertEqual(report["baseline"], written) def test_compare_runs_two_trees_and_prints_a_ratio(self): tools = os.path.join(ROOT, "tools") @@ -128,3 +131,4 @@ def test_bad_arguments_are_rejected(self): if __name__ == "__main__": unittest.main() + From bed9ed0c16a54672876d886ed01b55f0d89c36f5 Mon Sep 17 00:00:00 2001 From: fiestorra Date: Mon, 30 Nov 2026 15:47:12 +0100 Subject: [PATCH 3/3] tests: end the file with one newline, not two No content change. --- tests/test_bench_translate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_bench_translate.py b/tests/test_bench_translate.py index 4228a758dc..aead9008bf 100644 --- a/tests/test_bench_translate.py +++ b/tests/test_bench_translate.py @@ -131,4 +131,3 @@ def test_bad_arguments_are_rejected(self): if __name__ == "__main__": unittest.main() -