Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/test_bench_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +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))
result = run("--runs", "1", "--size", "20", "--baseline", path, "--max-slowdown", "5", "--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")
Expand Down