Answer stability round 2: 1 🔴, 2 🟡 (0 misread); run Stryker as @stryker-mutator/core, pass an interrupted tool SIGINT before the kill, test SIGHUP, and print a failed Stryker or Infection run's whole report
CI / tests (pull_request) Successful in 2m24s
CI / tests (pull_request) Successful in 2m24s
This commit was merged in pull request #488.
This commit is contained in:
@@ -3,7 +3,7 @@ import os
|
||||
import pathlib
|
||||
|
||||
from mutate_changes.changed_lines import by_folder, label, runs
|
||||
from mutate_changes.tool_process import failed, remove, run_tool, scratch_folder
|
||||
from mutate_changes.tool_process import failed, Ran, remove, run_tool, scratch_folder
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import git
|
||||
|
||||
@@ -48,8 +48,8 @@ def run_stryker(top: str, changed: dict[str, frozenset[int]], prefix: str | None
|
||||
"""For each folder Stryker runs in, a line naming it, then Stryker's own report of the mutants on the changed lines. Last, a line
|
||||
naming the files with no package.json above them, if any.
|
||||
|
||||
Stryker runs in the nearest folder above each file that holds a package.json. Through `npx --no`, it runs only where the project
|
||||
installed it."""
|
||||
Stryker runs in the nearest folder above each file that holds a package.json. npx runs the project's own @stryker-mutator/core, else
|
||||
one an earlier npx run cached, and installs none."""
|
||||
report: list[str] = []
|
||||
unplaced: list[str] = []
|
||||
for folder, files in sorted(by_folder(top, changed, ("package.json",)).items()):
|
||||
@@ -58,9 +58,9 @@ def run_stryker(top: str, changed: dict[str, frozenset[int]], prefix: str | None
|
||||
unplaced = sorted(files)
|
||||
continue
|
||||
mutate = ",".join(f"{path}:{first}-{last}" for path, lines in sorted(files.items()) for first, last in runs(lines))
|
||||
ran = run_tool(["npx", "--no", "stryker", "run", "--mutate", mutate, "--concurrency", str(jobs), "--reporters", "clear-text"], os.path.join(top, folder), prefix)
|
||||
ran = run_tool(["npx", "--no", "--package=@stryker-mutator/core", "stryker", "run", "--mutate", mutate, "--concurrency", str(jobs), "--reporters", "clear-text"], os.path.join(top, folder), prefix)
|
||||
if isinstance(ran, Failure) or ran.code:
|
||||
return ran if isinstance(ran, Failure) else failed(f"Stryker in {label(folder)}", ran)
|
||||
return ran if isinstance(ran, Failure) else whole_output(f"Stryker in {label(folder)}", ran)
|
||||
report.extend([f"Stryker in {label(folder)}:", *ran.output.splitlines()])
|
||||
return [*report, *([f"Not mutated, as no package.json is above them: {', '.join(unplaced)}."] if unplaced else [])]
|
||||
|
||||
@@ -69,5 +69,11 @@ def run_infection(top: str, base: str, prefix: str | None, jobs: int) -> list[st
|
||||
"""A line naming where Infection ran, top, then its own report of the mutants on the lines the branch changes since base."""
|
||||
ran = run_tool(["vendor/bin/infection", "--git-diff-lines", f"--git-diff-base={base}", f"--threads={jobs}", "--show-mutations=max", "--no-progress"], top, prefix)
|
||||
if isinstance(ran, Failure) or ran.code:
|
||||
return ran if isinstance(ran, Failure) else failed("Infection", ran)
|
||||
return ran if isinstance(ran, Failure) else whole_output("Infection", ran)
|
||||
return ["Infection in the checkout's top:", *ran.output.splitlines()]
|
||||
|
||||
|
||||
def whole_output(name: str, ran: Ran) -> Failure:
|
||||
"""A tool's exit code and its whole output. Stryker and Infection also exit nonzero on a mutation score below the project's threshold,
|
||||
where the output is the report of what survived."""
|
||||
return Failure("\n".join([f"{name} exited {ran.code}:", *ran.output.splitlines()]))
|
||||
|
||||
Reference in New Issue
Block a user