Answer stability round 2: 0 🔴, 0 🟡 (0 misread); drop a report the tree held before the run, move a comment back to its function
CI / tests (pull_request) Has been cancelled
CI / tests (pull_request) Has been cancelled
This commit is contained in:
@@ -116,8 +116,6 @@ def outcome_lines(path: pathlib.Path) -> list[str]:
|
||||
return path.read_text(encoding="utf-8", errors="replace").splitlines() if path.is_file() else []
|
||||
|
||||
|
||||
# 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 glob_escaped(path: str) -> str:
|
||||
"""A path as a glob that matches it. Stryker 10.1.1 reads each entry of --mutate as a glob, in which `app/[slug]/page.tsx`
|
||||
matches `app/s/page.tsx` and not the file of that name. It reads a backslash as a slash, so no character can be escaped: a `?`
|
||||
@@ -125,6 +123,8 @@ def glob_escaped(path: str) -> str:
|
||||
return re.sub(r"[][!()*+@{}]", "?", path)
|
||||
|
||||
|
||||
# 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]], run: Run, 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. Last, a line
|
||||
naming the files with no package.json above them, if any.
|
||||
|
||||
@@ -167,7 +167,7 @@ class KilledMutantsTest(unittest.TestCase):
|
||||
def run(argv: list[str], cwd: str) -> Ran:
|
||||
self.ran.append((argv, cwd, pathlib.Path(cwd, "src/pick.ts").read_bytes()))
|
||||
report = pathlib.Path(cwd, "reports/mutation/mutation.json")
|
||||
report.parent.mkdir(parents=True)
|
||||
report.parent.mkdir(parents=True, exist_ok=True)
|
||||
pathlib.Path(cwd, "reports/stryker-incremental.json").write_text("every mutant", encoding="utf-8")
|
||||
if files is not None:
|
||||
report.write_text(text if text is not None else json.dumps({"files": {path: {"source": PICK.decode(), "mutants": mutants} for path, mutants in files.items()}}), encoding="utf-8")
|
||||
@@ -214,6 +214,12 @@ class KilledMutantsTest(unittest.TestCase):
|
||||
found = killed_mutants(str(self.top), ["src/pick.ts"], self.stryker(None, code=1), 1)
|
||||
self.assertEqual(found, Failure("Stryker exited 1:\nthe tool's last words"))
|
||||
|
||||
def test_reads_no_report_that_the_tree_held_before_the_run(self):
|
||||
(self.top / "reports/mutation").mkdir(parents=True)
|
||||
(self.top / "reports/mutation/mutation.json").write_text(json.dumps({"files": {"src/pick.ts": {"source": PICK.decode(), "mutants": [OPERATOR]}}}), encoding="utf-8")
|
||||
found = killed_mutants(str(self.top), ["src/pick.ts"], self.stryker(None, code=1), 1)
|
||||
self.assertEqual(found, Failure("Stryker exited 1:\nthe tool's last words"))
|
||||
|
||||
def test_passes_on_a_run_that_could_not_start(self):
|
||||
failure = Failure("npx could not start: No such file or directory")
|
||||
self.assertIs(killed_mutants(str(self.top), ["src/pick.ts"], lambda argv, cwd: failure, 1), failure)
|
||||
|
||||
@@ -35,8 +35,10 @@ def killed_mutants(top: str, files: list[str], run: Run, jobs: int) -> list[Muta
|
||||
scratch, copy = copied
|
||||
try:
|
||||
mutate = ",".join(in_diff_tools.glob_escaped(path) for path in files)
|
||||
ran = run([*in_diff_tools.STRYKER_RUN, "--mutate", mutate, "--concurrency", str(jobs), "--reporters", "json"], copy)
|
||||
report = pathlib.Path(copy, REPORT)
|
||||
# A report the project tracks would otherwise stand for this run's.
|
||||
report.unlink(missing_ok=True)
|
||||
ran = run([*in_diff_tools.STRYKER_RUN, "--mutate", mutate, "--concurrency", str(jobs), "--reporters", "json"], copy)
|
||||
# Stryker exits 1 too where it finished under the score the project's config sets as `thresholds.break`, which the files'
|
||||
# score may be. Only a run that finished writes the report.
|
||||
if isinstance(ran, Failure) or ran.code and not report.is_file():
|
||||
|
||||
Reference in New Issue
Block a user