Keep a Rust file's test modules as planted when task-bench checks a fix
CI / tests (pull_request) Failing after 5m10s
CI / tests (pull_request) Failing after 5m10s
This commit is contained in:
@@ -578,6 +578,11 @@ class RunOutcomesTest(unittest.TestCase):
|
||||
bench = dataclasses.replace(self.bench(), trees={"base": str(self.tree), "head": str(head)})
|
||||
self.assertIsNone(main.planted(bench, 1, self.MUTANT))
|
||||
|
||||
def test_a_rust_mutant_in_a_file_whose_test_module_cannot_be_told_apart_is_passed_over(self):
|
||||
(self.tree / "lib.rs").write_text("pub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n#[cfg(test)]\nmod tests {\n")
|
||||
mutant = Mutant("lib.rs", 2, "lib.rs:2:7 replace + with -", (b" a + b",), (b" a - b",))
|
||||
self.assertIsNone(main.planted(self.bench(), 1, mutant))
|
||||
|
||||
|
||||
class ContainersTest(unittest.TestCase):
|
||||
IN_TREE = ["--memory", "512m", "--memory-swap", "512m", "--user", "1000:1000", "--env", "HOME=/tmp", "--volume", "/tree:/work", "--workdir", "/work"]
|
||||
@@ -718,6 +723,18 @@ class CheckedTreeTest(unittest.TestCase):
|
||||
checked_tree(planted, copy, str(self.root / "check"))
|
||||
self.assertEqual(self.held("check"), {"calc.go": "fixed", "sub/testdata/gone.golden": "4", "testdata.go": "fixed", "testdata/want.golden": "3"})
|
||||
|
||||
def test_takes_a_rust_files_test_module_as_planted_and_the_rest_as_fixed(self):
|
||||
planted = self.tree("planted", {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 1 }\n"})
|
||||
copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests {}\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "#[cfg(test)]\nmod mine {}\nfn c() {}\n"})
|
||||
checked_tree(planted, copy, str(self.root / "check"))
|
||||
self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "#[cfg(test)]\nmod mine {}\nfn c() {}\n"})
|
||||
|
||||
def test_takes_the_planted_rust_file_where_the_fix_deleted_its_test_module(self):
|
||||
planted = self.tree("planted", {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"})
|
||||
copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n"})
|
||||
checked_tree(planted, copy, str(self.root / "check"))
|
||||
self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"})
|
||||
|
||||
def test_copies_a_link_as_a_link(self):
|
||||
planted = self.tree("planted", {"calc.go": "bug"})
|
||||
copy = self.tree("copy", {"calc.go": "fixed"})
|
||||
|
||||
Reference in New Issue
Block a user