Test that each file task-bench cannot copy, read or write fails the bench and names what could not be done
CI / tests (pull_request) Successful in 5m2s

This commit is contained in:
2026-11-23 01:58:57 +01:00
parent b7993aaf93
commit cc23e80fb8
+42
View File
@@ -2,6 +2,7 @@
fix is checked in, and the proxy that reaches only the API.""" fix is checked in, and the proxy that reaches only the API."""
import asyncio import asyncio
import contextlib import contextlib
import dataclasses
import io import io
import json import json
import os import os
@@ -472,6 +473,47 @@ class RunOutcomesTest(unittest.TestCase):
broke = Failure("docker could not start: No such file or directory") broke = Failure("docker could not start: No such file or directory")
self.assertEqual(main.planted(self.bench(broke), 1, self.MUTANT), broke) self.assertEqual(main.planted(self.bench(broke), 1, self.MUTANT), broke)
def assertFailsWith(self, found, start: str):
self.assertIsInstance(found, Failure)
self.assertTrue(found.reason.startswith(start), found.reason)
def test_a_tree_that_cannot_be_copied_for_a_fix_fails_the_bench_naming_the_bug_and_side(self):
task = dataclasses.replace(self.task, trees={"base": str(self.folder / "gone"), "head": str(self.tree)})
self.assertFailsWith(main.fixed(task, "base", 1, self.containers(), self.folder), "could not copy bug 1's tree at the base: ")
def test_a_tree_that_checks_a_fix_that_cannot_be_made_fails_the_bench_naming_the_bug_and_side(self):
(self.folder / "check").mkdir()
self.assertFailsWith(main.fixed(self.task, "base", 1, self.containers(Ran(0, "")), self.folder), "could not make the tree that checks bug 1's fix at the base: ")
def test_results_that_cannot_be_written_fail_the_bench_naming_the_folder(self):
bench = dataclasses.replace(self.bench(), folder=self.folder / "gone")
self.assertFailsWith(main.kept(bench, [], {}, []), f"could not write the results under {self.folder / 'gone'}: ")
def test_a_bug_that_cannot_be_planted_fails_the_bench_naming_the_tree(self):
(self.folder / "file").write_text("")
tree = self.folder / "file" / "base"
self.assertFailsWith(main.planted_tree(self.bench(), "base", tree, "calc.go", b""), f"could not plant the bug in {tree}: ")
def test_a_tree_that_cannot_be_copied_for_its_tests_fails_the_bench_naming_it(self):
gone = str(self.folder / "gone")
self.assertFailsWith(main.tests_in_copy(self.containers(), gone, self.folder), f"could not copy {gone} to test it: ")
def test_a_tree_whose_folder_cannot_be_made_fails_the_bench_naming_it(self):
(self.folder / "file").write_text("")
into = self.folder / "file" / "base"
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):
(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_mutant_in_a_file_the_head_lacks_is_passed_over(self):
head = self.folder / "head"
head.mkdir()
bench = dataclasses.replace(self.bench(), trees={"base": str(self.tree), "head": str(head)})
self.assertIsNone(main.planted(bench, 1, self.MUTANT))
class ContainersTest(unittest.TestCase): class ContainersTest(unittest.TestCase):
IN_TREE = ["--memory", "512m", "--memory-swap", "512m", "--user", "1000:1000", "--env", "HOME=/tmp", "--volume", "/tree:/work", "--workdir", "/work"] IN_TREE = ["--memory", "512m", "--memory-swap", "512m", "--user", "1000:1000", "--env", "HOME=/tmp", "--volume", "/tree:/work", "--workdir", "/work"]