Files
rea/scripts/verify/mutation-target-tsconfig.mjs
T
jeromeskiiiandmorluto 3273cbd1e2 fix(mutation): unblock the daily mutation sweep (#14748)
* fix(mutation): include every mutated file in the mutation project

Stryker's typescript-checker watches the files the mutation project
includes. A mutated file the project leaves out has no watcher, and the
sweep aborts with "no watcher is registered for it" before it reports a
score. The semantics suite mutates src/rizin/RizinDebugFrames.ts and
src/rizin/RizinDebugEvidence.ts, and the reverse-tools suite mutates
src/domain/analysisResourceLimits.ts; none of the three was in
tsconfig.reverse-tools-mutation.json, so the daily mutation sweep failed
before it produced a report.

Add the three files to the project. Add scripts/verify/mutation-target-tsconfig.mjs,
which reads the resolved mutation targets from both configurations and
fails when the project does not cover them or lists a file the repository
no longer has. The guard runs in the deep static lane and before the
sweep, so the drift is reported by name instead of as a checker
abort.

* fix(mutation): give the reverse-tools sweep the time it needs

The reverse-tools suite reached 805 of 1008 mutants after 57 minutes of
mutation testing on the 2026-11-26 scheduled run and was killed by the
60-minute job budget before it could report a score. The suite needs
about 70 minutes of mutation testing plus the setup it runs before it.

Raise the job budget to 90 minutes so the sweep reports instead of
being cancelled. The budget is the only change; the suite and its
mutant set are untouched.

* fix(ci): select mutation quality for debugger limit changes

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 19:13:03 +00:00

90 lines
3.0 KiB
JavaScript

import { dirname, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import ts from "typescript6";
const rootUrl = new URL("../../", import.meta.url);
const root = fileURLToPath(rootUrl);
const configNames = ["stryker.config.mjs", "stryker.semantics.config.mjs"];
const projectFiles = new Map();
const failures = [];
const diagnosticsHost = {
getCanonicalFileName: (path) => path,
getCurrentDirectory: ts.sys.getCurrentDirectory,
getNewLine: () => ts.sys.newLine,
};
// Stryker's range selectors read source paths relative to the repository.
process.chdir(root);
const fileKey = (path) =>
ts.sys.useCaseSensitiveFileNames ? path : path.toLowerCase();
for (const configName of configNames) {
const { default: config } = await import(new URL(configName, rootUrl).href);
if (typeof config.tsconfigFile !== "string" || !config.tsconfigFile)
throw new Error(`${configName} must name a TypeScript checker project`);
const projectPath = resolve(root, config.tsconfigFile);
const projectName = relative(root, projectPath);
if (!projectFiles.has(projectPath)) {
const project = ts.getParsedCommandLineOfConfigFile(
projectPath,
{},
{
...ts.sys,
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
throw new Error(ts.formatDiagnostic(diagnostic, diagnosticsHost));
},
},
);
if (project.errors.length > 0)
throw new Error(ts.formatDiagnostics(project.errors, diagnosticsHost));
// TypeScript silently drops unmatched include entries. Require literal paths
// in this project to exist while allowing globs and directory includes.
for (const entry of project.raw.include ?? []) {
const path = resolve(dirname(projectPath), entry);
if (
!/[*?]/u.test(entry) &&
!ts.sys.fileExists(path) &&
!ts.sys.directoryExists(path)
)
failures.push(`${projectName} has a missing include entry: ${entry}`);
}
projectFiles.set(
projectPath,
new Set(project.fileNames.map((path) => fileKey(resolve(path)))),
);
}
// A transitive import can be in the program without a Stryker file watcher.
// Check the compiler's root file list. Both configs emit concrete line ranges.
const targets = new Set(
config.mutate.map((target) => {
const match = /^(.+):\d+-\d+$/u.exec(target);
if (!match)
throw new Error(
`${configName} has an unreadable mutation target: ${target}`,
);
return match[1];
}),
);
const files = projectFiles.get(projectPath);
for (const target of [...targets].sort()) {
if (!files.has(fileKey(resolve(root, target))))
failures.push(
`${configName} requires ${target} as a root file in ${projectName}`,
);
}
}
if (failures.length > 0) {
console.error(`Mutation project guard failed:\n${failures.join("\n")}\n`);
process.exitCode = 1;
} else {
console.log(
`Mutation project guard passed for ${configNames.length} configurations.`,
);
}