Answer stability round 1: 0 🔴, 4 🟡 (0 misread); test the digest's half surrogate, git's diff settings and literal report rows, and guard the permissions test against root
This commit is contained in:
@@ -16,12 +16,12 @@ import unittest
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from task_bench import api_proxy, bench_folder, main, runs
|
||||
from test_env import assert_not_root, isolated_env
|
||||
from task_bench.runs import checked_tree, closed, Containers, docker_cli, fix_attempted, opened, ran_tests, TimedOut
|
||||
from task_bench.plant import drawn, Mutant
|
||||
from claude_code.entries import Entry
|
||||
from claude_code.entries import Entry, entry_from
|
||||
from failure import Failure
|
||||
from task_bench.figures import Figures, Result, table
|
||||
from test_env import isolated_env
|
||||
from task_bench.figures import Figures, Result
|
||||
from mutate_changes.tool_process import Ran
|
||||
from claude_code.tokens import Tokens
|
||||
|
||||
@@ -166,6 +166,16 @@ class BenchTest(unittest.TestCase):
|
||||
self.assertEqual((folder / "runs/bug-1-base-1.stderr").read_bytes(), b"")
|
||||
self.assertEqual(os.readlink(folder / "bugs/1/head/dangling"), "missing")
|
||||
|
||||
def test_plants_the_bug_on_the_same_line_at_the_head_whatever_the_callers_git_does_to_a_diff(self):
|
||||
# Colour, an external diff and a textconv that numbers the lines each change what `git diff` prints, and so where the head's line is.
|
||||
self.git("config", "color.diff", "always")
|
||||
self.git("config", "diff.external", "false")
|
||||
self.git("config", "diff.numbered.textconv", "cat -n")
|
||||
(self.repo / ".git/info/attributes").write_text("*.go diff=numbered\n")
|
||||
report = self.bench()
|
||||
self.assertNotIsInstance(report, Failure, report)
|
||||
self.assertIn("| 1: calc.go:4:11 ARITHMETIC_BASE | head | 2/2 | 40 | 9000 | 52000 | 800 | 3 | 61.5 | 1 |", report)
|
||||
|
||||
def test_writes_a_digest_of_the_runs_with_each_bugs_decoys_and_traces(self):
|
||||
folder = pathlib.Path(self.bench()[-1].removeprefix(main.KEPT))
|
||||
digest = (folder / "digest.md").read_text().splitlines()
|
||||
@@ -351,10 +361,19 @@ class ReportTest(unittest.TestCase):
|
||||
SIDES = {"base": "b" * 40, "head": "h" * 40}
|
||||
NAMES = {1: "calc.go:4:11 ARITHMETIC_BASE"}
|
||||
RESULTS = [Result(1, "base", 1, True, Figures("2.1.330", "claude-haiku-5-5", Tokens(40, 0, 9000, 52000, 800), 7, 61.5, 2)), Result(1, "head", 1, False, None)]
|
||||
TABLE = [
|
||||
"| Bug | Side | Passed | Input | Cache write | Cache read | Output | Turns | Wall, s | Reads |",
|
||||
"|---|---|---|---|---|---|---|---|---|---|",
|
||||
"| 1: calc.go:4:11 ARITHMETIC_BASE | base | 1/1 | 40 | 9000 | 52000 | 800 | 7 | 61.5 | 2 |",
|
||||
"| 1: calc.go:4:11 ARITHMETIC_BASE | head | 0/1 | - | - | - | - | - | - | - |",
|
||||
"| All | base | 1/1 | 40 | 9000 | 52000 | 800 | 7 | 61.5 | 2 |",
|
||||
"| All | head | 0/1 | - | - | - | - | - | - | - |",
|
||||
"| All | change | -1 | - | - | - | - | - | - | - |",
|
||||
]
|
||||
|
||||
def test_names_the_commits_the_bugs_the_runs_and_what_ran_them_above_the_table(self):
|
||||
told = main.report(self.SIDES, self.NAMES, main.Asked(seed=1, bugs=1, runs=2), self.RESULTS)
|
||||
self.assertEqual(told, ["task-bench: base bbbbbbbbbbbb, head hhhhhhhhhhhh. 1 bug, each run 2 times at each side by claude-haiku-5-5 in Claude Code 2.1.330.", "", *table(self.RESULTS, self.NAMES), ""])
|
||||
self.assertEqual(told, ["task-bench: base bbbbbbbbbbbb, head hhhhhhhhhhhh. 1 bug, each run 2 times at each side by claude-haiku-5-5 in Claude Code 2.1.330.", "", *self.TABLE, ""])
|
||||
|
||||
def test_says_where_fewer_bugs_were_planted_than_asked_for_and_where_no_run_finished(self):
|
||||
told = main.report(self.SIDES, self.NAMES, main.Asked(seed=1, bugs=3, runs=1), self.RESULTS[1:])
|
||||
@@ -362,7 +381,7 @@ class ReportTest(unittest.TestCase):
|
||||
|
||||
def test_a_stopped_bench_tells_why_then_how_far_it_came_then_the_table(self):
|
||||
told = main.stopped_report(Failure("claude could not use the API: Invalid bearer token"), self.RESULTS, 10, self.NAMES, pathlib.Path("/reviews/task-bench"))
|
||||
self.assertEqual(told, Failure("\n".join(["claude could not use the API: Invalid bearer token", "task-bench stopped after 2 of 10 runs, which results.json holds in /reviews/task-bench:", "", *table(self.RESULTS, self.NAMES)])))
|
||||
self.assertEqual(told, Failure("\n".join(["claude could not use the API: Invalid bearer token", "task-bench stopped after 2 of 10 runs, which results.json holds in /reviews/task-bench:", "", *self.TABLE])))
|
||||
|
||||
|
||||
class MainTest(unittest.TestCase):
|
||||
@@ -504,10 +523,17 @@ class RunOutcomesTest(unittest.TestCase):
|
||||
self.assertFailsWith(main.archived("b", into, "", lambda *args, **given: ""), f"could not make {into}: ")
|
||||
|
||||
def test_a_mutant_in_a_file_that_cannot_be_read_fails_the_bench_naming_the_file(self):
|
||||
assert_not_root(self)
|
||||
(self.tree / "calc.go").chmod(0)
|
||||
self.addCleanup((self.tree / "calc.go").chmod, 0o644)
|
||||
self.assertFailsWith(main.planted(self.bench(), 1, self.MUTANT), "could not read calc.go: ")
|
||||
|
||||
def test_a_digest_quoting_half_of_a_surrogate_pair_is_written_with_a_question_mark_in_its_place(self):
|
||||
# Claude Code may cut a string between the halves of an emoji's pair, and JSON parses the half it keeps into a lone surrogate.
|
||||
said = entry_from(json.loads('{"type": "assistant", "message": {"content": [{"type": "text", "text": "half \\ud83d pair"}]}}'))
|
||||
self.assertIsNone(main.kept(self.bench(), [self.task], {1: "calc.go:4:11 ARITHMETIC_BASE"}, [Result(1, "base", 1, False, None, [said])]))
|
||||
self.assertIn("half ? pair", (self.folder / "digest.md").read_text(encoding="utf-8"))
|
||||
|
||||
def test_a_mutant_in_a_file_the_head_lacks_is_passed_over(self):
|
||||
head = self.folder / "head"
|
||||
head.mkdir()
|
||||
|
||||
Reference in New Issue
Block a user