@mark1russell7/rigor-mutation 0.1.9 → 0.2.1

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
@@ -126,6 +126,10 @@ A score is a read of the tests only when the run read all of them. A run that re
126
126
  - `--test-files` compares the test files that the run starts with the test files of the report. A test file that the run starts and that the report does not read fails.
127
127
  - The Vitest runner of Stryker starts the test files that load a file of the selection, directly or through other files. So a part does not start the test files of the other parts.
128
128
  - The check reads the relative imports of the package, and not its type imports. With `vitest.related` false in the field `stryker`, it expects each test file.
129
+ - With no `--alone`, `--test-files` also examines each package whose selections the command names in full. This is the gate job, which reads all the parts.
130
+ - A test file on the disk that no report reads fails, unless `notRead` gives its reason. One part does not show such a file, because a part starts only its related test files.
131
+ - An entry of `notRead` fails when its file is not on the disk, or when a report reads it.
132
+ - The fault fails the score of the package with `"gateOver": "package"`. Else it fails each selection of the package.
129
133
 
130
134
  The lane states each exception with its reason:
131
135
 
@@ -152,6 +156,21 @@ packages/compiler/src/module-sheet.test.ts:12: "../../testkit/src/fc-timeout.ts"
152
156
 
153
157
  The check does not read comments, type imports and paths with a template expression.
154
158
 
159
+ With `--collect`, the Vitest of each package also loads each test file, as Stryker does. It starts the collect of Vitest in a new process, with `staticParse: false`. Then each file starts, so the check finds a missing package, also through a helper or a computed dynamic import. 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
+
166
+ On a fault, the check fails with a line that starts with `No read`. A score of that package is not a reading.
167
+
168
+ `--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.
169
+
170
+ ```text
171
+ rigor-mutation load-check --collect --runner reports/runner.json
172
+ ```
173
+
155
174
  ## The disabled mutants
156
175
 
157
176
  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-C9CTCYmS.js";
2
+ import { n as runCli } from "./run-DSF8ITXj.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,45 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ import { join, relative, resolve } from "node:path";
4
+ import { 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 <dir> <out> [<vitest config>]`. It loads the Vitest that the folder of the package resolves. That
10
+ * 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.
14
+ */
15
+ const [dir, out, config] = process.argv.slice(2);
16
+ if (dir === void 0 || out === void 0) throw new Error("collect.ts takes <dir> <out> [<vitest config>]");
17
+ const root = resolve(dir);
18
+ const entry = createRequire(join(root, "package.json")).resolve("vitest/node");
19
+ const vitestNode = await import(pathToFileURL(entry).href);
20
+ process.chdir(root);
21
+ const vitest = await vitestNode.createVitest("test", {
22
+ root,
23
+ watch: false,
24
+ ...config === void 0 ? {} : { config: resolve(root, config) }
25
+ });
26
+ try {
27
+ const { testModules, unhandledErrors } = await vitest.collect(void 0, { staticParse: false });
28
+ const collected = {
29
+ version: vitestNode.version,
30
+ path: realpathSync(entry).replaceAll("\\", "/"),
31
+ files: testModules.map((m) => ({
32
+ file: relative(root, m.moduleId).replaceAll("\\", "/"),
33
+ errors: m.errors().map((e) => e.message),
34
+ children: m.children.size
35
+ })),
36
+ unhandled: unhandledErrors.map((e) => e instanceof Error ? e.message : String(e))
37
+ };
38
+ writeFileSync(out, `${JSON.stringify(collected)}\n`);
39
+ process.exitCode = 0;
40
+ } finally {
41
+ await vitest.close();
42
+ }
43
+ export {};
44
+
45
+ //# 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 <dir> <out> [<vitest config>]`. It loads the Vitest that the folder of the package resolves. That\n * 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.\n */\nimport { 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 } from \"./load.ts\";\n\nconst [dir, out, config] = process.argv.slice(2);\nif (dir === undefined || out === undefined) throw new Error(\"collect.ts takes <dir> <out> [<vitest config>]\");\nconst root = resolve(dir);\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 vitest = await vitestNode.createVitest(\"test\", { root, watch: false, ...(config === undefined ? {} : { config: resolve(root, config) }) });\ntry {\n const { testModules, unhandledErrors } = await vitest.collect(undefined, { staticParse: false });\n const collected: Collected = {\n version: vitestNode.version,\n path: realpathSync(entry).replaceAll(\"\\\\\", \"/\"),\n files: testModules.map((m) => ({\n file: relative(root, m.moduleId).replaceAll(\"\\\\\", \"/\"),\n errors: m.errors().map((e) => e.message),\n children: m.children.size,\n })),\n unhandled: unhandledErrors.map((e) => (e instanceof Error ? e.message : String(e))),\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":";;;;;;;;;;;;;;AAeA,MAAM,CAAC,KAAK,KAAK,UAAU,QAAQ,KAAK,MAAM,CAAC;AAC/C,IAAI,QAAQ,KAAA,KAAa,QAAQ,KAAA,GAAW,MAAM,IAAI,MAAM,gDAAgD;AAC5G,MAAM,OAAO,QAAQ,GAAG;AAExB,MAAM,QAAQ,cAAc,KAAK,MAAM,cAAc,CAAC,CAAC,CAAC,QAAQ,aAAa;AAC7E,MAAM,aAAc,MAAM,OAAO,cAAc,KAAK,CAAC,CAAC;AACtD,QAAQ,MAAM,IAAI;AAClB,MAAM,SAAS,MAAM,WAAW,aAAa,QAAQ;CAAE;CAAM,OAAO;CAAO,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,MAAM,MAAM,EAAE;AAAG,CAAC;AAC/I,IAAI;CACF,MAAM,EAAE,aAAa,oBAAoB,MAAM,OAAO,QAAQ,KAAA,GAAW,EAAE,aAAa,MAAM,CAAC;CAC/F,MAAM,YAAuB;EAC3B,SAAS,WAAW;EACpB,MAAM,aAAa,KAAK,CAAC,CAAC,WAAW,MAAM,GAAG;EAC9C,OAAO,YAAY,KAAK,OAAO;GAC7B,MAAM,SAAS,MAAM,EAAE,QAAQ,CAAC,CAAC,WAAW,MAAM,GAAG;GACrD,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,MAAM,EAAE,OAAO;GACvC,UAAU,EAAE,SAAS;EACvB,EAAE;EACF,WAAW,gBAAgB,KAAK,MAAO,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAE;CACpF;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.
@@ -380,6 +380,31 @@ export declare function leavingPaths(files: readonly PackageFile[], vitestConfig
380
380
  * @param selected - the function that tells if a file is a file of the selection
381
381
  */
382
382
  export declare function relatedTestFiles(files: readonly PackageFile[], selected: (file: string) => boolean): string[];
383
+ /** A test file as the collect of Vitest gives it (`load-check --collect`). */
384
+ interface CollectedFile {
385
+ /** The file, with `/`. */
386
+ readonly file: string;
387
+ /** The messages of the errors of the file. A file that does not load has one or more. */
388
+ readonly errors: readonly string[];
389
+ /** The number of tests and suites at the top of the file. */
390
+ readonly children: number;
391
+ }
392
+ /** The collect of Vitest in the folder of a package. */
393
+ interface Collected {
394
+ /** The version of Vitest that the folder of the package resolves. */
395
+ readonly version: string;
396
+ /** The real path of the entry `vitest/node` that the folder resolves. */
397
+ readonly path: string;
398
+ readonly files: readonly CollectedFile[];
399
+ /** The messages of the errors outside a test file. */
400
+ readonly unhandled: readonly string[];
401
+ }
402
+ /**
403
+ * This function gives the reason of each fault of a collect. A test file that does not load gives no failed test, so
404
+ * each mutant that it detects survives (V-090 of Vex). A test file with no test detects no mutant. An error outside a
405
+ * test file and a package with no test file are faults too.
406
+ */
407
+ export declare function collectFaults(collected: Collected): string[];
383
408
  /** The input and the output of the CLI. */
384
409
  interface CliIo {
385
410
  readonly cwd: string;
@@ -392,5 +417,5 @@ interface CliIo {
392
417
  export declare const HELP: string;
393
418
  /** This function starts the CLI with its arguments and gives the exit code. */
394
419
  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 };
420
+ export { type CliIo, type Collected, type CollectedFile, 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
421
  //# 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;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;;;;;;wBAkE5B,YAAY,QAAQ,gBAAgB;WAAsB;WAAuB;IAA6B;;;;;;;;wBA4C9G,aAAa,cAAc,0BAA0B,gBAAgB,SAAS,8BAAkC;;wBA2BhH,YAAY,GAAG;;wBASf,gBAAgB,iBAAiB;;;;;;;UC1RhC;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;;;;;;;;;wBAqCpE,iBAAiB,gBAAgB,eAAe,WAAW;;UCtG1D;WACN;WACA,SAAS;WACT,SAAS;;WAET,MAAM,SAAS;;;qBAIb;;wBA0UG,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;;;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;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;;;;;;wBAkG5B,YAAY,QAAQ,gBAAgB;WAAsB;WAAuB;IAA6B;;;;;;;;wBA4C9G,aAAa,cAAc,0BAA0B,gBAAgB,SAAS,8BAAkC;;wBA2BhH,YAAY,GAAG;;wBASf,gBAAgB,iBAAiB;;;;;;;UC1ThC;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;;;;;;;;;wBAqCpE,iBAAiB,gBAAgB,eAAe,WAAW;;UA0B1D;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;WACA,gBAAgB;;WAEhB;;;;;;;wBAQK,cAAc,WAAW;;UCtJxB;WACN;WACA,SAAS;WACT,SAAS;;WAET,MAAM,SAAS;;;qBAIb;;wBAibG,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-C9CTCYmS.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 selectionNames, C as strykerConfig, D as partErrors, E as parseLane, O as runSelections, S as rewritesTsconfig, T as changedFiles, _ as DRY_RUN_TIMEOUT_MINUTES, a as leavingPaths, b as REPORT_DIR, c as findDisables, d as packageScore, f as parsePartial, g as summaryMarkdown, h as scoreReport, i as isConfigFile, k as select, l as formatScore, m as partialScore, n as runCli, o as relatedTestFiles, p as parseReport, r as collectFaults, s as compareDisables, t as HELP, u as isHitLimit, v as NO_TSCONFIG, w as STRYKER_OWNED, x as TIMEOUT_MS, y as PARTIAL_PLUGIN } from "./run-DSF8ITXj.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, 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,CAAC,SAAS;CACnC;CACA;CACA;CAEA,YAAY,SAAqE,MAAoB,KAAK,KAAK,MAAc,QAAQ,IAAI,GAAG;EAC1I,KAAK,MAAM;EACX,KAAK,MAAM;EACX,KAAK,OAAO,KAAK,KAAK,QAAQ,QAAQ,cAAc,YAAY,gCAAgC,GAAG,YAAY;EAC/G,UAAU,QAAQ,KAAK,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;EACjD,cAAc,KAAK,MAAM,EAAE;EAC3B,KAAK,MAAM;GAAE,OAAO;GAAS,IAAI,KAAK,IAAI;EAAE,CAAC;CAC/C;CAEA,2BAA2B,OAA6E;EACtG,KAAK,MAAM;GAAE,OAAO;GAAQ,IAAI,KAAK,IAAI;GAAG,SAAS,MAAM,YAAY;GAAQ,KAAK,MAAM,YAAY,QAAQ,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC;EAAO,CAAC;CAChJ;CAEA,eAAe,QAA4B;EACzC,MAAM,OAAO,SAAS,KAAK,KAAK,OAAO,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;EACpE,MAAM,SAAS,OAAO,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc,OAAO,aAAa;EAC5F,KAAK,MAAM;GAAE,OAAO;GAAU,IAAI,KAAK,IAAI;GAAG;GAAM,QAAQ,OAAO;GAAQ,GAAG;GAAQ,aAAa,OAAO;GAAa,MAAM,OAAO,SAAS,MAAM;EAAK,CAAC;CAC3J;CAEA,4BAAkC;EAChC,KAAK,MAAM;GAAE,OAAO;GAAQ,IAAI,KAAK,IAAI;EAAE,CAAC;CAC9C;CAGA,MAAc,MAAyB;EACrC,eAAe,KAAK,MAAM,GAAG,KAAK,UAAU,IAAI,EAAE,GAAG;CACvD;AACF;;AAGA,MAAa,iBAAoI,CAC/I;CAAE,MAAM;CAAY,MAAM;CAAiB,iBAAiB;AAAgB,CAC9E"}
@@ -1,63 +1,2 @@
1
- /** The name of the file of the reporter, in the folder of the JSON report. */
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";