Answer product-owner round 2: 0 🔴, 1 🟡 (0 misread); run Stryker only where a package.json is above a file, and name the files with none in a Not mutated line
This commit is contained in:
@@ -45,18 +45,24 @@ def outcome_lines(path: pathlib.Path) -> list[str]:
|
||||
# Stryker and Infection also exit nonzero on a mutation score below a threshold the project sets, which their exit code doesn't
|
||||
# tell from a run that broke, so either fails the run.
|
||||
def run_stryker(top: str, changed: dict[str, frozenset[int]], prefix: str | None, jobs: int) -> list[str] | Failure:
|
||||
"""For each folder Stryker runs in, a line naming it, then Stryker's own report of the mutants on the changed lines.
|
||||
"""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, else in top. 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. Through `npx --no`, it runs only where the project
|
||||
installed it."""
|
||||
report: list[str] = []
|
||||
unplaced: list[str] = []
|
||||
for folder, files in sorted(by_folder(top, changed, ("package.json",)).items()):
|
||||
# by_folder falls back to top, where no package.json means there is no Stryker to run.
|
||||
if not os.path.isfile(os.path.join(top, folder, "package.json")):
|
||||
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)
|
||||
if isinstance(ran, Failure) or ran.code:
|
||||
return ran if isinstance(ran, Failure) else failed(f"Stryker in {label(folder)}", ran)
|
||||
report.extend([f"Stryker in {label(folder)}:", *ran.output.splitlines()])
|
||||
return report
|
||||
return [*report, *([f"Not mutated, as no package.json is above them: {', '.join(unplaced)}."] if unplaced else [])]
|
||||
|
||||
|
||||
def run_infection(top: str, base: str, prefix: str | None, jobs: int) -> list[str] | Failure:
|
||||
|
||||
Reference in New Issue
Block a user