Plant bugs for task-bench in Python from the mutants mutmut kills
CI / tests (pull_request) Failing after 3m46s

This commit is contained in:
2026-11-23 21:31:00 +01:00
parent cb6aedd603
commit c6cdd2f850
15 changed files with 968 additions and 401 deletions
+7 -5
View File
@@ -18,7 +18,8 @@ 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 task_bench.plant import drawn
from task_bench.planted_mutant import Mutant
from claude_code.entries import Entry, entry_from
from failure import Failure
from task_bench.figures import Figures, Result
@@ -235,7 +236,7 @@ class BenchTest(unittest.TestCase):
def test_the_command_line_fails_with_the_reason_where_the_places_or_the_bench_fail(self):
argv = [part for name, value in self.given.items() for part in (name, value)]
for places, said in ((Failure("no history"), "no history\n"), ("- `gone.go:1` `Gone`: removed\n", "The places the seats found hard don't name any Go file that the base holds, so there is nowhere to plant a bug.\n")):
for places, said in ((Failure("no history"), "no history\n"), ("- `gone.go:1` `Gone`: removed\n", "The places the seats found hard don't name any Go or Python file that the base holds, so there is nowhere to plant a bug.\n")):
with contextlib.redirect_stdout(io.StringIO()) as out, contextlib.redirect_stderr(io.StringIO()) as errors:
self.assertEqual(main.main(argv, self.env, lambda home: places), 1)
self.assertEqual((out.getvalue(), errors.getvalue().splitlines(keepends=True)[-1]), ("", said))
@@ -308,7 +309,7 @@ class BenchTest(unittest.TestCase):
def test_fails_where_the_places_name_no_go_file_of_the_base(self):
with contextlib.redirect_stderr(io.StringIO()):
found = main.bench({**self.given, "--base": "main"}, self.env, lambda home: "- `gone.go:1` `Gone`: removed\n- `README.md:1` `Calc`: thin\n", self.home)
self.assertEqual(found, Failure("The places the seats found hard don't name any Go file that the base holds, so there is nowhere to plant a bug."))
self.assertEqual(found, Failure("The places the seats found hard don't name any Go or Python file that the base holds, so there is nowhere to plant a bug."))
self.assertFalse(self.log.exists())
def test_fails_where_the_tests_fail_without_a_bug(self):
@@ -379,7 +380,8 @@ class BenchTest(unittest.TestCase):
# Tests that catch both mutants, at a head benched against itself, where each mutant's line stands.
(self.repo / "calc_test.go").write_text(TESTS.replace("calc.go &&", "calc.go && grep -q '2 \\* a' calc.go &&"))
self.commit("Tests that catch Twice")
mutants = [Mutant("calc.go", 5, 11, "ARITHMETIC_BASE"), Mutant("calc.go", 9, 11, "ARITHMETIC_BASE")]
# The seed draws from the mutants in the order of their lines.
mutants = [Mutant("calc.go", line, "", (), ()) for line in (5, 9)]
for seed in (1, 2, 3, 4):
report = self.bench(**{"--base": "HEAD", "--bugs": "1", "--runs": "1", "--seed": str(seed)})
self.assertNotIsInstance(report, Failure, report)
@@ -490,7 +492,7 @@ class InTurn(Recorded):
class RunOutcomesTest(unittest.TestCase):
MUTANT = Mutant("calc.go", 4, 11, "ARITHMETIC_BASE")
MUTANT = Mutant("calc.go", 4, "calc.go:4:11 ARITHMETIC_BASE", (b"\treturn a + b",), (b"\treturn a - b",))
def setUp(self):
folder = tempfile.TemporaryDirectory()