Answer stability round 1: 1 🔴, 1 🟡 (0 misread); a fix that drops a test file's declaration gets the planted file, and any file may stand beside or under its declarer

This commit is contained in:
2026-11-27 17:05:37 +01:00
parent fb9ca7757b
commit 71842a6a85
4 changed files with 50 additions and 28 deletions
+11 -4
View File
@@ -338,7 +338,7 @@ class BenchTest(unittest.TestCase):
# Passing tests with the bug planted: no message to tell Haiku.
(self.repo / "calc_test.go").write_text("exit 0\n")
self.commit("Tests that pass with the bug")
self.assertEqual(self.bench(), Failure("None of the 2 mutants the tests kill becomes a bug: each is on a line the head changed, or the test it fails doesn't print a message."))
self.assertEqual(self.bench(), Failure("None of the 2 mutants the tests kill becomes a bug: each is on a line the head changed, the test it fails doesn't print a message, or, in a Rust file, a `#[cfg(test)] mod name;` of the tree names a file the bench can't find."))
def test_a_run_the_api_refuses_fails_the_bench_and_still_removes_what_it_made(self):
self.env["FAKE_REFUSED_FROM"] = "1"
@@ -639,7 +639,7 @@ class RunOutcomesTest(unittest.TestCase):
bench = self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": "", "src/other.rs": ""})
(self.tree / "src/other.rs").chmod(0)
self.addCleanup((self.tree / "src/other.rs").chmod, 0o644)
self.assertFailsWith(main.planted(bench, 1, self.ADDING), "could not find the Rust test files beside src/lib.rs: ")
self.assertFailsWith(main.planted(bench, 1, self.ADDING), "could not read the Rust files for the mutant in src/lib.rs: ")
class ContainersTest(unittest.TestCase):
@@ -808,6 +808,12 @@ class CheckedTreeTest(unittest.TestCase):
checked_tree(planted, copy, str(self.root / "check"))
self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests;\n", "src/tests.rs": "old tests", "src/other.rs": "fixed"})
def test_takes_the_planted_rust_file_where_the_fix_dropped_the_declaration_of_a_test_file(self):
planted = self.tree("planted", {"src/lib.rs": self.DECLARING, "src/tests.rs": "old tests"})
copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n", "src/tests.rs": "old tests"})
checked_tree(planted, copy, str(self.root / "check"))
self.assertEqual(self.held("check"), {"src/lib.rs": self.DECLARING, "src/tests.rs": "old tests"})
def test_takes_a_rust_test_file_the_fix_deleted_as_planted(self):
planted = self.tree("planted", {"src/lib.rs": self.DECLARING, "src/tests.rs": "old tests"})
copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests;\n"})
@@ -831,6 +837,7 @@ class CheckedTreeTest(unittest.TestCase):
"beside a crate root": ({"src/lib.rs": self.DECLARING, "src/tests.rs": ""}, {"src/tests.rs"}),
"as a folder with a mod.rs": ({"src/main.rs": self.DECLARING, "src/tests/mod.rs": ""}, {"src/tests/mod.rs"}),
"in the folder of a module file": ({"src/pick.rs": self.DECLARING, "src/pick/tests.rs": ""}, {"src/pick/tests.rs"}),
"beside another crate root": ({"src/bin/tool.rs": self.DECLARING, "src/bin/tests.rs": ""}, {"src/bin/tests.rs"}),
"beside a mod.rs": ({"src/pick/mod.rs": self.DECLARING, "src/pick/tests.rs": ""}, {"src/pick/tests.rs"}),
"declared by no file": ({"src/lib.rs": "fn a() {}\n", "src/tests.rs": ""}, set()),
}
@@ -843,11 +850,11 @@ class CheckedTreeTest(unittest.TestCase):
os.symlink("missing.rs", os.path.join(tree, "src/ghost.rs"))
self.assertEqual(rust_test_files(tree), {"src/tests.rs"})
def test_cannot_find_a_rust_test_file_that_is_not_where_its_declaration_puts_it_or_cannot_be_read_from_it(self):
def test_cannot_find_a_rust_test_file_that_is_not_where_its_declaration_puts_it_or_cannot_be_read_from_the_tree(self):
cases = {
"missing": {"src/lib.rs": self.DECLARING},
"beside a module file, where only a crate root has its modules": {"src/pick.rs": self.DECLARING, "src/tests.rs": ""},
"moved by a path attribute": {"src/lib.rs": '#[cfg(test)]\n#[path = "t.rs"]\nmod tests;\n', "src/t.rs": ""},
"inside an inline module": {"src/lib.rs": "mod a {\n#[cfg(test)]\nmod tests;\n}\n", "src/a/tests.rs": ""},
"in a declaring file whose string is never closed": {"src/lib.rs": '#[cfg(test)]\nmod tests;\nconst A: &str = "\n', "src/tests.rs": ""},
}
for name, files in cases.items():