Answer principles round 1: 0 🔴, 1 🟡 (0 misread); chunk-pr's step takes its sleep and the tests fail on a wait; Rust test files read once per bench, the indent count bounded, and six nits
CI / tests (pull_request) Successful in 4m38s
CI / tests (pull_request) Successful in 4m38s
This commit is contained in:
@@ -7,10 +7,9 @@ import typing
|
||||
|
||||
from failure import Failure
|
||||
from task_bench.bugs import go_bugs, php_bugs, python_bugs, rust_bugs, typescript_bugs
|
||||
from mutate_changes.changed_lines import is_test
|
||||
from mutate_changes.changed_lines import is_test, STRYKER
|
||||
from task_bench.bugs.planted_mutant import Mutant
|
||||
from mutate_changes.tool_process import Run
|
||||
from mutate_changes.changed_lines import STRYKER
|
||||
|
||||
# A place as `larv-review places` prints it: `<path>:<line>` in backticks.
|
||||
PLACE = re.compile(r"`([^`\s:]+):\d+`")
|
||||
|
||||
+14
-4
@@ -524,10 +524,12 @@ def planted_tasks(bench: Bench, mutants: list[Mutant], seed: int, bugs: int) ->
|
||||
"""The mutants that become bugs, in the order seed draws them, until the bench has as many as bugs; with a line that says so
|
||||
where it has fewer."""
|
||||
tasks: list[Task] = []
|
||||
# The trees stand as they are while the bugs are planted, so their Rust test files are read once, and only where a Rust mutant is drawn.
|
||||
rust_tests = functools.cache(functools.partial(rust_tests_of, bench))
|
||||
for mutant in drawn(mutants, seed):
|
||||
if len(tasks) == bugs:
|
||||
break
|
||||
task = planted(bench, len(tasks) + 1, mutant)
|
||||
task = planted(bench, len(tasks) + 1, mutant, rust_tests)
|
||||
if isinstance(task, Failure):
|
||||
return task
|
||||
tasks += [task] if task else []
|
||||
@@ -581,8 +583,16 @@ def stopped_report(stopped: Failure, results: list[Result], total: int, names: d
|
||||
return Failure("\n".join([stopped.reason, f"task-bench stopped after {len(results)} of {total} runs, which results.json holds in {folder}:", "", *table(results, names, kind.noun)]))
|
||||
|
||||
|
||||
def planted(bench: Bench, number: int, mutant: Mutant) -> Task | Failure | None:
|
||||
"""The task of fixing mutant, with its planted tree at each side; None where the mutant doesn't become a bug at one side or the other."""
|
||||
RustTests = list[set[str] | None] | Failure
|
||||
|
||||
|
||||
def rust_tests_of(bench: Bench) -> RustTests:
|
||||
"""What `rust_test_files` finds in each side's tree."""
|
||||
return on_disk("read the Rust files", lambda: [rust_test_files(tree) for tree in bench.trees.values()])
|
||||
|
||||
|
||||
def planted(bench: Bench, number: int, mutant: Mutant, rust_tests: typing.Callable[[], RustTests] | None = None) -> Task | Failure | None:
|
||||
"""The task of fixing mutant, with its planted tree at each side; None where the mutant doesn't become a bug at one side or the other. rust_tests is what `rust_tests_of` finds for bench, read from the trees where the caller hands none."""
|
||||
diff = bench.git("diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", bench.sides["base"], bench.sides["head"], "--", mutant.path, cwd=bench.checkout, errors="replace")
|
||||
if isinstance(diff, Failure):
|
||||
return diff
|
||||
@@ -595,7 +605,7 @@ def planted(bench: Bench, number: int, mutant: Mutant) -> Task | Failure | None:
|
||||
return None
|
||||
# ... and the Rust test files of each side's tree, which it keeps only where it finds every one. A mutant in one of them is no bug.
|
||||
if mutant.path.endswith(".rs"):
|
||||
standing = on_disk(f"read the Rust files for the mutant in {mutant.path}", lambda: [rust_test_files(tree) for tree in bench.trees.values()])
|
||||
standing = (rust_tests or functools.partial(rust_tests_of, bench))()
|
||||
if isinstance(standing, Failure):
|
||||
return standing
|
||||
if any(tests is None or mutant.path in tests for tests in standing):
|
||||
|
||||
@@ -640,7 +640,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 read the Rust files for the mutant in src/lib.rs: ")
|
||||
self.assertFailsWith(main.planted(bench, 1, self.ADDING), "could not read the Rust files: ")
|
||||
|
||||
|
||||
class ContainersTest(unittest.TestCase):
|
||||
|
||||
@@ -5,8 +5,8 @@ import pathlib
|
||||
import shutil
|
||||
import typing
|
||||
|
||||
from mutate_changes.changed_lines import is_test
|
||||
from task_bench.rust_test_modules import declared, homes, with_tests_of
|
||||
from mutate_changes.changed_lines import is_test
|
||||
|
||||
|
||||
def checked_tree(planted: str, copy: str, into: str, rust_tests_planted: bool = True) -> None:
|
||||
|
||||
Reference in New Issue
Block a user