Sort the imports and hand the planter its languages as an argument
CI / tests (pull_request) Successful in 3m28s

This commit is contained in:
2026-11-23 21:35:21 +01:00
parent c6cdd2f850
commit b0e50e24ae
9 changed files with 25 additions and 30 deletions
+9 -9
View File
@@ -6,10 +6,10 @@ import re
import typing
from failure import Failure
from mutate_changes.changed_lines import is_test
from mutate_changes.tool_process import Run
from task_bench import go_bugs, python_bugs
from mutate_changes.changed_lines import is_test
from task_bench.planted_mutant import Mutant
from mutate_changes.tool_process import Run
# A place as `larv-review places` prints it: `<path>:<line>` in backticks.
PLACE = re.compile(r"`([^`\s:]+):\d+`")
@@ -32,8 +32,8 @@ LANGUAGES = (
)
def language_of(path: str) -> Language | None:
return next((language for language in LANGUAGES if path.endswith(language.suffixes)), None)
def language_of(path: str, languages: tuple[Language, ...] = LANGUAGES) -> Language | None:
return next((language for language in languages if path.endswith(language.suffixes)), None)
def place_files(places: str) -> list[str]:
@@ -42,12 +42,12 @@ def place_files(places: str) -> list[str]:
return sorted({path for path in PLACE.findall(places) if language_of(path) and not is_test(path)})
def killed_mutants(top: str, files: list[str], run: Run, jobs: int) -> list[Mutant] | Failure:
def killed_mutants(top: str, files: list[str], run: Run, jobs: int, languages: tuple[Language, ...] = LANGUAGES) -> list[Mutant] | Failure:
"""The mutants in `files`, which place_files named, that the tests of the tree at top kill: each language's tool runs over
the files in that language."""
killed: list[Mutant] = []
for language in LANGUAGES:
own = [path for path in files if language_of(path) is language]
for language in languages:
own = [path for path in files if language_of(path, languages) is language]
found = language.killed(top, own, run, jobs) if own else []
if isinstance(found, Failure):
return found
@@ -60,8 +60,8 @@ def drawn(mutants: list[Mutant], seed: int) -> list[Mutant]:
return random.Random(seed).sample(sorted(set(mutants)), len(set(mutants)))
def task_text(path: str, output: str) -> str | None:
def task_text(path: str, output: str, languages: tuple[Language, ...] = LANGUAGES) -> str | None:
"""What Haiku is told of a bug planted in the file at path, one place_files named: the failing test's message in output,
what the test command printed, as the file's language reads it. None where the output holds no such message."""
language = language_of(path)
language = language_of(path, languages)
return language.told(output) if language else None