@systemfsoftware/stryker-ignorer-kit 0.1.0 → 0.1.3
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/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/dist/index.d.ts +25 -30
- package/dist/index.mjs +19 -30
- package/dist/tester.d.ts +33 -38
- package/dist/tester.mjs +121 -166
- package/package.json +17 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @systemfsoftware/stryker-ignorer-kit
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
Build and lint with effect 4.1.0 and @effect/tsgo 0.63.0; the published code is unchanged.
|
|
6
|
+
|
|
7
|
+
## 0.1.2
|
|
8
|
+
|
|
9
|
+
Effect moves to `4.0.0-rc.117`, together with the `@effect/*` packages these libraries use. Projects that install `effect` next to them need the same release.
|
|
10
|
+
|
|
11
|
+
- The TypeScript checker and test-runner workers now bundle their own runtime, so the only modules they load from your project are the TypeScript compiler and your test framework.
|
|
12
|
+
- The test-runner plugin supports the framework's fifth major release.
|
|
13
|
+
- The ignorer interface re-exports the `oxc-parser` 0.150 AST, in which `FormalParameterRest.decorators` is `Array<Decorator>`.
|
|
14
|
+
|
|
15
|
+
## 0.1.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Effect moves to `4.0.0-rc.116` (with `@effect/platform-node`, `@effect/platform-node-shared`, `@effect/vitest` and `@effect/opentelemetry` on the same release), the `@systemfsoftware/*` toolchain pins move to their current releases, and `vitest` 5 with `oxc-parser` 0.150 come along. Both worker bundles (`stryker-js-typescript-checker`, `stryker-js-vitest-runner`) now inline their whole runtime rather than resolving `effect`, `@effect/*` and the sibling packages from the host's tree, so a worker runs on its own copy of the effect that built it; the project's `typescript` and `vitest` remain the only imports beside Node builtins. The filter-level `arbitrary.candidate` generators that the thresholds schemas carried are gone: v4 no longer reads them, so thresholds still reject a `low` above `high` and the property tests generate the pair from the schema again. Log calls inside `Effect.catch*` handlers moved to `Effect.tapError`/`Effect.tapCause` at the same level and message. `@systemfsoftware/stryker-ignorer-interface` re-exports the 0.150 AST, where `FormalParameterRest.decorators` is now `Array<Decorator>`.
|
|
20
|
+
|
|
3
21
|
## 0.1.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ Case semantics:
|
|
|
147
147
|
### 4. Ship it
|
|
148
148
|
|
|
149
149
|
`pnpm --filter <your-package> test` green, `api:update` for the report, a
|
|
150
|
-
changeset entry, and the
|
|
150
|
+
changeset entry, and the README wording true to what ships. The family
|
|
151
151
|
rules bind: zero Effect, no type assertions, complexity ≤ 2 per function —
|
|
152
152
|
narrow with small type-predicate functions, as above.
|
|
153
153
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
|
-
import { Ignorer } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export declare type IgnorerVisitors = { readonly [K in Node_2['type']]?: IgnorerVisitor<K>; } & {
|
|
27
|
-
readonly onAnyNode?: (node: Node_2, ctx: IgnorerContext) => string | undefined;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { }
|
|
1
|
+
import { Ignorer, Node } from "@systemfsoftware/stryker-ignorer-interface";
|
|
2
|
+
//#region src/define-ignorer.d.ts
|
|
3
|
+
interface IgnorerContext {
|
|
4
|
+
/** Nearest-first as the host hands it over; the parent is the first element. */
|
|
5
|
+
readonly ancestors: readonly Node[];
|
|
6
|
+
parentIf<K extends Node['type']>(kind: K): Extract<Node, {
|
|
7
|
+
readonly type: K;
|
|
8
|
+
}> | undefined;
|
|
9
|
+
ancestorIf<K extends Node['type']>(kind: K): Extract<Node, {
|
|
10
|
+
readonly type: K;
|
|
11
|
+
}> | undefined;
|
|
12
|
+
}
|
|
13
|
+
type IgnorerVisitor<K extends Node['type']> = (node: Extract<Node, {
|
|
14
|
+
readonly type: K;
|
|
15
|
+
}>, ctx: IgnorerContext) => string | undefined;
|
|
16
|
+
type IgnorerVisitors = { readonly [K in Node['type']]?: IgnorerVisitor<K>; } & {
|
|
17
|
+
readonly onAnyNode?: (node: Node, ctx: IgnorerContext) => string | undefined;
|
|
18
|
+
};
|
|
19
|
+
interface IgnorerDefinition {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly visitors: IgnorerVisitors;
|
|
22
|
+
}
|
|
23
|
+
export declare function defineIgnorer(definition: IgnorerDefinition): Ignorer;
|
|
24
|
+
//#endregion
|
|
25
|
+
export type { IgnorerContext, IgnorerDefinition, IgnorerVisitor, IgnorerVisitors };
|
package/dist/index.mjs
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
//#region src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ancestorIf: (kind) => ancestors.find((ancestor) => isNodeOfType(ancestor, kind))
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function isVisitor(value) {
|
|
13
|
-
return typeof value === "function";
|
|
14
|
-
}
|
|
15
|
-
function typedVisitor(visitors, node) {
|
|
16
|
-
const entry = visitors[node.type];
|
|
17
|
-
return isVisitor(entry) ? entry : void 0;
|
|
18
|
-
}
|
|
19
|
-
function callTyped(visitors, node, ctx) {
|
|
20
|
-
const visit = typedVisitor(visitors, node);
|
|
1
|
+
//#region src/define-ignorer.ts
|
|
2
|
+
const isNodeOfType = (node, kind) => node !== void 0 && node.type === kind;
|
|
3
|
+
const isVisitor = (value) => typeof value === "function";
|
|
4
|
+
const typedVisitorOf = (visitors, node) => {
|
|
5
|
+
return [visitors[node.type]].find(isVisitor);
|
|
6
|
+
};
|
|
7
|
+
const claimedReasonOf = (visitors, node, ctx) => {
|
|
8
|
+
const visit = typedVisitorOf(visitors, node);
|
|
21
9
|
return visit === void 0 ? void 0 : visit(node, ctx);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return reason === void 0 ? callAny(visitors, node, ctx) : reason;
|
|
29
|
-
}
|
|
10
|
+
};
|
|
11
|
+
const anyReasonOf = (visitors, node, ctx) => visitors.onAnyNode?.(node, ctx);
|
|
12
|
+
const reasonFrom = (visitors, node, ctx) => {
|
|
13
|
+
const claimed = claimedReasonOf(visitors, node, ctx);
|
|
14
|
+
return claimed === void 0 ? anyReasonOf(visitors, node, ctx) : claimed;
|
|
15
|
+
};
|
|
30
16
|
function defineIgnorer(definition) {
|
|
31
|
-
const visitors = definition.visitors;
|
|
32
17
|
return {
|
|
33
18
|
name: definition.name,
|
|
34
|
-
shouldIgnore: (node, ancestors) =>
|
|
19
|
+
shouldIgnore: (node, ancestors) => reasonFrom(definition.visitors, node, {
|
|
20
|
+
ancestors,
|
|
21
|
+
parentIf: (kind) => isNodeOfType(ancestors[0], kind) ? ancestors[0] : void 0,
|
|
22
|
+
ancestorIf: (kind) => ancestors.find((ancestor) => isNodeOfType(ancestor, kind))
|
|
23
|
+
})
|
|
35
24
|
};
|
|
36
25
|
}
|
|
37
26
|
//#endregion
|
package/dist/tester.d.ts
CHANGED
|
@@ -1,38 +1,33 @@
|
|
|
1
|
-
import { Ignorer } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* case here and rejects with one error enumerating every failing case.
|
|
35
|
-
*/
|
|
36
|
-
export declare function testIgnorer(subject: Ignorer, cases: IgnorerCases): Promise<void>;
|
|
37
|
-
|
|
38
|
-
export { }
|
|
1
|
+
import { Ignorer } from "@systemfsoftware/stryker-ignorer-interface";
|
|
2
|
+
//#region src/tester/test-ignorer.d.ts
|
|
3
|
+
type ScriptLang = 'js' | 'jsx' | 'ts' | 'tsx';
|
|
4
|
+
interface IgnoredSpan {
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly reason?: string;
|
|
7
|
+
}
|
|
8
|
+
interface IgnoredCase {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly code: string;
|
|
11
|
+
readonly lang?: ScriptLang;
|
|
12
|
+
readonly ignores: readonly (string | IgnoredSpan)[];
|
|
13
|
+
readonly keeps?: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
interface KeptCase {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly code: string;
|
|
18
|
+
readonly lang?: ScriptLang;
|
|
19
|
+
readonly keeps?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
interface IgnorerCases {
|
|
22
|
+
readonly ignored?: readonly IgnoredCase[];
|
|
23
|
+
readonly kept?: readonly KeptCase[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parses each case with the instrumenter's parser convention, walks with host-shaped
|
|
27
|
+
* ancestor semantics, and consults the subject at every node. With runner globals present
|
|
28
|
+
* this registers one test per case under the subject's name; without them it runs every
|
|
29
|
+
* case here and rejects with one error enumerating every failing case.
|
|
30
|
+
*/
|
|
31
|
+
export declare function testIgnorer(subject: Ignorer, cases: IgnorerCases): Promise<void>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export type { IgnoredCase, IgnoredSpan, IgnorerCases, KeptCase, ScriptLang };
|
package/dist/tester.mjs
CHANGED
|
@@ -1,213 +1,169 @@
|
|
|
1
|
+
import { parseSync } from "oxc-parser";
|
|
1
2
|
import { parseAndWalk } from "oxc-walker";
|
|
2
|
-
//#region src/tester.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
3
|
+
//#region src/tester/case-failure.ts
|
|
4
|
+
const reasonSuffix = (reason) => ` reason ${JSON.stringify(reason)}`;
|
|
5
|
+
const spanLine = (span) => `- ${JSON.stringify(span.text)} (${span.type})${reasonSuffix(span.reason)}`;
|
|
6
|
+
const receivedLines = (received) => received.length === 0 ? ["- none"] : received.map(spanLine);
|
|
7
|
+
const messageFor = (failure) => [
|
|
8
|
+
`case ${JSON.stringify(failure.file.name)} (${failure.file.kind}) failed:`,
|
|
9
|
+
"code:",
|
|
10
|
+
failure.file.code,
|
|
11
|
+
"failures:",
|
|
12
|
+
...failure.failures.map((one) => `- ${one}`),
|
|
13
|
+
"received ignored spans:",
|
|
14
|
+
...receivedLines(failure.received)
|
|
15
|
+
].join("\n");
|
|
16
|
+
var IgnorerCaseFailed = class extends Error {
|
|
17
|
+
outcomes;
|
|
18
|
+
_tag = "IgnorerCaseFailed";
|
|
19
|
+
constructor(outcomes) {
|
|
20
|
+
super(outcomes.map(messageFor).join("\n\n"));
|
|
21
|
+
this.outcomes = outcomes;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/tester/test-ignorer.ts
|
|
26
|
+
const FILE_NAMES = {
|
|
9
27
|
js: "case.js",
|
|
10
28
|
jsx: "case.jsx",
|
|
11
29
|
ts: "case.ts",
|
|
12
30
|
tsx: "case.tsx"
|
|
13
31
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
const toSpan = (expect) => typeof expect === "string" ? { text: expect } : expect;
|
|
33
|
+
const langOf = (one) => one.lang ?? "ts";
|
|
34
|
+
const keepsOf = (one) => one.keeps ?? [];
|
|
35
|
+
const toKept = (one) => ({
|
|
36
|
+
kind: "kept",
|
|
37
|
+
name: one.name,
|
|
38
|
+
code: one.code,
|
|
39
|
+
lang: langOf(one),
|
|
40
|
+
expects: [],
|
|
41
|
+
keeps: keepsOf(one)
|
|
42
|
+
});
|
|
43
|
+
const toIgnored = (one) => ({
|
|
44
|
+
kind: "ignored",
|
|
45
|
+
name: one.name,
|
|
46
|
+
code: one.code,
|
|
47
|
+
lang: langOf(one),
|
|
48
|
+
expects: one.ignores.map(toSpan),
|
|
49
|
+
keeps: keepsOf(one)
|
|
50
|
+
});
|
|
51
|
+
const keptFiles = (kept) => (kept ?? []).map(toKept);
|
|
52
|
+
const ignoredFiles = (ignored) => (ignored ?? []).map(toIgnored);
|
|
53
|
+
const toFiles = (cases) => [...keptFiles(cases.kept), ...ignoredFiles(cases.ignored)];
|
|
54
|
+
const parseFailure = (errors) => `parse failed: ${errors.map((error) => error.message).join("; ")}`;
|
|
55
|
+
const allIgnoredFailures = (received) => received.length === 0 ? [] : [`expected nothing ignored, received ${received.length} span(s)`];
|
|
56
|
+
const keepFailure = (received, keep) => {
|
|
57
|
+
const hit = received.find((span) => span.text === keep);
|
|
58
|
+
return hit === void 0 ? [] : [`expected span ${JSON.stringify(keep)} to stay live, but it was ignored${reasonSuffix(hit.reason)}`];
|
|
59
|
+
};
|
|
60
|
+
const keepFailures = (file, received) => file.keeps.flatMap((keep) => keepFailure(received, keep));
|
|
61
|
+
const keptFailures = (file, received) => file.keeps.length === 0 ? allIgnoredFailures(received) : keepFailures(file, received);
|
|
62
|
+
const keptOutcome = (file, received) => {
|
|
63
|
+
const failures = keptFailures(file, received);
|
|
24
64
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
expects: [],
|
|
30
|
-
keeps: keepsOf(one)
|
|
65
|
+
file,
|
|
66
|
+
passed: failures.length === 0,
|
|
67
|
+
failures,
|
|
68
|
+
received
|
|
31
69
|
};
|
|
32
|
-
}
|
|
33
|
-
|
|
70
|
+
};
|
|
71
|
+
const reasonMatches = (actual, pinned) => pinned === void 0 || actual === pinned;
|
|
72
|
+
const spansMatch = (span, expect) => span.text === expect.text && reasonMatches(span.reason, expect.reason);
|
|
73
|
+
const pinnedSuffix = (expect) => expect.reason === void 0 ? "" : ` with reason ${JSON.stringify(expect.reason)}`;
|
|
74
|
+
const missingMessage = (expect) => `expected ignored span ${JSON.stringify(expect.text)}${pinnedSuffix(expect)} was not ignored`;
|
|
75
|
+
const expectFailures = (pool, expect) => {
|
|
76
|
+
const at = pool.findIndex((span) => spansMatch(span, expect));
|
|
77
|
+
pool.splice(at, Number(at !== -1));
|
|
78
|
+
return at === -1 ? [missingMessage(expect)] : [];
|
|
79
|
+
};
|
|
80
|
+
const ignoredOutcome = (file, received) => {
|
|
81
|
+
const pool = [...received];
|
|
82
|
+
const failures = [...file.expects.flatMap((expect) => expectFailures(pool, expect)), ...keepFailures(file, received)];
|
|
34
83
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
expects: one.ignores.map(toSpan),
|
|
40
|
-
keeps: keepsOf(one)
|
|
84
|
+
file,
|
|
85
|
+
passed: failures.length === 0,
|
|
86
|
+
failures,
|
|
87
|
+
received
|
|
41
88
|
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return [
|
|
51
|
-
}
|
|
52
|
-
function errorMessage(error) {
|
|
53
|
-
return error.message;
|
|
54
|
-
}
|
|
55
|
-
function parseFailure(errors) {
|
|
56
|
-
return `parse failed: ${errors.map(errorMessage).join("; ")}`;
|
|
57
|
-
}
|
|
58
|
-
function recordIfIgnored(subject, node, ancestors, received, file) {
|
|
59
|
-
const reason = subject.shouldIgnore(node, [...ancestors]);
|
|
60
|
-
if (reason !== void 0) received.push({
|
|
89
|
+
};
|
|
90
|
+
const OUTCOME_OF = {
|
|
91
|
+
kept: keptOutcome,
|
|
92
|
+
ignored: ignoredOutcome
|
|
93
|
+
};
|
|
94
|
+
const judge = (file, received) => OUTCOME_OF[file.kind](file, received);
|
|
95
|
+
const receivedOf = (subject, file, node, ancestors) => {
|
|
96
|
+
const reason = subject.shouldIgnore(node, ancestors);
|
|
97
|
+
return reason === void 0 ? [] : [{
|
|
61
98
|
text: file.code.slice(node.start, node.end),
|
|
62
99
|
reason,
|
|
63
100
|
type: node.type
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
const received = [];
|
|
101
|
+
}];
|
|
102
|
+
};
|
|
103
|
+
const collect = (subject, file) => {
|
|
104
|
+
const visits = [];
|
|
69
105
|
const ancestors = [];
|
|
70
|
-
const result = parseAndWalk(file.code,
|
|
106
|
+
const result = parseAndWalk(file.code, FILE_NAMES[file.lang], {
|
|
71
107
|
parseSync,
|
|
72
108
|
parseOptions: {
|
|
73
109
|
lang: file.lang,
|
|
74
110
|
range: true
|
|
75
111
|
},
|
|
76
112
|
enter(node) {
|
|
77
|
-
|
|
113
|
+
visits.push([node, [...ancestors]]);
|
|
78
114
|
ancestors.unshift(node);
|
|
79
115
|
},
|
|
80
116
|
leave() {
|
|
81
117
|
ancestors.shift();
|
|
82
118
|
}
|
|
83
119
|
});
|
|
84
|
-
return result.errors.length > 0 ? parseFailure(result.errors) :
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
function keepFailure(received, keep) {
|
|
90
|
-
const hit = received.find((span) => span.text === keep);
|
|
91
|
-
return hit === void 0 ? [] : [`expected span ${JSON.stringify(keep)} to stay live, but it was ignored${reasonSuffix(hit.reason)}`];
|
|
92
|
-
}
|
|
93
|
-
function keepFailures(file, received) {
|
|
94
|
-
return file.keeps.flatMap((keep) => keepFailure(received, keep));
|
|
95
|
-
}
|
|
96
|
-
function keptFailures(file, received) {
|
|
97
|
-
return file.keeps.length === 0 ? allIgnoredFailures(received) : keepFailures(file, received);
|
|
98
|
-
}
|
|
99
|
-
function keptOutcome(file, received) {
|
|
100
|
-
const failures = keptFailures(file, received);
|
|
101
|
-
return {
|
|
102
|
-
file,
|
|
103
|
-
passed: failures.length === 0,
|
|
104
|
-
failures,
|
|
105
|
-
received
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function reasonMatches(actual, pinned) {
|
|
109
|
-
return pinned === void 0 || actual === pinned;
|
|
110
|
-
}
|
|
111
|
-
function spansMatch(span, expect) {
|
|
112
|
-
return span.text === expect.text && reasonMatches(span.reason, expect.reason);
|
|
113
|
-
}
|
|
114
|
-
function pinnedSuffix(expect) {
|
|
115
|
-
return expect.reason === void 0 ? "" : ` with reason ${JSON.stringify(expect.reason)}`;
|
|
116
|
-
}
|
|
117
|
-
function missingMessage(expect) {
|
|
118
|
-
return `expected ignored span ${JSON.stringify(expect.text)}${pinnedSuffix(expect)} was not ignored`;
|
|
119
|
-
}
|
|
120
|
-
function expectFailures(pool, expect) {
|
|
121
|
-
const at = pool.findIndex((span) => spansMatch(span, expect));
|
|
122
|
-
if (at === -1) return [missingMessage(expect)];
|
|
123
|
-
pool.splice(at, 1);
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
function ignoredOutcome(file, received) {
|
|
127
|
-
const pool = [...received];
|
|
128
|
-
const failures = [...file.expects.flatMap((expect) => expectFailures(pool, expect)), ...keepFailures(file, received)];
|
|
129
|
-
return {
|
|
130
|
-
file,
|
|
131
|
-
passed: failures.length === 0,
|
|
132
|
-
failures,
|
|
133
|
-
received
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function judge(file, received) {
|
|
137
|
-
return file.kind === "kept" ? keptOutcome(file, received) : ignoredOutcome(file, received);
|
|
138
|
-
}
|
|
139
|
-
function reasonSuffix(reason) {
|
|
140
|
-
return ` reason ${JSON.stringify(reason)}`;
|
|
141
|
-
}
|
|
142
|
-
function spanLine(span) {
|
|
143
|
-
return `- ${JSON.stringify(span.text)} (${span.type})${reasonSuffix(span.reason)}`;
|
|
144
|
-
}
|
|
145
|
-
function failureLine(failure) {
|
|
146
|
-
return `- ${failure}`;
|
|
147
|
-
}
|
|
148
|
-
function receivedLines(received) {
|
|
149
|
-
return received.length === 0 ? ["- none"] : received.map(spanLine);
|
|
150
|
-
}
|
|
151
|
-
function messageFor(outcome) {
|
|
152
|
-
return [
|
|
153
|
-
`case ${JSON.stringify(outcome.file.name)} (${outcome.file.kind}) failed:`,
|
|
154
|
-
"code:",
|
|
155
|
-
outcome.file.code,
|
|
156
|
-
"failures:",
|
|
157
|
-
...outcome.failures.map(failureLine),
|
|
158
|
-
"received ignored spans:",
|
|
159
|
-
...receivedLines(outcome.received)
|
|
160
|
-
].join("\n");
|
|
161
|
-
}
|
|
162
|
-
async function outcomeOf(subject, file) {
|
|
163
|
-
const result = await collect(subject, file);
|
|
120
|
+
return result.errors.length > 0 ? parseFailure(result.errors) : visits.flatMap(([node, chain]) => receivedOf(subject, file, node, chain));
|
|
121
|
+
};
|
|
122
|
+
const outcomeOf = (subject, file) => {
|
|
123
|
+
const result = collect(subject, file);
|
|
164
124
|
return typeof result === "string" ? {
|
|
165
125
|
file,
|
|
166
126
|
passed: false,
|
|
167
127
|
failures: [result],
|
|
168
128
|
received: []
|
|
169
129
|
} : judge(file, result);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
function isIt(value) {
|
|
175
|
-
return typeof value === "function";
|
|
176
|
-
}
|
|
177
|
-
function globalDescribe() {
|
|
130
|
+
};
|
|
131
|
+
const isDescribe = (value) => typeof value === "function";
|
|
132
|
+
const isIt = (value) => typeof value === "function";
|
|
133
|
+
const globalDescribe = () => {
|
|
178
134
|
const value = Reflect.get(globalThis, "describe");
|
|
179
135
|
return isDescribe(value) ? value : void 0;
|
|
180
|
-
}
|
|
181
|
-
|
|
136
|
+
};
|
|
137
|
+
const globalIt = () => {
|
|
182
138
|
const value = Reflect.get(globalThis, "it");
|
|
183
139
|
return isIt(value) ? value : void 0;
|
|
184
|
-
}
|
|
185
|
-
|
|
140
|
+
};
|
|
141
|
+
const withIt = (describe) => {
|
|
186
142
|
const it = globalIt();
|
|
187
143
|
return it === void 0 ? void 0 : {
|
|
188
144
|
describe,
|
|
189
145
|
it
|
|
190
146
|
};
|
|
191
|
-
}
|
|
192
|
-
|
|
147
|
+
};
|
|
148
|
+
const runner = () => {
|
|
193
149
|
const describe = globalDescribe();
|
|
194
150
|
return describe === void 0 ? void 0 : withIt(describe);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const failed =
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
run.it(file.name,
|
|
202
|
-
const outcome =
|
|
203
|
-
|
|
151
|
+
};
|
|
152
|
+
const directRun = (subject, files) => {
|
|
153
|
+
const failed = files.map((file) => outcomeOf(subject, file)).filter((outcome) => outcome.passed === false);
|
|
154
|
+
return failed.length === 0 ? Promise.resolve() : Promise.reject(new IgnorerCaseFailed(failed));
|
|
155
|
+
};
|
|
156
|
+
const registerCase = (run, subject, file) => {
|
|
157
|
+
run.it(file.name, () => {
|
|
158
|
+
const outcome = outcomeOf(subject, file);
|
|
159
|
+
return outcome.passed ? Promise.resolve() : Promise.reject(new IgnorerCaseFailed([outcome]));
|
|
204
160
|
});
|
|
205
|
-
}
|
|
206
|
-
|
|
161
|
+
};
|
|
162
|
+
const registerAll = (run, subject, files) => {
|
|
207
163
|
run.describe(subject.name, () => {
|
|
208
|
-
|
|
164
|
+
files.map((file) => registerCase(run, subject, file));
|
|
209
165
|
});
|
|
210
|
-
}
|
|
166
|
+
};
|
|
211
167
|
/**
|
|
212
168
|
* Parses each case with the instrumenter's parser convention, walks with host-shaped
|
|
213
169
|
* ancestor semantics, and consults the subject at every node. With runner globals present
|
|
@@ -217,8 +173,7 @@ function registerAll(run, subject, files) {
|
|
|
217
173
|
async function testIgnorer(subject, cases) {
|
|
218
174
|
const run = runner();
|
|
219
175
|
const files = toFiles(cases);
|
|
220
|
-
|
|
221
|
-
else registerAll(run, subject, files);
|
|
176
|
+
return run === void 0 ? directRun(subject, files) : Promise.resolve(registerAll(run, subject, files));
|
|
222
177
|
}
|
|
223
178
|
//#endregion
|
|
224
179
|
export { testIgnorer };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/stryker-ignorer-kit",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"type": "module",
|
|
24
24
|
"files": [
|
|
25
|
-
"dist"
|
|
25
|
+
"dist",
|
|
26
|
+
"CHANGELOG.md"
|
|
26
27
|
],
|
|
27
28
|
"exports": {
|
|
28
29
|
".": {
|
|
@@ -36,26 +37,27 @@
|
|
|
36
37
|
"./package.json": "./package.json"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@oxc-project/types": "^0.
|
|
40
|
-
"
|
|
41
|
-
"oxc-
|
|
42
|
-
"
|
|
40
|
+
"@oxc-project/types": "^0.150.0",
|
|
41
|
+
"@systemfsoftware/stryker-ignorer-interface": "^0.1.3",
|
|
42
|
+
"oxc-parser": "^0.150.0",
|
|
43
|
+
"oxc-walker": "^1"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@microsoft/api-extractor": "^7",
|
|
46
|
-
"@systemfsoftware/arethetypeswrong-cli": "^4",
|
|
47
|
-
"@systemfsoftware/
|
|
47
|
+
"@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
|
|
48
|
+
"@systemfsoftware/oxlint-ignorer-config": "^0.1.3",
|
|
49
|
+
"@systemfsoftware/tsconfig": "^2.0.1",
|
|
50
|
+
"@systemfsoftware/tsdown-config": "^0.1.0",
|
|
51
|
+
"@systemfsoftware/vitest": "^2.0.0",
|
|
52
|
+
"@systemfsoftware/vitest-config": "^0.1.0",
|
|
48
53
|
"@types/node": "^24",
|
|
49
|
-
"@vitest/coverage-v8": "^
|
|
54
|
+
"@vitest/coverage-v8": "^5",
|
|
50
55
|
"concurrently": "^10",
|
|
51
|
-
"oxlint": "
|
|
56
|
+
"oxlint": "~1.90.0",
|
|
52
57
|
"rimraf": "^6.1.3",
|
|
53
58
|
"tsdown": "^0.23.0",
|
|
54
59
|
"typescript": "^7",
|
|
55
|
-
"vitest": "^
|
|
56
|
-
"@systemfsoftware/oxlint-ignorer-config": "^0.1.0",
|
|
57
|
-
"@systemfsoftware/tsdown-config": "^0.1.0",
|
|
58
|
-
"@systemfsoftware/vitest-config": "^0.1.0"
|
|
60
|
+
"vitest": "^5"
|
|
59
61
|
},
|
|
60
62
|
"publishConfig": {
|
|
61
63
|
"access": "public",
|
|
@@ -64,7 +66,7 @@
|
|
|
64
66
|
"scripts": {
|
|
65
67
|
"build": "tsdown",
|
|
66
68
|
"clean": "rimraf dist",
|
|
67
|
-
"typecheck": "tsc
|
|
69
|
+
"typecheck": "tsc -b",
|
|
68
70
|
"test": "vitest run",
|
|
69
71
|
"lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint . --format=${f:-default}",
|
|
70
72
|
"attw": "attw --pack .",
|