@mark1russell7/rigor-mutation 0.2.2 → 0.2.4

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
@@ -45,8 +45,14 @@ The lane file `mutation.json` is at the root of the repository:
45
45
  - `dryRunTimeoutMinutes` is the time in minutes for the run of the tests without mutants. The default is 15.
46
46
  - `stryker` has more options for the Stryker config of each selection of the package, for example `{ "ignoreStatic": true }`. Its keys replace the keys of the config, but `--concurrency` replaces its `concurrency`. The lane owns `mutate`, `thresholds`, `jsonReporter`, `htmlReporter`, `timeoutMS` and `dryRunTimeoutMinutes`, so `stryker` cannot have them.
47
47
  - `disables` (at the root of the lane) names the list of the disabled mutants. The default is `mutation-disables.json`.
48
+ - `staticLimits` gives the most static runs of each file of the package, from the folder where Stryker starts. The key `*` gives the limit of the other files. `plan-check` reads it.
49
+ - `targetMinutes` (at the root of the lane) is the target of the estimate of each selection, in minutes. The default is 100.
50
+ - `stopMinutes` (at the root of the lane) is the stop of the estimate of each selection, in minutes. The default is 140. It is not less than `targetMinutes`.
51
+ - `planPerClock` (at the root of the lane) is the planned net time of one minute of the clock. The default is 9.8, from a nightly run of Vex.
52
+ - `cuts` gives groups of files that the cost maps cut into numbered parts. A group has its globs in `files` and its count of parts in `count`. The globs have no line range.
53
+ - `costs` (at the root of the lane) names the file of the cost maps, from the folder of the lane file.
48
54
 
49
- A selection is one Stryker run: a package (`collections`) or a part (`collections.impl`). `rigor-mutation list --runs` gives the selections of a full run: the parts of each package with parts, else the package.
55
+ A selection is one Stryker run: a package (`collections`), a part (`collections.impl`) or a numbered part of a group (`collections.base.2`). `rigor-mutation list --runs` gives the selections of a full run: the parts of each package with parts, else the package.
50
56
 
51
57
  A full run mutates only the files of the parts. Thus a file in no part has no score, and a file in two parts has two scores. `list --runs`, and `config` and `scores` of a part, examine the source files of the package. They fail and name each file that is in no part, in two parts, or in a part but not in `mutate`. For a file in line ranges, they name each gap and each overlap of the ranges, and the lines after the last range. In the example, a file `src/util.ts` is in no part, so the lane fails.
52
58
 
@@ -93,6 +99,59 @@ A partial score is a no read, because it does not read all the mutants. Its fiel
93
99
 
94
100
  The workflow `stryker-stop.yml` checks the reporter in a real run. It stops Stryker on the fixture lane `test/stryker/mutation.json` and examines the partial score.
95
101
 
102
+ ### The cost plan
103
+
104
+ After the run of the tests without mutants, Stryker makes a plan of the mutants. The reporter `rigor-partial` writes it to `plan.json`, next to `mutation.json`:
105
+
106
+ - `files` gives the plan of each file: its mutants, the runs, the static runs, the planned net time and the time limits in milliseconds. `lines` gives the runs, the static runs and the net time of each line.
107
+ - `tests` gives the 40 tests of the largest cost. The cost of a test is its time, times the runs that start it.
108
+
109
+ Each line of a mutant in `partial.jsonl` also gives its planned net time and its time limit.
110
+
111
+ `rigor-mutation config <selection> --plan` gives a config that stops Stryker after the plan. Stryker starts no mutant, so the plan costs only the run of the tests.
112
+
113
+ `rigor-mutation plan-check <selection>...` reads the plan of each selection. It gives the estimate of the clock. It gives a warning when the estimate is over `targetMinutes`, and in GitHub Actions also a warning annotation. The estimate has an error of 28 minutes in the mean, so the target does not fail. These conditions fail a selection:
114
+
115
+ - The estimate is over `stopMinutes`. Stryker cannot end the selection before the stop, so it cannot give a full score.
116
+ - A file has more static runs than its limit in `staticLimits`.
117
+
118
+ A static run starts each test, so it costs the time of all the tests. Code outside a function gives a static mutant.
119
+
120
+ ```text
121
+ vex.kernel: 812 runs, 3 of them static, with a planned net time of 12.4 h. The estimate is 76 minutes of the clock, the target is 100 and the stop is 140.
122
+ plan-check: each plan of 1 selections is in its limits
123
+ ```
124
+
125
+ `--report <file>` reads the plan of one selection from a file. `--reports <dir>` reads `<dir>/mutation-<selection>/plan.json`. The workflow `stryker-stop.yml` checks the plan in a real run.
126
+
127
+ ### The cut by cost
128
+
129
+ A group of `cuts` gives the numbered parts `<group>.1` to `<group>.<count>`. A full run reads these parts. The selection `<group>` mutates the full group. A group with the count 1 is one part. For the cover of the files, a group is a part.
130
+
131
+ ```json
132
+ {
133
+ "packages": { "vex": { "dir": "packages/core", "mutate": ["src/**/*.ts", "!src/**/*.test.ts"], "cuts": { "base": { "files": ["src/**/*.ts"], "count": 4 } } } },
134
+ "costs": "mutation-costs.json"
135
+ }
136
+ ```
137
+
138
+ The cut follows the cost maps of the lane:
139
+
140
+ - The files of a group follow one another in the order of their paths.
141
+ - A segment of a file ends on a closing line: a `}` with an indent of 0 to 2 spaces. Its key is the name of its first declaration.
142
+ - A cost map gives the planned net time of each segment of a file. A segment spreads its cost over its lines.
143
+ - A new segment has the mean cost of a line of its file. A file with no map has the mean cost of a line of its group. With no map, each line has the weight 1.
144
+ - A part ends on a closing line or at the end of a file. Thus a mutant of the body of a method stays in one part.
145
+ - Of all cuts, the cut has the smallest largest part. Of these cuts, it has the smallest sum of squares.
146
+
147
+ The cut reads only the files on the disk and the cost maps. Thus each job of a run gets the same parts.
148
+
149
+ `rigor-mutation costs <run> --reports <dir>` writes the cost maps from the plans of the run `<run>`. It reads `<dir>/mutation-<selection>/plan.json` of each selection. It adds the plan lines of a file over the parts, and a file with no plan line gets a map of 0. The maps of the other files stay. Write the maps again after a large change of a file or of its tests, and commit them.
150
+
151
+ `rigor-mutation cost-check [<selection>...]` gives the estimate of the clock of each numbered part under the committed maps. A part over `targetMinutes` fails, and so does a group with no map. The check reads no plan, so each commit gives one result. Thus a check of the pull request can hold each part under its target.
152
+
153
+ `rigor-mutation minutes` gives `target=<minutes>` and `stop=<minutes>` for `GITHUB_OUTPUT`. Thus a workflow can stop Stryker at `stopMinutes` of the lane, and the lane is the one source of the stop.
154
+
96
155
  ## The score
97
156
 
98
157
  The score counts the detected mutants, out of the mutants that a test covers or that survive. Compile errors, runtime errors and ignored mutants do not count.
@@ -196,4 +255,4 @@ const score = scoreReport(parseReport(JSON.parse(reportText)), selection);
196
255
  console.log(formatScore(score)); // collections.impl: 91.20 % (456 of 500, 44 survived), gate 80 %: pass
197
256
  ```
198
257
 
199
- The package also exports `selectionNames`, `runSelections`, `summaryMarkdown`, `findDisables`, `compareDisables`, `leavingPaths`, `relatedTestFiles`, `isConfigFile`, `testCount`, `testFall`, `unreadTestFiles`, `failScore` and `runCli`.
258
+ The package also exports `selectionNames`, `runSelections`, `packageRuns`, `summaryMarkdown`, `findDisables`, `compareDisables`, `leavingPaths`, `relatedTestFiles`, `isConfigFile`, `testCount`, `testFall`, `unreadTestFiles`, `failScore` and `runCli`. The cut by cost has the exports `cutByCost`, `costMapOf`, `segmentsOf`, `lineWeights`, `weightedFiles`, `plannedMs` and `parseCostMaps`.
package/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as runCli } from "./run-BvctkYlJ.js";
2
+ import { n as runCli } from "./run-B6T7az_y.js";
3
3
  // src/cli.ts
4
4
  try {
5
5
  process.exitCode = runCli(process.argv.slice(2), {
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as PartialLine, r as PartialReporter, t as PARTIAL_FILE } from "./reporter-CkdX8IPx.js";
1
+ import { C as staticFaults, S as readPlan, _ as TestOfDryRun, b as filePlans, c as LinePlan, d as PlanLimits, f as PlanOfMutant, g as TARGET_MINUTES, h as SelectionPlan, i as ReporterOptions, l as PLAN_FILE, m as STOP_MINUTES, n as PartialLine, p as PlanRead, r as PartialReporter, s as FilePlan, t as PARTIAL_FILE, u as PLAN_PER_CLOCK, v as TestPlan, w as testPlans, x as parsePlan, y as clockMinutes } from "./reporter-BS3LIodv.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.
@@ -49,6 +49,21 @@ interface PackageLane {
49
49
  * of Vitest does not follow this type of import. `load-check --collect` fails for each other file of the run with one.
50
50
  */
51
51
  readonly computedImports?: Readonly<Record<string, string>>;
52
+ /**
53
+ * This field gives the most static runs in the plan of each file, from `dir`. The key `*` gives the limit of each other
54
+ * file. A static run starts each test. `plan-check` fails a file over its limit.
55
+ */
56
+ readonly staticLimits?: Readonly<Record<string, number>>;
57
+ /**
58
+ * Each group of this field has its globs and a count of parts. The cost maps of the lane cut the files of the group
59
+ * into the parts `<group>.1` to `<group>.<count>`. A group is a part for `partErrors`. Its globs have no line range.
60
+ */
61
+ readonly cuts?: Readonly<Record<string, CutGroup>>;
62
+ }
63
+ /** A group of files that the cost maps cut into `count` parts of near the same planned net time. */
64
+ interface CutGroup {
65
+ readonly files: readonly string[];
66
+ readonly count: number;
52
67
  }
53
68
  /** The keys of the Stryker config that the lane owns. The field `stryker` of a package cannot have them. */
54
69
  export declare const STRYKER_OWNED: readonly string[];
@@ -64,6 +79,14 @@ interface Lane {
64
79
  readonly maxTestFall?: number;
65
80
  /** Each selection of this field can have a higher fall of its test count. The value gives the reason. */
66
81
  readonly plannedFalls?: Readonly<Record<string, string>>;
82
+ /** This field gives the planned net time of one minute of the clock, for the estimate of `plan-check`. The default is 9.8. */
83
+ readonly planPerClock?: number;
84
+ /** This field gives the target of the estimate of a selection, in minutes. `plan-check` warns of a selection over it. The default is 100. */
85
+ readonly targetMinutes?: number;
86
+ /** This field gives the stop of the estimate of a selection, in minutes. `plan-check` fails a selection over it. The default is 140. */
87
+ readonly stopMinutes?: number;
88
+ /** This field gives the file of the cost maps, from the folder of the lane file. Without it, each line of a group has the weight 1. */
89
+ readonly costs?: string;
67
90
  }
68
91
  /** A selection is one Stryker run: a package (`collections`) or a part of a package (`collections.impl`). */
69
92
  interface Selection {
@@ -76,23 +99,45 @@ interface Selection {
76
99
  readonly timeoutMS: number | undefined;
77
100
  readonly dryRunTimeoutMinutes: number | undefined;
78
101
  readonly stryker: Readonly<Record<string, unknown>> | undefined;
102
+ /** A numbered part of a group of `cuts` has its group, the count of parts and its index from 0. */
103
+ readonly cut?: CutPart;
79
104
  }
105
+ /** The place of a numbered part in its group of `cuts`. */
106
+ interface CutPart {
107
+ readonly group: string;
108
+ readonly count: number;
109
+ readonly index: number;
110
+ }
111
+ /**
112
+ * This function gives the entries of `mutate` of a numbered part of a group, from the cut of the group by cost. The
113
+ * CLI reads the files and the cost maps. The globs are the globs of the group, with the `!` globs of the package.
114
+ */
115
+ type CutOf = (pkg: string, cut: CutPart, globs: readonly string[]) => readonly string[];
80
116
  /**
81
117
  * This function examines the JSON of a lane file and gives the lane.
82
118
  *
83
119
  * @throws Error with each problem of the file
84
120
  */
85
121
  export declare function parseLane(json: unknown): Lane;
86
- /** This function gives the names of all the selections of a lane: each package, then each part of the package. */
122
+ /**
123
+ * This function gives the names of all the selections of a lane. These are each package, each part of the package,
124
+ * and each group of `cuts` of the package with its numbered parts.
125
+ */
87
126
  export declare function selectionNames(lane: Lane): string[];
88
- /** This function gives the selections of a full run: the parts of each package with parts, else the package. Each file is in one run. */
127
+ /**
128
+ * This function gives the selections of a full run. These are the parts and the numbered parts of each package with
129
+ * parts or groups, else the package. Each file is in one run.
130
+ */
89
131
  export declare function runSelections(lane: Lane): string[];
132
+ /** This function gives the selections of a full run of one package: its parts and numbered parts, else the package. */
133
+ export declare function packageRuns(lane: Lane, pkg: string): string[];
90
134
  /**
91
- * This function gives the selection of a name: a package, or a part of a package.
135
+ * This function gives the selection of a name. The name is a package, a part, a group of `cuts` or a numbered part of a
136
+ * group. A numbered part mutates the entries that `cutOf` gives. Without `cutOf`, it mutates its full group.
92
137
  *
93
- * @throws Error when the lane has no package or part of that name
138
+ * @throws Error when the lane has no selection of that name
94
139
  */
95
- export declare function select(lane: Lane, name: string): Selection;
140
+ export declare function select(lane: Lane, name: string, cutOf?: CutOf): Selection;
96
141
  /**
97
142
  * This function gives the changed files of a selection, from the folder of its package. The globs of the selection
98
143
  * select the files. A file that the selection takes in line ranges gives one entry for each range, `src/a.ts:1-300`.
@@ -114,6 +159,65 @@ export declare function changedFiles(selection: Selection, changed: readonly str
114
159
  * @param lines - this function gives the number of lines of a file of `files`
115
160
  */
116
161
  export declare function partErrors(lane: Lane, pkg: string, files: readonly string[], lines?: (file: string) => number): string[];
162
+ /** A segment of a text: a run of lines that ends on a closing line, with the name of its first declaration. */
163
+ interface Segment {
164
+ readonly key: string;
165
+ /** The first line of the segment, counted from 1. */
166
+ readonly start: number;
167
+ /** The last line of the segment, counted from 1. */
168
+ readonly end: number;
169
+ }
170
+ /**
171
+ * This function cuts a text into segments. Each segment ends on a closing line, and the last segment ends on the last
172
+ * line. The key of a segment is the name of its first declaration, with `#2` for the second segment of that name. A
173
+ * segment with no name has the key `@n`. A key thus stays the same when a change moves the lines.
174
+ */
175
+ export declare function segmentsOf(text: string): Segment[];
176
+ /** The cost map of a file: the planned net time of each segment in milliseconds, from the plan of a run. */
177
+ interface CostMap {
178
+ /** The run that gave the plan. */
179
+ readonly run: string;
180
+ readonly segments: Readonly<Record<string, number>>;
181
+ }
182
+ /** The cost maps of a lane: a map for each file, by the name of its package and its path from the package folder. */
183
+ type CostMaps = Readonly<Record<string, Readonly<Record<string, CostMap>>>>;
184
+ /** This function gives the cost map of a text from the plan of its lines: the planned net time of each segment. */
185
+ export declare function costMapOf(text: string, run: string, lines: readonly LinePlan[]): CostMap;
186
+ /**
187
+ * This function gives the weight of each line of a text from a cost map. A segment spreads its cost over its lines. A
188
+ * segment that the map does not name has the mean cost of a line of the named segments. Thus a new function has a cost.
189
+ */
190
+ export declare function lineWeights(text: string, map: CostMap): number[];
191
+ /** A file of a group: its path from the folder of its package, its lines, and the weight of each line. */
192
+ interface WeightedFile {
193
+ readonly path: string;
194
+ readonly lines: readonly string[];
195
+ readonly weights: readonly number[];
196
+ }
197
+ /**
198
+ * This function gives the weight of each line of each file from the cost maps of its package. A file with no map has
199
+ * the mean weight of a line of the files with a map, so a new file has a cost. With no map, each line has the weight 1.
200
+ */
201
+ export declare function weightedFiles(texts: readonly {
202
+ readonly path: string;
203
+ readonly text: string;
204
+ }[], maps?: Readonly<Record<string, CostMap>>): WeightedFile[];
205
+ /**
206
+ * This function cuts the files of a group into `count` parts of near the same weight. It gives the entries of `mutate`
207
+ * of each part. The files follow one another in their order. A part ends on the closing line of a method, or on the last
208
+ * line of a file. A part holds whole files, and a range of lines of a file at each end. Each input gives one result.
209
+ *
210
+ * @throws Error when the files have fewer end lines than the count of parts needs
211
+ */
212
+ export declare function cutByCost(files: readonly WeightedFile[], count: number): string[][];
213
+ /** This function gives the planned net time of the entries of a part in milliseconds: the sum of the weights of their lines. */
214
+ export declare function plannedMs(entries: readonly string[], files: readonly WeightedFile[]): number;
215
+ /**
216
+ * This function reads the JSON of a file of cost maps.
217
+ *
218
+ * @throws Error when the JSON is not an object of packages, each an object of files, each with a run and segments
219
+ */
220
+ export declare function parseCostMaps(json: unknown): CostMaps;
117
221
  /** The options of `strykerConfig`. */
118
222
  interface ConfigOptions {
119
223
  /** This option gives the number of test processes. The default is 2. */
@@ -125,6 +229,11 @@ interface ConfigOptions {
125
229
  * test. Use it to see if the tests pass under Stryker before a long run.
126
230
  */
127
231
  readonly dryRun?: boolean;
232
+ /**
233
+ * When this option is true, Stryker starts the tests without mutants and makes its plan. The reporter `rigor-partial`
234
+ * writes the plan into `plan.json` and stops Stryker. No mutant runs. `plan-check` reads the plan.
235
+ */
236
+ readonly plan?: boolean;
128
237
  /**
129
238
  * When this option is false, Stryker does not rewrite the tsconfig of the package in its sandbox. The default is true.
130
239
  * The rewrite uses `parseConfigFileTextToJson`, and TypeScript 7 does not have it. Refer to `rewritesTsconfig`.
@@ -159,6 +268,9 @@ interface StrykerConfig {
159
268
  readonly tsconfigFile?: string;
160
269
  readonly dryRunOnly?: true;
161
270
  readonly disableBail?: true;
271
+ readonly rigorPartial?: {
272
+ readonly stopAfterPlan: true;
273
+ };
162
274
  }
163
275
  /**
164
276
  * The file URL of the module of the reporter `rigor-partial`: the source in the workspace, the build in the package of
@@ -440,5 +552,5 @@ interface CliIo {
440
552
  export declare const HELP: string;
441
553
  /** This function starts the CLI with its arguments and gives the exit code. */
442
554
  export declare function runCli(argv: readonly string[], io: CliIo): number;
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 };
555
+ export { type CliIo, type Collected, type CollectedFile, type ComputedImport, type ConfigOptions, type CostMap, type CostMaps, type CutGroup, type CutOf, type CutPart, type Disable, type DisableCheck, type FilePlan, type Lane, type LeavingPath, type LinePlan, type Mutant, type MutationReport, PARTIAL_FILE, PLAN_FILE, PLAN_PER_CLOCK, type PackageFile, type PackageLane, type PartialCosts, type PartialLine, PartialReporter, type PartialRun, type PlanLimits, type PlanOfMutant, type PlanRead, type ReporterOptions, STOP_MINUTES, type Score, type ScoreOutcome, type Segment, type Selection, type SelectionPlan, type StrykerConfig, TARGET_MINUTES, type TestOfDryRun, type TestPlan, type WeightedFile, clockMinutes, filePlans, parsePlan, readPlan, staticFaults, testPlans };
444
556
  //# 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;;;;;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;;;;;;;;;;;;wBAkD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C3B,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"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/lane.ts","../src/cut.ts","../src/config.ts","../src/score.ts","../src/disables.ts","../src/load.ts","../src/run.ts"],"mappings":";;;;;;UASiB;;WAEN;;;;;WAKA;;;;;;WAMA,QAAQ,SAAS;;WAEjB;;;;;WAKA;;WAEA;;;;;WAKA;;WAEA;;;;;WAKA,UAAU,SAAS;;;;;WAKnB,UAAU,SAAS;;;;;WAKnB,kBAAkB,SAAS;;;;;WAK3B,eAAe,SAAS;;;;;WAKxB,OAAO,SAAS,eAAe;;;UAIzB;WACN;WACA;;;qBAIE;;UAGI;WACN,UAAU,SAAS,eAAe;;WAElC;;;;;WAKA;;WAEA,eAAe,SAAS;;WAExB;;WAEA;;WAEA;;WAEA;;;UAOM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,SAAS,SAAS;;WAElB,MAAM;;;UAIA;WACN;WACA;WACA;;;;;;KAOC,SAAS,aAAa,KAAK,SAAS;;;;;;wBA8EhC,UAAU,gBAAgB;;;;;wBAmC1B,eAAe,MAAM;;;;;wBAYrB,cAAc,MAAM;;wBASpB,YAAY,MAAM,MAAM;;;;;;;wBAUxB,OAAO,MAAM,MAAM,cAAc,QAAQ,QAAQ;;;;;;;;;wBAuEjD,aAAa,WAAW,WAAW,4BAA4B,UAAS;;;;;;;;;;;;wBAkDxE,WAAW,MAAM,MAA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AAY,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;;UCrMxB;WACN;WACA,SAAS;WACT,SAAS;;WAET,MAAM,SAAS;;;qBAIb;;wBA2oBG,OAAO,yBAAyB,IAAI"}
package/build/index.js CHANGED
@@ -1,3 +1,3 @@
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 };
1
+ import { a as PLAN_FILE, c as TARGET_MINUTES, d as parsePlan, f as readPlan, l as clockMinutes, m as testPlans, n as PartialReporter, o as PLAN_PER_CLOCK, p as staticFaults, s as STOP_MINUTES, t as PARTIAL_FILE, u as filePlans } from "./reporter-BYC384h-.js";
2
+ import { A as segmentsOf, C as rewritesTsconfig, D as lineWeights, E as cutByCost, F as parseLane, I as partErrors, L as runSelections, M as STRYKER_OWNED, N as changedFiles, O as parseCostMaps, P as packageRuns, R as select, S as TIMEOUT_MS, T as costMapOf, _ 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 weightedFiles, k as plannedMs, 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, z as selectionNames } from "./run-B6T7az_y.js";
3
+ export { DRY_RUN_TIMEOUT_MINUTES, HELP, NO_TSCONFIG, PARTIAL_FILE, PARTIAL_PLUGIN, PLAN_FILE, PLAN_PER_CLOCK, PartialReporter, REPORT_DIR, STOP_MINUTES, STRYKER_OWNED, TARGET_MINUTES, TIMEOUT_MS, changedFiles, clockMinutes, collectFaults, compareDisables, computedImports, costMapOf, cutByCost, filePlans, findDisables, formatScore, isConfigFile, isHitLimit, leavingPaths, lineWeights, packageRuns, packageScore, parseCostMaps, parseLane, parsePartial, parsePlan, parseReport, partErrors, partialScore, plannedMs, readPlan, relatedTestFiles, rewritesTsconfig, runCli, runSelections, scoreReport, segmentsOf, select, selectionNames, staticFaults, strykerConfig, summaryMarkdown, testPlans, weightedFiles };
@@ -0,0 +1,219 @@
1
+ /**
2
+ * The cost plan of a selection. Stryker makes a plan of the mutants after the run of the tests without mutants. The
3
+ * reporter `rigor-partial` writes the plan of each file and each line into `plan.json`. `plan-check` reads the file and
4
+ * gives the estimate of the clock of the selection. It warns of a selection over its target. It fails a selection over
5
+ * its stop, and a file over its limit of static runs. The cut of the parts can then follow the cost of the lines, and
6
+ * not the size of the files.
7
+ */
8
+ /** The name of the file of the plan, in the folder of the JSON report. */
9
+ declare const PLAN_FILE = "plan.json";
10
+ /**
11
+ * The default planned net time of one minute of the clock. In a nightly run of Vex (GitHub Actions, 2 test processes),
12
+ * the mutants that ended had 9.8 to 11.7 times the planned time of their clock. The lower value gives the longer estimate.
13
+ */
14
+ declare const PLAN_PER_CLOCK = 9.8;
15
+ /** The default target of the estimate of a selection, in minutes. A slow runner then ends a job of 150 minutes. */
16
+ declare const TARGET_MINUTES = 100;
17
+ /**
18
+ * The default stop of the estimate of a selection, in minutes. A selection over it does not end before the limit of the
19
+ * job, so it cannot give a full score. The estimate has an error of 28 minutes in the mean, so the target only warns.
20
+ */
21
+ declare const STOP_MINUTES = 140;
22
+ /** The parts of a plan of Stryker for one mutant that the reporter reads. */
23
+ interface PlanOfMutant {
24
+ readonly plan: string;
25
+ readonly mutant: {
26
+ readonly id: string;
27
+ readonly fileName: string;
28
+ readonly static?: boolean;
29
+ /** The start of the mutant. In a plan, Stryker counts the lines from 0. */
30
+ readonly location?: {
31
+ readonly start: {
32
+ readonly line: number;
33
+ };
34
+ };
35
+ };
36
+ readonly netTime?: number;
37
+ /** The tests that Stryker starts for the mutant. With no filter, Stryker starts all tests, as for a static mutant. */
38
+ readonly runOptions?: {
39
+ readonly timeout?: number;
40
+ readonly testFilter?: readonly string[];
41
+ };
42
+ }
43
+ /** The parts of a test of the run without mutants that the reporter reads. */
44
+ interface TestOfDryRun {
45
+ readonly id: string;
46
+ readonly name: string;
47
+ readonly fileName?: string;
48
+ readonly timeSpentMs: number;
49
+ }
50
+ /** The plan of one line: the line from 1, the runs that start on it, the static runs of them, and their planned net time. */
51
+ type LinePlan = readonly [line: number, runs: number, staticRuns: number, netMs: number];
52
+ /** The plan of one file of a selection. */
53
+ interface FilePlan {
54
+ /** The mutants of the file, with the mutants that have an early result. */
55
+ readonly mutants: number;
56
+ readonly runs: number;
57
+ readonly static: number;
58
+ readonly netMs: number;
59
+ readonly limitMs: number;
60
+ /** The plan of each line with a run, in the order of the lines. */
61
+ readonly lines: readonly LinePlan[];
62
+ }
63
+ /** The plan of one test: its name, its file, its time without mutants, the runs that start it, and their product. */
64
+ type TestPlan = readonly [name: string, file: string, ms: number, runs: number, costMs: number];
65
+ /** The content of `plan.json`. The paths of the files are from the folder where Stryker starts. */
66
+ interface SelectionPlan {
67
+ readonly files: Readonly<Record<string, FilePlan>>;
68
+ readonly tests: readonly TestPlan[];
69
+ }
70
+ /** This function gives the plan of each file: its mutants, the mutants that Stryker starts, and their planned times. */
71
+ declare function filePlans(plans: readonly PlanOfMutant[], path?: (fileName: string) => string): Record<string, FilePlan>;
72
+ /**
73
+ * This function gives the tests of the largest planned cost, the largest first. The cost of a test is its time without
74
+ * mutants, times the runs that start it. A test with a large cost is the first place to make the selection faster.
75
+ */
76
+ declare function testPlans(plans: readonly PlanOfMutant[], tests: readonly TestOfDryRun[], path?: (fileName: string) => string, top?: number): TestPlan[];
77
+ /** This function gives the estimate of the minutes of the clock of a planned net time. */
78
+ declare function clockMinutes(netMs: number, planPerClock?: number): number;
79
+ /** The read of the plan of a selection. */
80
+ interface PlanRead {
81
+ readonly runs: number;
82
+ readonly static: number;
83
+ readonly netMs: number;
84
+ /** The estimate of the clock of the selection, in minutes. */
85
+ readonly minutes: number;
86
+ /** One line for a selection over its stop, and one for each file over its limit of static runs. */
87
+ readonly faults: readonly string[];
88
+ /** One line for a selection over its target and under its stop. */
89
+ readonly warnings: readonly string[];
90
+ /** The line of the plan of the selection, with its estimate. */
91
+ readonly line: string;
92
+ }
93
+ /** The limits of the read of a plan. */
94
+ interface PlanLimits {
95
+ readonly planPerClock?: number;
96
+ readonly targetMinutes?: number;
97
+ readonly stopMinutes?: number;
98
+ /** The most static runs of each file. The key `*` gives the limit of each file that the field does not name. */
99
+ readonly staticLimits?: Readonly<Record<string, number>>;
100
+ }
101
+ /**
102
+ * This function gives the faults of the static runs of a plan. A static run starts each test, so it costs the time of
103
+ * all tests. Code outside a function gives a static mutant.
104
+ */
105
+ declare function staticFaults(files: Readonly<Record<string, FilePlan>>, limits?: Readonly<Record<string, number>>): string[];
106
+ /** This function reads the plan of a selection: its estimate of the clock, against the target and the stop, and its static runs. */
107
+ declare function readPlan(name: string, plan: SelectionPlan, limits?: PlanLimits): PlanRead;
108
+ /**
109
+ * This function reads the JSON of `plan.json`.
110
+ *
111
+ * @throws Error when the JSON has no object `files` or no list `tests`
112
+ */
113
+ declare function parsePlan(json: unknown): SelectionPlan;
114
+ /** The name of the file of the reporter, in the folder of the JSON report. */
115
+ declare const PARTIAL_FILE = "partial.jsonl";
116
+ /** A line of `partial.jsonl`. The field `at` gives the time in milliseconds since 1970. */
117
+ type PartialLine = {
118
+ readonly event: "start";
119
+ readonly at: number;
120
+ } | {
121
+ readonly event: "plan";
122
+ readonly at: number;
123
+ readonly mutants: number;
124
+ readonly run: number;
125
+ } | {
126
+ readonly event: "mutant";
127
+ readonly at: number;
128
+ readonly file: string;
129
+ readonly status: string;
130
+ readonly statusReason?: string;
131
+ readonly mutatorName: string;
132
+ readonly line: number;
133
+ /** The planned net time of the mutant in milliseconds. A mutant with an early result has none. */
134
+ readonly netMs?: number;
135
+ /** The time limit of the mutant in milliseconds. A mutant that the clock stops costs this time. */
136
+ readonly limitMs?: number;
137
+ readonly static?: boolean;
138
+ } | {
139
+ readonly event: "done";
140
+ readonly at: number;
141
+ };
142
+ /** The parts of a Stryker mutant result that the reporter reads. */
143
+ interface TestedMutant {
144
+ readonly id?: string;
145
+ readonly fileName: string;
146
+ readonly status: string;
147
+ readonly statusReason?: string;
148
+ readonly mutatorName: string;
149
+ readonly location: {
150
+ readonly start: {
151
+ readonly line: number;
152
+ };
153
+ };
154
+ }
155
+ /** The options of Stryker that the reporter reads. */
156
+ interface ReporterOptions {
157
+ readonly jsonReporter?: {
158
+ readonly fileName?: string;
159
+ };
160
+ /** With `stopAfterPlan` at true, the reporter stops Stryker after it writes the plan, before the first mutant. */
161
+ readonly rigorPartial?: {
162
+ readonly stopAfterPlan?: boolean;
163
+ };
164
+ }
165
+ /** The reporter. Stryker gives it its options, and `now`, `cwd` and `exit` are for the tests. */
166
+ declare class PartialReporter {
167
+ static readonly inject: readonly ["options"];
168
+ readonly file: string;
169
+ /** The file of the cost plan, in the folder of the JSON report. */
170
+ readonly planFile: string;
171
+ private readonly now;
172
+ private readonly cwd;
173
+ private readonly exit;
174
+ private readonly stopAfterPlan;
175
+ private tests;
176
+ private runs;
177
+ constructor(options: ReporterOptions, now?: () => number, cwd?: string, exit?: (code: number) => void);
178
+ onDryRunCompleted(event: {
179
+ readonly result: {
180
+ readonly tests: readonly TestOfDryRun[];
181
+ };
182
+ }): void;
183
+ onMutationTestingPlanReady(event: {
184
+ readonly mutantPlans: readonly PlanOfMutant[];
185
+ }): void;
186
+ onMutantTested(result: TestedMutant): void;
187
+ onMutationTestReportReady(): void;
188
+ /** This function gives the path of a file from the folder where Stryker starts, with `/`. */
189
+ private readonly path;
190
+ private write;
191
+ }
192
+ /** The schema of the option of the reporter. Stryker adds it to its own schema, so the option gives no warning. */
193
+ declare const strykerValidationSchema: {
194
+ readonly $schema: "http://json-schema.org/draft-07/schema";
195
+ readonly type: "object";
196
+ readonly properties: {
197
+ readonly rigorPartial: {
198
+ readonly description: "The options of the reporter rigor-partial.";
199
+ readonly type: "object";
200
+ readonly properties: {
201
+ readonly stopAfterPlan: {
202
+ readonly description: "Stop Stryker after the reporter writes the plan.";
203
+ readonly type: "boolean";
204
+ readonly default: false;
205
+ };
206
+ };
207
+ readonly additionalProperties: false;
208
+ readonly default: {};
209
+ };
210
+ };
211
+ };
212
+ /** The plugins of this module, in the form of `declareClassPlugin` of `@stryker-mutator/api/plugin`. */
213
+ declare const strykerPlugins: readonly {
214
+ readonly kind: "Reporter";
215
+ readonly name: string;
216
+ readonly injectableClass: typeof PartialReporter;
217
+ }[];
218
+ export { staticFaults as C, readPlan as S, TestOfDryRun as _, strykerPlugins as a, filePlans as b, LinePlan as c, PlanLimits as d, PlanOfMutant as f, TARGET_MINUTES as g, SelectionPlan as h, ReporterOptions as i, PLAN_FILE as l, STOP_MINUTES as m, PartialLine as n, strykerValidationSchema as o, PlanRead as p, PartialReporter as r, FilePlan as s, PARTIAL_FILE as t, PLAN_PER_CLOCK as u, TestPlan as v, testPlans as w, parsePlan as x, clockMinutes as y };
219
+ //# sourceMappingURL=reporter-BS3LIodv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter-BS3LIodv.d.ts","names":[],"sources":["../src/plan.ts","../src/reporter.ts"],"mappings":";;;;;;;;cASa;;;;;cAMA;;cAGA;;;;;cAMA;;UAMI;WACN;WACA;aACE;aACA;aACA;;aAEA;eAAsB;iBAAkB;;;;WAE1C;;WAEA;aAAwB;aAA2B;;;;UAI7C;WACN;WACA;WACA;WACA;;;KAcC,qBAAqB,cAAc,cAAc,oBAAoB;;UAGhE;;WAEN;WACA;WACA;WACA;WACA;;WAEA,gBAAgB;;;KAIf,qBAAqB,cAAc,cAAc,YAAY,cAAc;;UAGtE;WACN,OAAO,SAAS,eAAe;WAC/B,gBAAgB;;;iBAeX,UAAU,gBAAgB,gBAAgB,QAAO,8BAAyC,eAAe;;;;;iBA6BzG,UAAU,gBAAgB,gBAAgB,gBAAgB,gBAAgB,QAAO,6BAAwC,eAA0B;;iBAgBnJ,aAAa,eAAe;;U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