@mark1russell7/rigor-mutation 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -156,6 +156,30 @@ packages/compiler/src/module-sheet.test.ts:12: "../../testkit/src/fc-timeout.ts"
156
156
 
157
157
  The check does not read comments, type imports and paths with a template expression.
158
158
 
159
+ With `--collect`, the Vitest of each package also loads each test file, as Stryker does. The check copies the folder of the package to `.stryker-tmp/load-check-*` in that folder, and links its `node_modules`. Stryker makes its sandbox in the same form. The copy takes only the files that Stryker copies. The ignore rules of Stryker 10 and the `ignorePatterns` of the `stryker` field of the lane leave out the other files. The collect of Vitest starts in the copy, in a new process, with `staticParse: false`. Then each file starts, so the check finds a missing package, also through a helper. A path that finds a file only in the folder of the package fails in the copy too. Then for each selection of the package, Vitest gives the test files that its related mode starts for the mutated files. These are faults:
160
+
161
+ - a test file that does not load,
162
+ - a test file that holds no test,
163
+ - an error outside a test file,
164
+ - a package with no test file,
165
+ - a test file that no selection starts, and that `notRead` does not name,
166
+ - an entry of `notRead` for a file that is not on the disk, or that a selection starts,
167
+ - a dynamic import with a computed path in a file that the run loads, unless `computedImports` of the package names the file with a reason.
168
+
169
+ The related mode does not follow a computed import. A test file that reaches the mutated files only through this import thus starts in no selection, and each mutant that it detects survives.
170
+
171
+ ```json
172
+ { "computedImports": { "src/load-all.test.ts": "it imports each module of src/ops, and ops.test.ts tests each module" } }
173
+ ```
174
+
175
+ On a fault, the check fails with a line that starts with `No read`. A score of that package is not a reading.
176
+
177
+ `--runner <file>` writes the version and the path of the Vitest of each package to the file, as JSON. Each package uses the Vitest that its folder resolves.
178
+
179
+ ```text
180
+ rigor-mutation load-check --collect --runner reports/runner.json
181
+ ```
182
+
159
183
  ## The disabled mutants
160
184
 
161
185
  A comment `// Stryker disable next-line <Mutator>: <reason>` disables a mutant that is equivalent. The disable raises the score, so each one is also in the list, with its reason. `rigor-mutation disables` compares the comments of the sources of each package with the list. It fails when they are not the same, or when a comment has no reason. After you add or remove a disable, start `rigor-mutation disables --write` and examine the diff of the list.
package/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as runCli } from "./run-B5WrsoMv.js";
2
+ import { n as runCli } from "./run-BvctkYlJ.js";
3
3
  // src/cli.ts
4
4
  try {
5
5
  process.exitCode = runCli(process.argv.slice(2), {
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ import { join, relative, resolve } from "node:path";
4
+ import { readFileSync, realpathSync, writeFileSync } from "node:fs";
5
+ import { pathToFileURL } from "node:url";
6
+ // src/collect.ts
7
+ /**
8
+ * The collect of `load-check --collect`. The CLI starts this file in a new process for each package:
9
+ * `node collect.ts <request> <out>`. The request is a `CollectRequest` as JSON. The script loads the Vitest that the
10
+ * folder resolves. That Vitest collects each test file, and the script writes a `Collected` as JSON to `<out>`.
11
+ *
12
+ * The option `staticParse: false` makes Vitest start each file. Under Vitest 5 the default form only parses a file, so
13
+ * it does not find a missing package. Then for each selection, the script sets `related` to its mutated files. It reads
14
+ * the test files that the related mode starts, as the runner of Stryker does.
15
+ */
16
+ const [requestFile, out] = process.argv.slice(2);
17
+ if (requestFile === void 0 || out === void 0) throw new Error("collect.ts takes <request> <out>");
18
+ const request = JSON.parse(readFileSync(requestFile, "utf8"));
19
+ const root = resolve(request.dir);
20
+ const fromRoot = (file) => relative(root, file).replaceAll("\\", "/");
21
+ const entry = createRequire(join(root, "package.json")).resolve("vitest/node");
22
+ const vitestNode = await import(pathToFileURL(entry).href);
23
+ process.chdir(root);
24
+ const config = request.config === void 0 ? {} : { config: resolve(root, request.config) };
25
+ const vitest = await vitestNode.createVitest("test", {
26
+ root,
27
+ watch: false,
28
+ ...config
29
+ });
30
+ try {
31
+ const { testModules, unhandledErrors } = await vitest.collect(void 0, { staticParse: false });
32
+ const message = (e) => e instanceof Error ? e.message : String(e);
33
+ const unhandled = unhandledErrors.map(message);
34
+ const selections = {};
35
+ for (const [name, files] of Object.entries(request.selections)) {
36
+ selections[name] = [];
37
+ if (files.length === 0) continue;
38
+ vitest.config.related = files.map((f) => resolve(root, f));
39
+ try {
40
+ const specifications = await vitest.getRelevantTestSpecifications();
41
+ selections[name] = [...new Set(specifications.map((s) => fromRoot(s.moduleId)))].toSorted();
42
+ } catch (e) {
43
+ unhandled.push(`the related mode of Vitest failed for the selection ${name}: ${message(e)}`);
44
+ }
45
+ }
46
+ const collected = {
47
+ version: vitestNode.version,
48
+ path: realpathSync(entry).replaceAll("\\", "/"),
49
+ files: testModules.map((m) => ({
50
+ file: fromRoot(m.moduleId),
51
+ errors: m.errors().map((e) => e.message),
52
+ children: m.children.size
53
+ })),
54
+ unhandled,
55
+ selections
56
+ };
57
+ writeFileSync(out, `${JSON.stringify(collected)}\n`);
58
+ process.exitCode = 0;
59
+ } finally {
60
+ await vitest.close();
61
+ }
62
+ export {};
63
+
64
+ //# sourceMappingURL=collect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect.js","names":[],"sources":["../src/collect.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * The collect of `load-check --collect`. The CLI starts this file in a new process for each package:\n * `node collect.ts <request> <out>`. The request is a `CollectRequest` as JSON. The script loads the Vitest that the\n * folder resolves. That Vitest collects each test file, and the script writes a `Collected` as JSON to `<out>`.\n *\n * The option `staticParse: false` makes Vitest start each file. Under Vitest 5 the default form only parses a file, so\n * it does not find a missing package. Then for each selection, the script sets `related` to its mutated files. It reads\n * the test files that the related mode starts, as the runner of Stryker does.\n */\nimport { readFileSync, realpathSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join, relative, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { Collected, CollectRequest } from \"./load.ts\";\n\nconst [requestFile, out] = process.argv.slice(2);\nif (requestFile === undefined || out === undefined) throw new Error(\"collect.ts takes <request> <out>\");\nconst request = JSON.parse(readFileSync(requestFile, \"utf8\")) as CollectRequest;\nconst root = resolve(request.dir);\nconst fromRoot = (file: string): string => relative(root, file).replaceAll(\"\\\\\", \"/\");\n// Each package reads the Vitest of its own folder, as the runner of Stryker does.\nconst entry = createRequire(join(root, \"package.json\")).resolve(\"vitest/node\");\nconst vitestNode = (await import(pathToFileURL(entry).href)) as typeof import(\"vitest/node\");\nprocess.chdir(root);\nconst config = request.config === undefined ? {} : { config: resolve(root, request.config) };\nconst vitest = await vitestNode.createVitest(\"test\", { root, watch: false, ...config });\ntry {\n const { testModules, unhandledErrors } = await vitest.collect(undefined, { staticParse: false });\n const message = (e: unknown): string => (e instanceof Error ? e.message : String(e));\n const unhandled = unhandledErrors.map(message);\n const selections: Record<string, string[]> = {};\n for (const [name, files] of Object.entries(request.selections)) {\n selections[name] = [];\n // An empty list of related files makes Vitest start each test file, so a selection with no file starts none.\n if (files.length === 0) continue;\n (vitest.config as { related?: string[] }).related = files.map((f) => resolve(root, f));\n try {\n const specifications = await vitest.getRelevantTestSpecifications();\n selections[name] = [...new Set(specifications.map((s) => fromRoot(s.moduleId)))].toSorted();\n } catch (e) {\n unhandled.push(`the related mode of Vitest failed for the selection ${name}: ${message(e)}`);\n }\n }\n const collected: Collected = {\n version: vitestNode.version,\n path: realpathSync(entry).replaceAll(\"\\\\\", \"/\"),\n files: testModules.map((m) => ({ file: fromRoot(m.moduleId), errors: m.errors().map((e) => e.message), children: m.children.size })),\n unhandled,\n selections,\n };\n writeFileSync(out, `${JSON.stringify(collected)}\\n`);\n // Vitest sets the exit code 1 for a file that does not load. The file of the collect gives that fault.\n process.exitCode = 0;\n} finally {\n await vitest.close();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAM,CAAC,aAAa,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC/C,IAAI,gBAAgB,KAAA,KAAa,QAAQ,KAAA,GAAW,MAAM,IAAI,MAAM,kCAAkC;AACtG,MAAM,UA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,KAAK,CAAC,CAAC,WAAW,MAAM,GAAG;EAC9C,OAAO,YAAY,KAAK,OAAO;GAAE,MAAM,SAAS,EAAE,QAAQ;GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,MAAM,EAAE,OAAO;GAAG,UAAU,EAAE,SAAS;EAAK,EAAE;EACnI;EACA;CACF;CACA,cAAc,KAAK,GAAG,KAAK,UAAU,SAAS,EAAE,GAAG;CAEnD,QAAQ,WAAW;AACrB,UAAU;CACR,MAAM,OAAO,MAAM;AACrB"}
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PARTIAL_FILE, PartialLine, PartialReporter } from "./reporter.js";
1
+ import { n as PartialLine, r as PartialReporter, t as PARTIAL_FILE } from "./reporter-CkdX8IPx.js";
2
2
  /**
3
3
  * The lane file of a repository (`mutation.json`) names the packages that the mutation tests mutate. A package has
4
4
  * its folder, its globs and an optional gate. A big package has parts, so that each part has its own runner.
@@ -44,6 +44,11 @@ interface PackageLane {
44
44
  * --test-files` fails for each other test file on the disk that the report does not read. The file is from `dir`.
45
45
  */
46
46
  readonly notRead?: Readonly<Record<string, string>>;
47
+ /**
48
+ * Each file of this field has a dynamic import with a computed path, and the value gives the reason. The related walk
49
+ * of Vitest does not follow this type of import. `load-check --collect` fails for each other file of the run with one.
50
+ */
51
+ readonly computedImports?: Readonly<Record<string, string>>;
47
52
  }
48
53
  /** The keys of the Stryker config that the lane owns. The field `stryker` of a package cannot have them. */
49
54
  export declare const STRYKER_OWNED: readonly string[];
@@ -371,6 +376,22 @@ export declare function isConfigFile(file: string, vitestConfig?: string): boole
371
376
  * @param vitestConfig - the field `vitestConfig` of the lane
372
377
  */
373
378
  export declare function leavingPaths(files: readonly PackageFile[], vitestConfig?: string): LeavingPath[];
379
+ /** A dynamic import with a computed path in a file that the run loads. */
380
+ interface ComputedImport {
381
+ /** The file, from the folder of the package, with `/`. */
382
+ readonly file: string;
383
+ /** The line of the import, from 1. */
384
+ readonly line: number;
385
+ }
386
+ /**
387
+ * This function gives each dynamic import with a computed path in the files that the run loads. The related walk of
388
+ * Vitest does not follow this type of import. So no selection starts a test file that reaches the mutated files only through
389
+ * it, and each mutant of these files survives. The function does not read comments and config files.
390
+ *
391
+ * @param files - the files of the package, from its folder
392
+ * @param vitestConfig - the field `vitestConfig` of the lane
393
+ */
394
+ export declare function computedImports(files: readonly PackageFile[], vitestConfig?: string): ComputedImport[];
374
395
  /**
375
396
  * This function gives the test files that the related mode of the Vitest runner starts for a selection. A test file
376
397
  * is related when it loads a file of the selection, directly or through other files of the package. The function
@@ -380,6 +401,33 @@ export declare function leavingPaths(files: readonly PackageFile[], vitestConfig
380
401
  * @param selected - the function that tells if a file is a file of the selection
381
402
  */
382
403
  export declare function relatedTestFiles(files: readonly PackageFile[], selected: (file: string) => boolean): string[];
404
+ /** A test file as the collect of Vitest gives it (`load-check --collect`). */
405
+ interface CollectedFile {
406
+ /** The file, with `/`. */
407
+ readonly file: string;
408
+ /** The messages of the errors of the file. A file that does not load has one or more. */
409
+ readonly errors: readonly string[];
410
+ /** The number of tests and suites at the top of the file. */
411
+ readonly children: number;
412
+ }
413
+ /** The collect of Vitest in the folder of a package. */
414
+ interface Collected {
415
+ /** The version of Vitest that the folder of the package resolves. */
416
+ readonly version: string;
417
+ /** The real path of the entry `vitest/node` that the folder resolves. */
418
+ readonly path: string;
419
+ readonly files: readonly CollectedFile[];
420
+ /** The messages of the errors outside a test file. */
421
+ readonly unhandled: readonly string[];
422
+ /** The test files that the related mode of Vitest starts for each selection, by the name of the selection. */
423
+ readonly selections: Readonly<Record<string, readonly string[]>>;
424
+ }
425
+ /**
426
+ * This function gives the reason of each fault of a collect. A test file that does not load gives no failed test, so
427
+ * each mutant that it detects survives (V-090 of Vex). A test file with no test detects no mutant. An error outside a
428
+ * test file and a package with no test file are faults too.
429
+ */
430
+ export declare function collectFaults(collected: Collected): string[];
383
431
  /** The input and the output of the CLI. */
384
432
  interface CliIo {
385
433
  readonly cwd: string;
@@ -392,5 +440,5 @@ interface CliIo {
392
440
  export declare const HELP: string;
393
441
  /** This function starts the CLI with its arguments and gives the exit code. */
394
442
  export declare function runCli(argv: readonly string[], io: CliIo): number;
395
- export { type CliIo, type ConfigOptions, type Disable, type DisableCheck, type Lane, type LeavingPath, type Mutant, type MutationReport, PARTIAL_FILE, type PackageFile, type PackageLane, type PartialCosts, type PartialLine, PartialReporter, type PartialRun, type Score, type ScoreOutcome, type Selection, type StrykerConfig };
443
+ export { type CliIo, type Collected, type CollectedFile, type ComputedImport, type ConfigOptions, type Disable, type DisableCheck, type Lane, type LeavingPath, type Mutant, type MutationReport, PARTIAL_FILE, type PackageFile, type PackageLane, type PartialCosts, type PartialLine, PartialReporter, type PartialRun, type Score, type ScoreOutcome, type Selection, type StrykerConfig };
396
444
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/lane.ts","../src/config.ts","../src/score.ts","../src/disables.ts","../src/load.ts","../src/run.ts"],"mappings":";;;;;;UAQiB;;WAEN;;;;;WAKA;;;;;;WAMA,QAAQ,SAAS;;WAEjB;;;;;WAKA;;WAEA;;;;;WAKA;;WAEA;;;;;WAKA,UAAU,SAAS;;;;;WAKnB,UAAU,SAAS;;;qBAIjB;;UAGI;WACN,UAAU,SAAS,eAAe;;WAElC;;;;;WAKA;;WAEA,eAAe,SAAS;;;UAOlB;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,SAAS,SAAS;;;;;;;wBAyDb,UAAU,gBAAgB;;wBAkB1B,eAAe,MAAM;;wBAKrB,cAAc,MAAM;;;;;;wBASpB,OAAO,MAAM,MAAM,eAAe;;;;;;;;;wBAoElC,aAAa,WAAW,WAAW,4BAA4B,UAAS;;;;;;;;;;;;wBAkDxE,WAAW,MAAM,MAAM,aAAa,0BAA0B,SAAS;;UC5RtE;;WAEN;;WAEA;;;;;WAKA;;;;;WAKA;;;UAIM;;WAEN;WACA;WACA;aAAoB;;WACpB;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AAM,SAAS;;;qBAIb;;wBA0XG,OAAO,yBAAyB,IAAI"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/lane.ts","../src/config.ts","../src/score.ts","../src/disables.ts","../src/load.ts","../src/run.ts"],"mappings":";;;;;;UAQiB;;WAEN;;;;;WAKA;;;;;;WAMA,QAAQ,SAAS;;WAEjB;;;;;WAKA;;WAEA;;;;;WAKA;;WAEA;;;;;WAKA,UAAU,SAAS;;;;;WAKnB,UAAU,SAAS;;;;;WAKnB,kBAAkB,SAAS;;;qBAIzB;;UAGI;WACN,UAAU,SAAS,eAAe;;WAElC;;;;;WAKA;;WAEA,eAAe,SAAS;;;UAOlB;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,SAAS,SAAS;;;;;;;wBA0Db,UAAU,gBAAgB;;wBAkB1B,eAAe,MAAM;;wBAKrB,cAAc,MAAM;;;;;;wBASpB,OAAO,MAAM,MAAM,eAAe;;;;;;;;;wBAoElC,aAAa,WAAW,WAAW,4BAA4B,UAAS;;;;;;;;;;;;wBAkDxE,WAAW,MAAM,MAAM,aAAa,0BAA0B,SAAS;;UClStE;;WAEN;;WAEA;;;;;WAKA;;;;;WAKA;;;UAIM;;WAEN;WACA;WACA;aAAoB;;WACpB;WACA;WACA;WACA;aAAyB;;WACzB;aAAyB;;WACzB;aAAuB;aAAuB;aAAsB;;WACpE;WACA;WACA;WACA;WACA;WACA;;;;;;qBAOE;;qBAGA;;;;;qBAMA;;;;;qBAMA;;;;;;wBAOG,iBAAiB;;qBAKpB;;;;;;wBAOG,cAAc,WAAW,WAAW,UAAS,gBAAqB;;;;;;;;;;UCpEjE;WACN;WACA;;WAEA;WACA;aAAqB;eAAkB;;;;;UAIjC;WACN,OAAO,SAAS;aAA0B,kBAAkB;;;WAE5D,YAAY,SAAS;aAA0B;eAA2B;;;;;;;;KAOzE;;UAGK;WACN;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;WAEA;;WAEA,UAAU;;WAEV,UAAU;;;UAIJ;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM,mBAAmB;WACzB,QAAQ;;WAER;;;;;;;;wBASK,aAAa,eAAe;;;;;wBAuC5B,aAAa,KAAK,YAAY;WAAsB;WAAuB;IAA6B;;qBAY3G,aAAc,GAAG;;;;;;wBAOd,YAAY,gBAAgB;;;;;;wBA4G5B,YAAY,QAAQ,gBAAgB;WAAsB;WAAuB;IAA6B;;;;;;;;wBA4C9G,aAAa,cAAc,0BAA0B,gBAAgB,SAAS,8BAAkC;;wBA2BhH,YAAY,GAAG;;wBASf,gBAAgB,iBAAiB;;;;;;;UCpUhC;WACN;WACA;;;UAIM;;WAEN;;WAEA;;WAEA,mBAAmB;WACnB;;;wBAIK,aAAa;WAA2B;WAAuB;MAAmB;;wBA+BlF,gBAAgB,gBAAgB,WAAW,iBAAiB,YAAY;;UC9CvE;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;WACA;;;;;;;;wBAoBK,aAAa,cAAc;;;;;;;;;;wBAsC3B,aAAa,gBAAgB,eAAe,wBAAwB;;UAoCnE;;WAEN;;WAEA;;;;;;;;;;wBAWK,gBAAgB,gBAAgB,eAAe,wBAAwB;;;;;;;;;wBAwBvE,iBAAiB,gBAAgB,eAAe,WAAW;;UA0B1D;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;WACA,gBAAgB;;WAEhB;;WAEA,YAAY,SAAS;;;;;;;wBAkBhB,cAAc,WAAW;;UCvMxB;WACN;WACA,SAAS;WACT,SAAS;;WAET,MAAM,SAAS;;;qBAIb;;wBA4dG,OAAO,yBAAyB,IAAI"}
package/build/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { C as STRYKER_OWNED, D as runSelections, E as partErrors, O as select, S as strykerConfig, T as parseLane, _ as NO_TSCONFIG, a as relatedTestFiles, b as TIMEOUT_MS, c as formatScore, d as parsePartial, f as parseReport, g as DRY_RUN_TIMEOUT_MINUTES, h as summaryMarkdown, i as leavingPaths, k as selectionNames, l as isHitLimit, m as scoreReport, n as runCli, o as compareDisables, p as partialScore, r as isConfigFile, s as findDisables, t as HELP, u as packageScore, v as PARTIAL_PLUGIN, w as changedFiles, x as rewritesTsconfig, y as REPORT_DIR } from "./run-B5WrsoMv.js";
2
- import { PARTIAL_FILE, PartialReporter } from "./reporter.js";
3
- export { DRY_RUN_TIMEOUT_MINUTES, HELP, NO_TSCONFIG, PARTIAL_FILE, PARTIAL_PLUGIN, PartialReporter, REPORT_DIR, STRYKER_OWNED, TIMEOUT_MS, changedFiles, compareDisables, findDisables, formatScore, isConfigFile, isHitLimit, leavingPaths, packageScore, parseLane, parsePartial, parseReport, partErrors, partialScore, relatedTestFiles, rewritesTsconfig, runCli, runSelections, scoreReport, select, selectionNames, strykerConfig, summaryMarkdown };
1
+ import { A as select, C as rewritesTsconfig, D as parseLane, E as changedFiles, O as partErrors, S as TIMEOUT_MS, T as STRYKER_OWNED, _ as summaryMarkdown, a as isConfigFile, b as PARTIAL_PLUGIN, c as compareDisables, d as isHitLimit, f as packageScore, g as scoreReport, h as partialScore, i as computedImports, j as selectionNames, k as runSelections, l as findDisables, m as parseReport, n as runCli, o as leavingPaths, p as parsePartial, r as collectFaults, s as relatedTestFiles, t as HELP, u as formatScore, v as DRY_RUN_TIMEOUT_MINUTES, w as strykerConfig, x as REPORT_DIR, y as NO_TSCONFIG } from "./run-BvctkYlJ.js";
2
+ import { n as PartialReporter, t as PARTIAL_FILE } from "./reporter-Cypwcaj9.js";
3
+ export { DRY_RUN_TIMEOUT_MINUTES, HELP, NO_TSCONFIG, PARTIAL_FILE, PARTIAL_PLUGIN, PartialReporter, REPORT_DIR, STRYKER_OWNED, TIMEOUT_MS, changedFiles, collectFaults, compareDisables, computedImports, findDisables, formatScore, isConfigFile, isHitLimit, leavingPaths, packageScore, parseLane, parsePartial, parseReport, partErrors, partialScore, relatedTestFiles, rewritesTsconfig, runCli, runSelections, scoreReport, select, selectionNames, strykerConfig, summaryMarkdown };
@@ -0,0 +1,63 @@
1
+ /** The name of the file of the reporter, in the folder of the JSON report. */
2
+ declare const PARTIAL_FILE = "partial.jsonl";
3
+ /** A line of `partial.jsonl`. The field `at` gives the time in milliseconds since 1970. */
4
+ type PartialLine = {
5
+ readonly event: "start";
6
+ readonly at: number;
7
+ } | {
8
+ readonly event: "plan";
9
+ readonly at: number;
10
+ readonly mutants: number;
11
+ readonly run: number;
12
+ } | {
13
+ readonly event: "mutant";
14
+ readonly at: number;
15
+ readonly file: string;
16
+ readonly status: string;
17
+ readonly statusReason?: string;
18
+ readonly mutatorName: string;
19
+ readonly line: number;
20
+ } | {
21
+ readonly event: "done";
22
+ readonly at: number;
23
+ };
24
+ /** The parts of a Stryker mutant result that the reporter reads. */
25
+ interface TestedMutant {
26
+ readonly fileName: string;
27
+ readonly status: string;
28
+ readonly statusReason?: string;
29
+ readonly mutatorName: string;
30
+ readonly location: {
31
+ readonly start: {
32
+ readonly line: number;
33
+ };
34
+ };
35
+ }
36
+ /** The reporter. Stryker gives it its options, and `now` and `cwd` are for the tests. */
37
+ declare class PartialReporter {
38
+ static readonly inject: readonly ["options"];
39
+ readonly file: string;
40
+ private readonly now;
41
+ private readonly cwd;
42
+ constructor(options: {
43
+ readonly jsonReporter?: {
44
+ readonly fileName?: string;
45
+ };
46
+ }, now?: () => number, cwd?: string);
47
+ onMutationTestingPlanReady(event: {
48
+ readonly mutantPlans: readonly {
49
+ readonly plan: string;
50
+ }[];
51
+ }): void;
52
+ onMutantTested(result: TestedMutant): void;
53
+ onMutationTestReportReady(): void;
54
+ private write;
55
+ }
56
+ /** The plugins of this module, in the form of `declareClassPlugin` of `@stryker-mutator/api/plugin`. */
57
+ declare const strykerPlugins: readonly {
58
+ readonly kind: "Reporter";
59
+ readonly name: string;
60
+ readonly injectableClass: typeof PartialReporter;
61
+ }[];
62
+ export { strykerPlugins as i, PartialLine as n, PartialReporter as r, PARTIAL_FILE as t };
63
+ //# sourceMappingURL=reporter-CkdX8IPx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter-CkdX8IPx.d.ts","names":[],"sources":["../src/reporter.ts"],"mappings":";cAQa;;KAGD;WACG;WAAyB;;WACzB;WAAwB;WAAqB;WAA0B;;WAEvE;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WAAwB;;;UAG7B;WACC;WACA;WACA;WACA;WACA;aAAqB;eAAkB;;;;;cAIrC;kBACK;WACP;mBACQ;mBACA;EAEjB,YAAY;aAAoB;eAA0B;;KAAuB,oBAA8B;EAS/G,2BAA2B;aAAkB;eAAiC;;;EAI9E,eAAe,QAAQ;EAMvB;UAKQ;;;cAMG;WAAoC;WAA2B;WAAuB,wBAAwB"}
@@ -0,0 +1,66 @@
1
+ import { dirname, join, relative, sep } from "node:path";
2
+ import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
3
+ // src/reporter.ts
4
+ /**
5
+ * The Stryker reporter `rigor-partial`. It appends the plan and each tested mutant to `partial.jsonl`, next to the JSON
6
+ * report, at the time of each event. When a time limit stops Stryker, `scores` reads this file for a partial score.
7
+ */
8
+ /** The name of the file of the reporter, in the folder of the JSON report. */
9
+ const PARTIAL_FILE = "partial.jsonl";
10
+ /** The reporter. Stryker gives it its options, and `now` and `cwd` are for the tests. */
11
+ var PartialReporter = class {
12
+ static inject = ["options"];
13
+ file;
14
+ now;
15
+ cwd;
16
+ constructor(options, now = Date.now, cwd = process.cwd()) {
17
+ this.now = now;
18
+ this.cwd = cwd;
19
+ this.file = join(cwd, dirname(options.jsonReporter?.fileName ?? "reports/mutation/mutation.json"), PARTIAL_FILE);
20
+ mkdirSync(dirname(this.file), { recursive: true });
21
+ writeFileSync(this.file, "");
22
+ this.write({
23
+ event: "start",
24
+ at: this.now()
25
+ });
26
+ }
27
+ onMutationTestingPlanReady(event) {
28
+ this.write({
29
+ event: "plan",
30
+ at: this.now(),
31
+ mutants: event.mutantPlans.length,
32
+ run: event.mutantPlans.filter((p) => p.plan === "Run").length
33
+ });
34
+ }
35
+ onMutantTested(result) {
36
+ const file = relative(this.cwd, result.fileName).split(sep).join("/");
37
+ const reason = result.statusReason === void 0 ? {} : { statusReason: result.statusReason };
38
+ this.write({
39
+ event: "mutant",
40
+ at: this.now(),
41
+ file,
42
+ status: result.status,
43
+ ...reason,
44
+ mutatorName: result.mutatorName,
45
+ line: result.location.start.line
46
+ });
47
+ }
48
+ onMutationTestReportReady() {
49
+ this.write({
50
+ event: "done",
51
+ at: this.now()
52
+ });
53
+ }
54
+ write(line) {
55
+ appendFileSync(this.file, `${JSON.stringify(line)}\n`);
56
+ }
57
+ };
58
+ /** The plugins of this module, in the form of `declareClassPlugin` of `@stryker-mutator/api/plugin`. */
59
+ const strykerPlugins = [{
60
+ kind: "Reporter",
61
+ name: "rigor-partial",
62
+ injectableClass: PartialReporter
63
+ }];
64
+ export { PartialReporter as n, strykerPlugins as r, PARTIAL_FILE as t };
65
+
66
+ //# sourceMappingURL=reporter-Cypwcaj9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter-Cypwcaj9.js","names":[],"sources":["../src/reporter.ts"],"sourcesContent":["/**\n * The Stryker reporter `rigor-partial`. It appends the plan and each tested mutant to `partial.jsonl`, next to the JSON\n * report, at the time of each event. When a time limit stops Stryker, `scores` reads this file for a partial score.\n */\nimport { appendFileSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, relative, sep } from \"node:path\";\n\n/** The name of the file of the reporter, in the folder of the JSON report. */\nexport const PARTIAL_FILE = \"partial.jsonl\";\n\n/** A line of `partial.jsonl`. The field `at` gives the time in milliseconds since 1970. */\nexport type PartialLine =\n | { readonly event: \"start\"; readonly at: number }\n | { readonly event: \"plan\"; readonly at: number; readonly mutants: number; readonly run: number }\n | {\n readonly event: \"mutant\";\n readonly at: number;\n readonly file: string;\n readonly status: string;\n readonly statusReason?: string;\n readonly mutatorName: string;\n readonly line: number;\n }\n | { readonly event: \"done\"; readonly at: number };\n\n/** The parts of a Stryker mutant result that the reporter reads. */\ninterface TestedMutant {\n readonly fileName: string;\n readonly status: string;\n readonly statusReason?: string;\n readonly mutatorName: string;\n readonly location: { readonly start: { readonly line: number } };\n}\n\n/** The reporter. Stryker gives it its options, and `now` and `cwd` are for the tests. */\nexport class PartialReporter {\n static readonly inject = [\"options\"] as const;\n readonly file: string;\n private readonly now: () => number;\n private readonly cwd: string;\n\n constructor(options: { readonly jsonReporter?: { readonly fileName?: string } }, now: () => number = Date.now, cwd: string = process.cwd()) {\n this.now = now;\n this.cwd = cwd;\n this.file = join(cwd, dirname(options.jsonReporter?.fileName ?? \"reports/mutation/mutation.json\"), PARTIAL_FILE);\n mkdirSync(dirname(this.file), { recursive: true });\n writeFileSync(this.file, \"\");\n this.write({ event: \"start\", at: this.now() });\n }\n\n onMutationTestingPlanReady(event: { readonly mutantPlans: readonly { readonly plan: string }[] }): void {\n this.write({ event: \"plan\", at: this.now(), mutants: event.mutantPlans.length, run: event.mutantPlans.filter((p) => p.plan === \"Run\").length });\n }\n\n onMutantTested(result: TestedMutant): void {\n const file = relative(this.cwd, result.fileName).split(sep).join(\"/\");\n const reason = result.statusReason === undefined ? {} : { statusReason: result.statusReason };\n this.write({ event: \"mutant\", at: this.now(), file, status: result.status, ...reason, mutatorName: result.mutatorName, line: result.location.start.line });\n }\n\n onMutationTestReportReady(): void {\n this.write({ event: \"done\", at: this.now() });\n }\n\n // A synchronous append: a stop of the process loses no line of a mutant that was tested.\n private write(line: PartialLine): void {\n appendFileSync(this.file, `${JSON.stringify(line)}\\n`);\n }\n}\n\n/** The plugins of this module, in the form of `declareClassPlugin` of `@stryker-mutator/api/plugin`. */\nexport const strykerPlugins: readonly { readonly kind: \"Reporter\"; readonly name: string; readonly injectableClass: typeof PartialReporter }[] = [\n { kind: \"Reporter\", name: \"rigor-partial\", injectableClass: PartialReporter },\n];\n"],"mappings":";;;;;;;;AAQA,MAAa,eAAe;;AA2B5B,IAAa,kBAAb,MAA6B;CAC3B,OAAgB,SAAS,CA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. */
2
- export declare const PARTIAL_FILE = "partial.jsonl";
3
- /** A line of `partial.jsonl`. The field `at` gives the time in milliseconds since 1970. */
4
- export type PartialLine = {
5
- readonly event: "start";
6
- readonly at: number;
7
- } | {
8
- readonly event: "plan";
9
- readonly at: number;
10
- readonly mutants: number;
11
- readonly run: number;
12
- } | {
13
- readonly event: "mutant";
14
- readonly at: number;
15
- readonly file: string;
16
- readonly status: string;
17
- readonly statusReason?: string;
18
- readonly mutatorName: string;
19
- readonly line: number;
20
- } | {
21
- readonly event: "done";
22
- readonly at: number;
23
- };
24
- /** The parts of a Stryker mutant result that the reporter reads. */
25
- interface TestedMutant {
26
- readonly fileName: string;
27
- readonly status: string;
28
- readonly statusReason?: string;
29
- readonly mutatorName: string;
30
- readonly location: {
31
- readonly start: {
32
- readonly line: number;
33
- };
34
- };
35
- }
36
- /** The reporter. Stryker gives it its options, and `now` and `cwd` are for the tests. */
37
- export declare class PartialReporter {
38
- static readonly inject: readonly ["options"];
39
- readonly file: string;
40
- private readonly now;
41
- private readonly cwd;
42
- constructor(options: {
43
- readonly jsonReporter?: {
44
- readonly fileName?: string;
45
- };
46
- }, now?: () => number, cwd?: string);
47
- onMutationTestingPlanReady(event: {
48
- readonly mutantPlans: readonly {
49
- readonly plan: string;
50
- }[];
51
- }): void;
52
- onMutantTested(result: TestedMutant): void;
53
- onMutationTestReportReady(): void;
54
- private write;
55
- }
56
- /** The plugins of this module, in the form of `declareClassPlugin` of `@stryker-mutator/api/plugin`. */
57
- export declare const strykerPlugins: readonly {
58
- readonly kind: "Reporter";
59
- readonly name: string;
60
- readonly injectableClass: typeof PartialReporter;
61
- }[];
62
- export {};
63
- //# sourceMappingURL=reporter.d.ts.map
1
+ import { i as strykerPlugins, n as PartialLine, r as PartialReporter, t as PARTIAL_FILE } from "./reporter-CkdX8IPx.js";
2
+ export { PARTIAL_FILE, PartialLine, PartialReporter, strykerPlugins };
package/build/reporter.js CHANGED
@@ -1,66 +1 @@
1
- import { dirname, join, relative, sep } from "node:path";
2
- import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
3
- // src/reporter.ts
4
- /**
5
- * The Stryker reporter `rigor-partial`. It appends the plan and each tested mutant to `partial.jsonl`, next to the JSON
6
- * report, at the time of each event. When a time limit stops Stryker, `scores` reads this file for a partial score.
7
- */
8
- /** The name of the file of the reporter, in the folder of the JSON report. */
9
- const PARTIAL_FILE = "partial.jsonl";
10
- /** The reporter. Stryker gives it its options, and `now` and `cwd` are for the tests. */
11
- var PartialReporter = class {
12
- static inject = ["options"];
13
- file;
14
- now;
15
- cwd;
16
- constructor(options, now = Date.now, cwd = process.cwd()) {
17
- this.now = now;
18
- this.cwd = cwd;
19
- this.file = join(cwd, dirname(options.jsonReporter?.fileName ?? "reports/mutation/mutation.json"), PARTIAL_FILE);
20
- mkdirSync(dirname(this.file), { recursive: true });
21
- writeFileSync(this.file, "");
22
- this.write({
23
- event: "start",
24
- at: this.now()
25
- });
26
- }
27
- onMutationTestingPlanReady(event) {
28
- this.write({
29
- event: "plan",
30
- at: this.now(),
31
- mutants: event.mutantPlans.length,
32
- run: event.mutantPlans.filter((p) => p.plan === "Run").length
33
- });
34
- }
35
- onMutantTested(result) {
36
- const file = relative(this.cwd, result.fileName).split(sep).join("/");
37
- const reason = result.statusReason === void 0 ? {} : { statusReason: result.statusReason };
38
- this.write({
39
- event: "mutant",
40
- at: this.now(),
41
- file,
42
- status: result.status,
43
- ...reason,
44
- mutatorName: result.mutatorName,
45
- line: result.location.start.line
46
- });
47
- }
48
- onMutationTestReportReady() {
49
- this.write({
50
- event: "done",
51
- at: this.now()
52
- });
53
- }
54
- write(line) {
55
- appendFileSync(this.file, `${JSON.stringify(line)}\n`);
56
- }
57
- };
58
- /** The plugins of this module, in the form of `declareClassPlugin` of `@stryker-mutator/api/plugin`. */
59
- const strykerPlugins = [{
60
- kind: "Reporter",
61
- name: "rigor-partial",
62
- injectableClass: PartialReporter
63
- }];
64
- export { PARTIAL_FILE, PartialReporter, strykerPlugins };
65
-
66
- //# sourceMappingURL=reporter.js.map
1
+ export { t as PARTIAL_FILE, n as PartialReporter, r as strykerPlugins } from "./reporter-Cypwcaj9.js";