@smoothbricks/nx-plugin 0.6.2 → 0.7.0
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 +417 -171
- package/dist/.build-inputs.json +39 -28
- package/dist/bin/smoo-nx-go-test-build.d.ts +3 -0
- package/dist/bin/smoo-nx-go-test-build.d.ts.map +1 -0
- package/dist/bin/smoo-nx-go-test-build.js +79 -0
- package/dist/bin/smoo-nx-go-test-run.d.ts +3 -0
- package/dist/bin/smoo-nx-go-test-run.d.ts.map +1 -0
- package/dist/bin/smoo-nx-go-test-run.js +129 -0
- package/dist/bin/smoo-nx-publish.d.ts +3 -0
- package/dist/bin/smoo-nx-publish.d.ts.map +1 -0
- package/dist/bin/smoo-nx-publish.js +3 -0
- package/dist/bounded-test-policy.d.ts +1 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +9 -8
- package/dist/cargo-retention-hook.d.ts +6 -2
- package/dist/cargo-retention-hook.d.ts.map +1 -1
- package/dist/cargo-retention-hook.js +13 -7
- package/dist/cargo-workspace.d.ts +10 -20
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +12 -22
- package/dist/cross-check-policy.d.ts +2 -2
- package/dist/cross-check-policy.js +2 -2
- package/dist/deploy-policy.d.ts +6 -0
- package/dist/deploy-policy.d.ts.map +1 -1
- package/dist/deploy-policy.js +11 -0
- package/dist/eslint-file-set.d.ts +4 -1
- package/dist/eslint-file-set.d.ts.map +1 -1
- package/dist/eslint-sources.d.ts +25 -0
- package/dist/eslint-sources.d.ts.map +1 -0
- package/dist/eslint-sources.js +99 -0
- package/dist/executors/all-verdicts/executor.d.ts +2 -1
- package/dist/executors/all-verdicts/executor.d.ts.map +1 -1
- package/dist/executors/all-verdicts/executor.js +48 -2
- package/dist/executors/all-verdicts/schema.d.ts +13 -0
- package/dist/executors/all-verdicts/schema.d.ts.map +1 -1
- package/dist/executors/all-verdicts/schema.js +7 -0
- package/dist/executors/bounded-exec/bounds.d.ts +57 -8
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +100 -11
- package/dist/executors/bounded-exec/executor.d.ts +2 -1
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +289 -34
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +2 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +2 -2
- package/dist/executors/bounded-exec/mbx-pool.d.ts +56 -10
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +145 -11
- package/dist/executors/bounded-exec/mbx-queue.d.ts +30 -0
- package/dist/executors/bounded-exec/mbx-queue.d.ts.map +1 -0
- package/dist/executors/bounded-exec/mbx-queue.js +229 -0
- package/dist/executors/bounded-exec/progress.d.ts +9 -2
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +151 -25
- package/dist/executors/bounded-exec/runner-sizing.d.ts +40 -2
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +55 -4
- package/dist/executors/bounded-exec/runtime-pin.js +1 -1
- package/dist/executors/bounded-exec/test-result-writer.d.ts +30 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -0
- package/dist/executors/bounded-exec/test-result-writer.js +126 -0
- package/dist/executors/bounded-exec/test-results.d.ts +33 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -0
- package/dist/executors/bounded-exec/test-results.js +33 -0
- package/dist/executors/bounded-exec/verdict.d.ts +26 -2
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +108 -4
- package/dist/executors/wrangler-deploy/deploy-hash.d.ts +10 -0
- package/dist/executors/wrangler-deploy/deploy-hash.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/deploy-hash.js +14 -0
- package/dist/executors/wrangler-deploy/executor.d.ts +24 -0
- package/dist/executors/wrangler-deploy/executor.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/executor.js +43 -0
- package/dist/executors/wrangler-deploy/hasher.d.ts +27 -0
- package/dist/executors/wrangler-deploy/hasher.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/hasher.js +90 -0
- package/dist/executors/wrangler-deploy/schema.d.ts +5 -0
- package/dist/executors/wrangler-deploy/schema.d.ts.map +1 -0
- package/dist/go-tests.d.ts +30 -0
- package/dist/go-tests.d.ts.map +1 -0
- package/dist/go-tests.js +43 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +338 -295
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +5 -0
- package/dist/nx-publish.d.ts +24 -0
- package/dist/nx-publish.d.ts.map +1 -0
- package/dist/nx-publish.js +150 -0
- package/dist/process-group.js +2 -2
- package/dist/runtime-input-policy.d.ts +17 -3
- package/dist/runtime-input-policy.d.ts.map +1 -1
- package/dist/runtime-input-policy.js +4 -4
- package/dist/test-timings.d.ts +23 -4
- package/dist/test-timings.d.ts.map +1 -1
- package/dist/test-timings.js +72 -12
- package/dist/tool-bins.d.ts +6 -8
- package/dist/tool-bins.d.ts.map +1 -1
- package/dist/tool-bins.js +7 -5
- package/dist/version-actions.cjs +10 -11
- package/dist/version-actions.d.cts.map +1 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +17 -22
- package/dist/workspace-index.d.ts +7 -0
- package/dist/workspace-index.d.ts.map +1 -1
- package/dist/workspace-index.js +11 -0
- package/dist/workspace-manifest.js +3 -3
- package/executors.json +7 -6
- package/managed/raw/patches/nx@23.2.1.patch +118 -24
- package/managed/raw/patches/ttsc@0.34.1.patch +139 -0
- package/managed/raw/tooling/devenv +1 -2
- package/managed/raw/tooling/direnv/developer-links.ts +124 -51
- package/managed/raw/tooling/direnv/devenv.smoo.nix +34 -15
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
- package/managed/raw/tooling/direnv/installed-bun-links.ts +7 -6
- package/managed/raw/tooling/direnv/setup-environment.ts +49 -24
- package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
- package/managed/raw/tooling/git-hooks/pinned-revisions-served.ts +252 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +34 -32
- package/managed/templates/github/actions/cache-node-modules/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +12 -11
- package/package.json +277 -11
- package/runtime/nx-publish/.build-inputs.json +11 -0
- package/runtime/nx-publish/cache_adapter.js +45 -0
- package/runtime/nx-publish/nx_publish.js +60 -0
- package/runtime-input.sh +62 -26
- package/src/bin/smoo-nx-go-test-build.ts +83 -0
- package/src/bin/smoo-nx-go-test-run.ts +140 -0
- package/src/bin/smoo-nx-publish.ts +4 -0
- package/src/bounded-test-policy.ts +9 -8
- package/src/cargo-retention-hook.ts +16 -10
- package/src/cargo-workspace.ts +12 -24
- package/src/cross-check-policy.ts +2 -2
- package/src/deploy-policy.ts +11 -0
- package/src/eslint-file-set.ts +4 -1
- package/src/eslint-sources.ts +134 -0
- package/src/executors/all-verdicts/executor.ts +58 -3
- package/src/executors/all-verdicts/schema.json +4 -0
- package/src/executors/all-verdicts/schema.ts +14 -0
- package/src/executors/bounded-exec/bounds.ts +132 -15
- package/src/executors/bounded-exec/executor.ts +329 -34
- package/src/executors/bounded-exec/hang-diagnostics.ts +3 -2
- package/src/executors/bounded-exec/mbx-pool.ts +158 -17
- package/src/executors/bounded-exec/mbx-queue.ts +170 -0
- package/src/executors/bounded-exec/progress.ts +171 -18
- package/src/executors/bounded-exec/runner-sizing.ts +73 -7
- package/src/executors/bounded-exec/runtime-pin.ts +1 -1
- package/src/executors/bounded-exec/test-result-writer.ts +152 -0
- package/src/executors/bounded-exec/test-results.ts +39 -0
- package/src/executors/bounded-exec/verdict.ts +115 -5
- package/src/executors/wrangler-deploy/deploy-hash.ts +15 -0
- package/src/executors/wrangler-deploy/executor.ts +63 -0
- package/src/executors/wrangler-deploy/hasher.ts +111 -0
- package/src/executors/wrangler-deploy/schema.json +16 -0
- package/src/executors/wrangler-deploy/schema.ts +4 -0
- package/src/go-tests.ts +67 -0
- package/src/index.ts +368 -323
- package/src/managed-files/files.ts +5 -0
- package/src/nx-publish.ts +157 -0
- package/src/process-group.ts +2 -2
- package/src/runtime-input-policy.ts +4 -4
- package/src/test-timings.ts +72 -14
- package/src/tool-bins.ts +13 -9
- package/src/version-actions.cts +10 -11
- package/src/workspace-config-policy.ts +20 -29
- package/src/workspace-index.ts +12 -0
- package/src/workspace-manifest.ts +3 -3
- package/test-timings.json +131 -125
- package/dist/executors/clean-outputs/executor.d.ts +0 -26
- package/dist/executors/clean-outputs/executor.d.ts.map +0 -1
- package/dist/executors/clean-outputs/executor.js +0 -83
- package/dist/executors/clean-outputs/schema.d.ts +0 -4
- package/dist/executors/clean-outputs/schema.d.ts.map +0 -1
- package/src/executors/clean-outputs/executor.ts +0 -131
- package/src/executors/clean-outputs/schema.json +0 -15
- package/src/executors/clean-outputs/schema.ts +0 -3
- /package/dist/executors/{clean-outputs → wrangler-deploy}/schema.js +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
1
2
|
import typia from 'typia';
|
|
2
3
|
import { invocationSpan, withInvocationFlag } from './runner-sizing.js';
|
|
3
|
-
import { BUN_TEST, GO_TEST, NEXTEST_RUN } from './verdict.js';
|
|
4
|
+
import { BUN_TEST, GO_TEST, GO_TEST_RUNNER, NEXTEST_RUN } from './verdict.js';
|
|
4
5
|
const ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*[A-Za-z]`, 'g');
|
|
5
6
|
/** Lines naming a test or file that finished; group 1 is its name. */
|
|
6
7
|
const FINISHED = [
|
|
7
8
|
/^\s*(?:[A-Z0-9][A-Z0-9-]*\s+)+\[\s*[0-9.]+s\]\s+\(\s*\d+\/\d+\)\s+(\S.*)$/,
|
|
8
9
|
/^test (\S+) \.\.\. (?:ok|FAILED|ignored)\b/,
|
|
9
|
-
/^\((?:pass|fail|skip|todo)\) (.+)$/,
|
|
10
10
|
/^\s*[✓×]\s+(\S.*?)\s+\d+ms\b/,
|
|
11
11
|
/^\s*❯\s+(\S.*?)\s+\(\d+ tests?(?: \| \d+ (?:failed|skipped|todo))*\)\s+\d+ms\b/,
|
|
12
12
|
/^\s*↓\s+(\S.*?)\s+\(\d+ tests?(?: \| \d+ (?:skipped|todo))+\)(?:\s+\d+ms\b|$)/,
|
|
@@ -17,45 +17,63 @@ const RUNNING = [
|
|
|
17
17
|
/^test (\S+) has been running for over \d+ seconds$/,
|
|
18
18
|
];
|
|
19
19
|
const DOTS = /^\.+$/;
|
|
20
|
-
const
|
|
20
|
+
const BUN_RESULT = /^(?:\((?<status>pass|fail|skip|todo|pending)\)|(?<symbol>✓|✗|×|»|✎|…))\s+(?<name>.+?)(?: \[(?<duration>\d+(?:\.\d+)?)ms\])?$/;
|
|
21
|
+
const UNCAPTURED_NEXTEST = /(?<![\w-])--(?:no-?capture|debugger|tracer)(?=[=\s]|$)/;
|
|
22
|
+
const isNativeTestEvent = (() => {
|
|
21
23
|
const _ip0 = input => "string" === typeof input["Package"];
|
|
22
24
|
const _ip1 = input => undefined === input["Test"] || "string" === typeof input["Test"];
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
25
|
+
const _ip2 = input => "test" === input["type"];
|
|
26
|
+
const _ip3 = input => "string" === typeof input["name"];
|
|
27
|
+
const _io0 = input => "suite" === input.type && ("failed" === input.event || "ok" === input.event || "started" === input.event);
|
|
28
|
+
const _io1 = input => "start" === input.Action && _ip0(input);
|
|
29
|
+
const _io2 = input => ("cont" === input.Action || "pause" === input.Action || "run" === input.Action) && _ip0(input) && "string" === typeof input.Test;
|
|
30
|
+
const _io3 = input => ("bench" === input.Action || "fail" === input.Action || "pass" === input.Action || "skip" === input.Action) && _ip0(input) && _ip1(input) && (undefined === input.Elapsed || "number" === typeof input.Elapsed);
|
|
31
|
+
const _io4 = input => "output" === input.Action && _ip0(input) && "string" === typeof input.Output && _ip1(input);
|
|
32
|
+
const _io5 = input => _ip2(input) && ("ignored" === input.event || "started" === input.event) && _ip3(input);
|
|
33
|
+
const _io6 = input => _ip2(input) && ("failed" === input.event || "ok" === input.event) && _ip3(input) && ("number" === typeof input.exec_time && 0 <= input.exec_time) && (undefined === input.stdout || "string" === typeof input.stdout) && (undefined === input.reason || "string" === typeof input.reason);
|
|
27
34
|
const _iu0 = input => (() => {
|
|
28
|
-
if ("
|
|
35
|
+
if ("suite" === input.type)
|
|
29
36
|
return _io0(input);
|
|
30
|
-
else if ("
|
|
31
|
-
return _io2(input);
|
|
32
|
-
else if ("cont" === input.Action || "pause" === input.Action || "run" === input.Action)
|
|
37
|
+
else if ("start" === input.Action)
|
|
33
38
|
return _io1(input);
|
|
34
|
-
else if ("
|
|
39
|
+
else if ("cont" === input.Action || "pause" === input.Action || "run" === input.Action)
|
|
40
|
+
return _io2(input);
|
|
41
|
+
else if ("bench" === input.Action || "fail" === input.Action || "pass" === input.Action || "skip" === input.Action)
|
|
35
42
|
return _io3(input);
|
|
43
|
+
else if ("output" === input.Action)
|
|
44
|
+
return _io4(input);
|
|
45
|
+
else if (undefined !== input.exec_time)
|
|
46
|
+
return _io6(input);
|
|
36
47
|
else
|
|
37
|
-
return
|
|
48
|
+
return _io5(input);
|
|
38
49
|
})();
|
|
39
50
|
return input => "object" === typeof input && null !== input && _iu0(input);
|
|
40
51
|
})();
|
|
41
|
-
function
|
|
52
|
+
function nativeTestEvent(text, invalid) {
|
|
42
53
|
if (!text.startsWith('{'))
|
|
43
54
|
return null;
|
|
44
55
|
try {
|
|
45
56
|
const event = JSON.parse(text);
|
|
46
|
-
|
|
57
|
+
if (isNativeTestEvent(event))
|
|
58
|
+
return event;
|
|
59
|
+
if (typeof event === 'object' && event !== null && 'type' in event && event.type === 'test') {
|
|
60
|
+
invalid?.(`invalid native test record: ${text}`);
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
47
63
|
}
|
|
48
64
|
catch (error) {
|
|
49
|
-
if (error instanceof SyntaxError)
|
|
65
|
+
if (error instanceof SyntaxError) {
|
|
66
|
+
invalid?.(`invalid native test JSON: ${error.message}`);
|
|
50
67
|
return null;
|
|
68
|
+
}
|
|
51
69
|
throw error;
|
|
52
70
|
}
|
|
53
71
|
}
|
|
54
72
|
/** A direct Go chain reports tests only through JSON; other commands may also carry text runner reports. */
|
|
55
73
|
function onlyGoTests(command) {
|
|
56
74
|
let rest = command.trim();
|
|
57
|
-
while (rest.search(
|
|
58
|
-
rest = rest.slice(invocationSpan(rest,
|
|
75
|
+
while (rest.search(GO_TEST_RUNNER) === 0) {
|
|
76
|
+
rest = rest.slice(invocationSpan(rest, GO_TEST_RUNNER).argsEnd).trimStart();
|
|
59
77
|
if (rest === '')
|
|
60
78
|
return true;
|
|
61
79
|
const separator = /^(?:&&|\|\||;)\s*/.exec(rest);
|
|
@@ -65,18 +83,37 @@ function onlyGoTests(command) {
|
|
|
65
83
|
}
|
|
66
84
|
return false;
|
|
67
85
|
}
|
|
68
|
-
export function createRunProgress(command = '') {
|
|
86
|
+
export function createRunProgress(command = '', closed) {
|
|
69
87
|
const goLifecycle = onlyGoTests(command);
|
|
88
|
+
const goResults = command.search(GO_TEST_RUNNER) !== -1;
|
|
70
89
|
const streams = {
|
|
71
90
|
stdout: { partial: '', countedDots: 0 },
|
|
72
91
|
stderr: { partial: '', countedDots: 0 },
|
|
73
92
|
};
|
|
74
93
|
const running = new Set();
|
|
75
94
|
const packages = new Map();
|
|
95
|
+
const goOutput = new Map();
|
|
96
|
+
const decoders = {
|
|
97
|
+
stdout: new StringDecoder('utf8'),
|
|
98
|
+
stderr: new StringDecoder('utf8'),
|
|
99
|
+
};
|
|
100
|
+
const nextestStarted = new Set();
|
|
101
|
+
const nextestJson = /--message-format(?:=|\s+)libtest-json-plus(?=\s|$)/.test(command) && !UNCAPTURED_NEXTEST.test(command);
|
|
102
|
+
let failure = null;
|
|
103
|
+
const bunResults = command.search(BUN_TEST) !== -1 && command.search(NEXTEST_RUN) === -1;
|
|
104
|
+
let bunFile = '';
|
|
105
|
+
let bunSummary = false;
|
|
106
|
+
const bunDiagnostics = { stdout: [], stderr: [] };
|
|
76
107
|
// One complete line, ANSI stripped, that is not a line of dots: true when it names a finished test.
|
|
77
|
-
const finishedLine = (text) => {
|
|
78
|
-
const event =
|
|
79
|
-
|
|
108
|
+
const finishedLine = (text, stream) => {
|
|
109
|
+
const event = stream === 'stdout'
|
|
110
|
+
? nativeTestEvent(text, nextestJson
|
|
111
|
+
? (detail) => {
|
|
112
|
+
failure ??= detail;
|
|
113
|
+
}
|
|
114
|
+
: undefined)
|
|
115
|
+
: null;
|
|
116
|
+
if (event !== null && 'Action' in event) {
|
|
80
117
|
switch (event.Action) {
|
|
81
118
|
case 'start':
|
|
82
119
|
packages.set(event.Package, new Set());
|
|
@@ -90,17 +127,82 @@ export function createRunProgress(command = '') {
|
|
|
90
127
|
case 'bench':
|
|
91
128
|
if (event.Test === undefined)
|
|
92
129
|
packages.delete(event.Package);
|
|
93
|
-
else
|
|
130
|
+
else {
|
|
94
131
|
packages.get(event.Package)?.delete(event.Test);
|
|
132
|
+
const id = `${event.Package}::${event.Test}`;
|
|
133
|
+
if (event.Action !== 'bench' && goResults)
|
|
134
|
+
closed?.({
|
|
135
|
+
id,
|
|
136
|
+
status: event.Action,
|
|
137
|
+
source: 'native',
|
|
138
|
+
durationMs: event.Elapsed === undefined ? null : event.Elapsed * 1000,
|
|
139
|
+
sourceRef: null,
|
|
140
|
+
failureOutput: event.Action === 'fail' ? (goOutput.get(id)?.join('') ?? null) : null,
|
|
141
|
+
});
|
|
142
|
+
goOutput.delete(id);
|
|
143
|
+
}
|
|
95
144
|
return true;
|
|
96
145
|
case 'pause':
|
|
97
146
|
case 'cont':
|
|
147
|
+
return false;
|
|
98
148
|
case 'output':
|
|
149
|
+
if (goResults && closed !== undefined && event.Test !== undefined) {
|
|
150
|
+
const id = `${event.Package}::${event.Test}`;
|
|
151
|
+
const output = goOutput.get(id) ?? [];
|
|
152
|
+
output.push(event.Output);
|
|
153
|
+
goOutput.set(id, output);
|
|
154
|
+
}
|
|
99
155
|
return false;
|
|
100
156
|
}
|
|
101
157
|
}
|
|
158
|
+
if (nextestJson && event !== null && 'type' in event && event.type === 'test') {
|
|
159
|
+
if (event.event === 'started') {
|
|
160
|
+
nextestStarted.add(event.name);
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
// nextest appends #N only after retries; a literal #N in the original name stays intact.
|
|
164
|
+
const name = nextestStarted.has(event.name) ? event.name : event.name.replace(/#\d+$/, '');
|
|
165
|
+
nextestStarted.delete(name);
|
|
166
|
+
const split = name.indexOf('$');
|
|
167
|
+
if (nextestJson && split !== -1)
|
|
168
|
+
closed?.({
|
|
169
|
+
id: `${name.slice(0, split)}::${name.slice(split + 1)}`,
|
|
170
|
+
status: event.event === 'ok' ? 'pass' : event.event === 'failed' ? 'fail' : 'skip',
|
|
171
|
+
source: 'native',
|
|
172
|
+
durationMs: 'exec_time' in event ? event.exec_time * 1000 : null,
|
|
173
|
+
sourceRef: null,
|
|
174
|
+
failureOutput: event.event === 'failed' ? (event.stdout ?? event.reason ?? null) : null,
|
|
175
|
+
});
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
102
178
|
if (goLifecycle)
|
|
103
179
|
return false;
|
|
180
|
+
const bun = BUN_RESULT.exec(text)?.groups;
|
|
181
|
+
if (!bunSummary &&
|
|
182
|
+
bun !== undefined &&
|
|
183
|
+
bun.name !== undefined &&
|
|
184
|
+
((bunResults && stream === 'stderr') || (bun.status !== undefined && bun.status !== 'pending'))) {
|
|
185
|
+
const status = bun.status === 'fail' ||
|
|
186
|
+
bun.status === 'pending' ||
|
|
187
|
+
bun.symbol === '…' ||
|
|
188
|
+
bun.symbol === '✗' ||
|
|
189
|
+
bun.symbol === '×'
|
|
190
|
+
? 'fail'
|
|
191
|
+
: bun.status === 'skip' || bun.status === 'todo' || bun.symbol === '»' || bun.symbol === '✎'
|
|
192
|
+
? 'skip'
|
|
193
|
+
: 'pass';
|
|
194
|
+
if (bunResults && stream === 'stderr')
|
|
195
|
+
closed?.({
|
|
196
|
+
id: `${bunFile}::${bun.name}`,
|
|
197
|
+
status,
|
|
198
|
+
source: 'progress',
|
|
199
|
+
durationMs: bun.duration === undefined ? null : Number(bun.duration),
|
|
200
|
+
sourceRef: null,
|
|
201
|
+
failureOutput: status === 'fail' ? bunDiagnostics[stream].join('') : null,
|
|
202
|
+
});
|
|
203
|
+
bunDiagnostics[stream] = [];
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
104
206
|
for (const pattern of FINISHED) {
|
|
105
207
|
const name = pattern.exec(text)?.[1];
|
|
106
208
|
if (name !== undefined) {
|
|
@@ -120,19 +222,31 @@ export function createRunProgress(command = '') {
|
|
|
120
222
|
return {
|
|
121
223
|
scan(stream, chunk) {
|
|
122
224
|
const state = streams[stream];
|
|
123
|
-
const
|
|
225
|
+
const decoded = typeof chunk === 'string' ? chunk : decoders[stream].write(chunk);
|
|
226
|
+
const lines = (state.partial + decoded).split('\n');
|
|
124
227
|
const rest = lines.pop() ?? '';
|
|
125
228
|
let progressed = false;
|
|
126
229
|
// The first complete line continues the partial one, whose dots were counted as they came.
|
|
127
230
|
let counted = state.countedDots;
|
|
128
231
|
for (const raw of lines) {
|
|
129
232
|
const text = raw.replace(ANSI, '').trimEnd();
|
|
233
|
+
if (bunResults && stream === 'stderr' && closed !== undefined) {
|
|
234
|
+
const header = /^(?:::group::)?(\S.*\.[cm]?[jt]sx?):(?: \(run #\d+\))?$/.exec(text)?.[1];
|
|
235
|
+
if (header !== undefined) {
|
|
236
|
+
bunFile = header.replace(/^\.\//, '');
|
|
237
|
+
bunSummary = false;
|
|
238
|
+
}
|
|
239
|
+
if (/^\s*\d+ tests (?:skipped|todo|failed):$/.test(text))
|
|
240
|
+
bunSummary = true;
|
|
241
|
+
if (!bunSummary)
|
|
242
|
+
bunDiagnostics[stream].push(`${raw}\n`);
|
|
243
|
+
}
|
|
130
244
|
if (DOTS.test(text)) {
|
|
131
245
|
if (!goLifecycle && DOTS.test(text)) {
|
|
132
246
|
progressed ||= text.length > counted;
|
|
133
247
|
}
|
|
134
248
|
}
|
|
135
|
-
else if (finishedLine(text)) {
|
|
249
|
+
else if (finishedLine(text, stream)) {
|
|
136
250
|
progressed = true;
|
|
137
251
|
}
|
|
138
252
|
counted = 0;
|
|
@@ -144,12 +258,24 @@ export function createRunProgress(command = '') {
|
|
|
144
258
|
state.countedDots = dots;
|
|
145
259
|
return progressed;
|
|
146
260
|
},
|
|
261
|
+
error: () => failure,
|
|
147
262
|
inFlight: () => [
|
|
148
263
|
...running,
|
|
149
264
|
...[...packages].flatMap(([name, tests]) => tests.size === 0 ? [name] : [...tests].map((test) => `${name} ${test}`)),
|
|
150
265
|
],
|
|
151
266
|
};
|
|
152
267
|
}
|
|
268
|
+
/** JSON-plus 0.1 flushes each closed result; plain libtest-json buffers a whole binary. */
|
|
269
|
+
export function withTestResultReport(command) {
|
|
270
|
+
if ((command.match(NEXTEST_RUN)?.length ?? 0) !== 1 ||
|
|
271
|
+
command.search(BUN_TEST) !== -1 ||
|
|
272
|
+
command.search(GO_TEST_RUNNER) !== -1 ||
|
|
273
|
+
UNCAPTURED_NEXTEST.test(command))
|
|
274
|
+
return { command, env: {} };
|
|
275
|
+
let reported = withInvocationFlag(command, NEXTEST_RUN, /(?<![\w-])--message-format(?:=|\s+)(?:"[^"]*"|'[^']*'|[^\s]+)/g, '--message-format=libtest-json-plus', true);
|
|
276
|
+
reported = withInvocationFlag(reported, NEXTEST_RUN, /(?<![\w-])--message-format-version(?:=|\s+)(?:"[^"]*"|'[^']*'|[^\s]+)/g, '--message-format-version=0.1', true);
|
|
277
|
+
return { command: reported, env: { NEXTEST_EXPERIMENTAL_LIBTEST_JSON: '1' } };
|
|
278
|
+
}
|
|
153
279
|
/**
|
|
154
280
|
* `command` with its one `bun test` asked for a line of dots, one per finished test: the only per-test report bun
|
|
155
281
|
* prints whoever runs it. A command that runs no bun, more than one runner, or already chose bun's dots is returned
|
|
@@ -35,7 +35,11 @@ export interface TestThreadCeilings {
|
|
|
35
35
|
* ceilings their sizing keeps; cargo-mutants carries how many cargo processes it runs at once, which share its grant.
|
|
36
36
|
*/
|
|
37
37
|
export type Demand = {
|
|
38
|
-
kind: 'cargo'
|
|
38
|
+
kind: 'cargo';
|
|
39
|
+
want: number;
|
|
40
|
+
testThreads: TestThreadCeilings;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'process';
|
|
39
43
|
want: number;
|
|
40
44
|
testThreads: TestThreadCeilings;
|
|
41
45
|
} | {
|
|
@@ -43,11 +47,32 @@ export type Demand = {
|
|
|
43
47
|
want: number;
|
|
44
48
|
jobs: number;
|
|
45
49
|
} | {
|
|
46
|
-
kind:
|
|
50
|
+
kind: 'nextest';
|
|
51
|
+
want: number;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'bun-parallel';
|
|
54
|
+
want: number;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'stryker';
|
|
57
|
+
want: number;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'vitest';
|
|
60
|
+
want: number;
|
|
61
|
+
} | {
|
|
62
|
+
kind: 'go-test';
|
|
47
63
|
want: number;
|
|
48
64
|
};
|
|
65
|
+
/** A runner a leaf reserves for under mbx (mbx-pool.ts, `mbxLeaf`): one that Cargo does not admit through mbx itself. */
|
|
66
|
+
export type ReservedDemand = Extract<Demand, {
|
|
67
|
+
kind: 'nextest' | 'bun-parallel' | 'stryker' | 'process';
|
|
68
|
+
}>;
|
|
49
69
|
/** Every budgeted command learns its grant here, so a script that starts a runner can size it. */
|
|
50
70
|
export declare const CPU_TOKENS_ENV = "BOUNDED_EXEC_CPU_TOKENS";
|
|
71
|
+
/**
|
|
72
|
+
* The cores mbx granted the reservation a leaf runs under: `mbx reserve --cpus N` names at most N to its command, as many
|
|
73
|
+
* as were free once one was.
|
|
74
|
+
*/
|
|
75
|
+
export declare const GRANTED_CPUS_ENV = "MBX_RESERVE_CPUS";
|
|
51
76
|
type WorkerFlagKind = 'stryker' | 'vitest' | 'go-test';
|
|
52
77
|
/**
|
|
53
78
|
* What `command` asks for: its kind by invocation, and `declared` (the target's `parallelism`)
|
|
@@ -86,6 +111,19 @@ export declare function sizeRunner(demand: Demand, command: string, tokens: numb
|
|
|
86
111
|
command: string;
|
|
87
112
|
env: Record<string, string>;
|
|
88
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* The shell statements that run first in a reserved leaf's reservation and size its runner to the grant, which only
|
|
116
|
+
* the command learns as it starts: `CPU_TOKENS_ENV` becomes the cores mbx granted (`GRANTED_CPUS_ENV`), never more
|
|
117
|
+
* than the leaf asked for, its `--cpus` (the runner's own count), which also stands in under an mbx that grants a
|
|
118
|
+
* reservation whole and names none. The test-thread variables a sizing sets follow from it, under their inherited
|
|
119
|
+
* ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`).
|
|
120
|
+
*/
|
|
121
|
+
export declare function grantedSizing(demand: ReservedDemand): string;
|
|
122
|
+
/**
|
|
123
|
+
* `command` with a reserved runner's named count read from its grant, `CPU_TOKENS_ENV` as `grantedSizing` sets it,
|
|
124
|
+
* where the runner's shell runs it; the runner then runs on all it holds.
|
|
125
|
+
*/
|
|
126
|
+
export declare function sizeRunnerToGrant(demand: ReservedDemand, command: string): string;
|
|
89
127
|
/**
|
|
90
128
|
* The count `CPU_TOKENS_ENV` names, as a positive safe integer, or `null` when absent or malformed. It is
|
|
91
129
|
* descriptor input only: a count proves nothing about a live pool and grants nothing. It is a ceiling the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-sizing.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/runner-sizing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,kGAAkG;AAClG,MAAM,MAAM,UAAU;AACpB,mFAAmF;AACjF,SAAS;AACX,mDAAmD;GACjD,cAAc;AAChB,2EAA2E;GACzE,cAAc;AAChB,yHAAyH;GACvH,eAAe;AACjB,kGAAkG;GAChG,OAAO;AACT,2FAA2F;GACzF,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GACd;IAAE,IAAI,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"runner-sizing.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/runner-sizing.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { BUN_TEST,
|
|
1
|
+
import { BUN_TEST, GO_TEST_RUNNER, NEXTEST_RUN } from './verdict.js';
|
|
2
2
|
/** Every budgeted command learns its grant here, so a script that starts a runner can size it. */
|
|
3
3
|
export const CPU_TOKENS_ENV = 'BOUNDED_EXEC_CPU_TOKENS';
|
|
4
|
+
/**
|
|
5
|
+
* The cores mbx granted the reservation a leaf runs under: `mbx reserve --cpus N` names at most N to its command, as many
|
|
6
|
+
* as were free once one was.
|
|
7
|
+
*/
|
|
8
|
+
export const GRANTED_CPUS_ENV = 'MBX_RESERVE_CPUS';
|
|
4
9
|
const CARGO_BUILD = /(?<=^|[\s;&|()])(?:cargo(?:\s+-\S+)*\s+(?:build|test|check|clippy|rustc|doc|run|nextest\s+archive)|napi\s+build)(?=\s|$)/;
|
|
5
10
|
const TEST_THREADS = /--test-threads(?:=|\s+)(\d+)/g;
|
|
6
11
|
/** nextest's `--no-capture` (`--nocapture` past `--`): it runs tests serially and ignores `--test-threads`. */
|
|
@@ -33,9 +38,9 @@ const WORKER_FLAGS = {
|
|
|
33
38
|
ownDefault: (cores) => Math.max(cores - 1, 1),
|
|
34
39
|
serial: /(?<![\w-])(?:--no-file-parallelism|--file(?:P|-p)arallelism=false)(?![\w-])/,
|
|
35
40
|
},
|
|
36
|
-
/** `go test -p`: packages built and tested at once, `GOMAXPROCS` by default, normally one per core. */
|
|
41
|
+
/** `go test -p`: packages built and tested at once, `GOMAXPROCS` by default, normally one per core; prebuilt runs alike. */
|
|
37
42
|
'go-test': {
|
|
38
|
-
invocation:
|
|
43
|
+
invocation: GO_TEST_RUNNER,
|
|
39
44
|
flag: new RegExp(String.raw `(?<![\w-])-p(?:=|\s+)${WORD}`, 'g'),
|
|
40
45
|
sized: (count) => `-p=${count}`,
|
|
41
46
|
ownDefault: (cores, env) => parseInheritedTokens(env.GOMAXPROCS) ?? cores,
|
|
@@ -226,7 +231,7 @@ export function sizeRunner(demand, command, tokens) {
|
|
|
226
231
|
case 'go-test': {
|
|
227
232
|
const runner = WORKER_FLAGS[demand.kind];
|
|
228
233
|
return {
|
|
229
|
-
command: withInvocationFlag(command, runner.invocation, runner.flag, runner.sized(
|
|
234
|
+
command: withInvocationFlag(command, runner.invocation, runner.flag, runner.sized(count), true),
|
|
230
235
|
env: { [CPU_TOKENS_ENV]: held },
|
|
231
236
|
};
|
|
232
237
|
}
|
|
@@ -249,6 +254,52 @@ export function sizeRunner(demand, command, tokens) {
|
|
|
249
254
|
}
|
|
250
255
|
}
|
|
251
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* The shell statements that run first in a reserved leaf's reservation and size its runner to the grant, which only
|
|
259
|
+
* the command learns as it starts: `CPU_TOKENS_ENV` becomes the cores mbx granted (`GRANTED_CPUS_ENV`), never more
|
|
260
|
+
* than the leaf asked for, its `--cpus` (the runner's own count), which also stands in under an mbx that grants a
|
|
261
|
+
* reservation whole and names none. The test-thread variables a sizing sets follow from it, under their inherited
|
|
262
|
+
* ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`).
|
|
263
|
+
*/
|
|
264
|
+
export function grantedSizing(demand) {
|
|
265
|
+
const asked = demand.want;
|
|
266
|
+
const named = `\${${GRANTED_CPUS_ENV}:-${asked}}`;
|
|
267
|
+
const tokens = `$${CPU_TOKENS_ENV}`;
|
|
268
|
+
const atMost = (ceiling) => ceiling === null ? `"${tokens}"` : `"$(( ${tokens} < ${ceiling} ? ${tokens} : ${ceiling} ))"`;
|
|
269
|
+
const statements = [`export ${CPU_TOKENS_ENV}="$(( ${named} < ${asked} ? ${named} : ${asked} ))"`];
|
|
270
|
+
switch (demand.kind) {
|
|
271
|
+
case 'nextest':
|
|
272
|
+
statements.push(`export NEXTEST_TEST_THREADS="${tokens}"`);
|
|
273
|
+
break;
|
|
274
|
+
case 'process':
|
|
275
|
+
// A process's script may start Cargo, whose test threads take no jobserver token: its whole grant.
|
|
276
|
+
statements.push(`export RUST_TEST_THREADS=${atMost(demand.testThreads.rust)}`, `export NEXTEST_TEST_THREADS=${atMost(demand.testThreads.nextest)}`);
|
|
277
|
+
break;
|
|
278
|
+
case 'bun-parallel':
|
|
279
|
+
case 'stryker':
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
return statements.map((statement) => `${statement}; `).join('');
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* `command` with a reserved runner's named count read from its grant, `CPU_TOKENS_ENV` as `grantedSizing` sets it,
|
|
286
|
+
* where the runner's shell runs it; the runner then runs on all it holds.
|
|
287
|
+
*/
|
|
288
|
+
export function sizeRunnerToGrant(demand, command) {
|
|
289
|
+
const granted = `\${${CPU_TOKENS_ENV}}`;
|
|
290
|
+
switch (demand.kind) {
|
|
291
|
+
case 'nextest':
|
|
292
|
+
return command.replace(TEST_THREADS, `--test-threads=${granted}`);
|
|
293
|
+
case 'bun-parallel':
|
|
294
|
+
return command.replace(BUN_PARALLEL, `--parallel=${granted}`);
|
|
295
|
+
case 'stryker': {
|
|
296
|
+
const runner = WORKER_FLAGS.stryker;
|
|
297
|
+
return withInvocationFlag(command, runner.invocation, runner.flag, runner.sized(granted), true);
|
|
298
|
+
}
|
|
299
|
+
case 'process':
|
|
300
|
+
return command;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
252
303
|
/** A configured value may lower an inherited ceiling, never raise it. */
|
|
253
304
|
function inheritedCeiling(inherited, configured) {
|
|
254
305
|
const left = parseInheritedTokens(inherited);
|
|
@@ -5,7 +5,7 @@ import { promisify } from 'node:util';
|
|
|
5
5
|
/**
|
|
6
6
|
* A leg that runs `bun` runs the Bun its workspace declares.
|
|
7
7
|
*
|
|
8
|
-
* The root `package.json` names that Bun in `packageManager` (`bun@
|
|
8
|
+
* The root `package.json` names that Bun in `packageManager` (`bun@x.y.z`); the Bun the command gets is the first `bun`
|
|
9
9
|
* on the PATH it runs with. When the two disagree the leg is refused before it asks for anything, naming both versions
|
|
10
10
|
* and the binary. A Bun other than the declared one does not fail at startup: on Bun 1.4.2 `console.log` drops what a
|
|
11
11
|
* full pipe refuses, so a child's JSON document reaches the parent that reads it cut in the middle of a string, the
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ClosedTestResult } from './test-results.js';
|
|
2
|
+
export { taskDirectory } from './verdict.js';
|
|
3
|
+
/** A runner's closed observation, before the artifact writer assigns its references. */
|
|
4
|
+
export interface NativeTestResult {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly status: ClosedTestResult['status'];
|
|
7
|
+
readonly source: ClosedTestResult['source'];
|
|
8
|
+
readonly contradictsCursor?: number;
|
|
9
|
+
readonly durationMs: number | null;
|
|
10
|
+
readonly sourceRef: string | null;
|
|
11
|
+
readonly failureOutput: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface TestResultWriter {
|
|
14
|
+
/** Completes the evidence write before publishing its referring JSONL record. */
|
|
15
|
+
append(result: NativeTestResult): string | null;
|
|
16
|
+
reconcile(results: readonly NativeTestResult[]): string | null;
|
|
17
|
+
close(): Promise<string | null>;
|
|
18
|
+
}
|
|
19
|
+
/** A new inode and UUID identify a replacement run, even when it has the same byte length. */
|
|
20
|
+
export declare function createTestResultWriter(directory: string, sourceRoot: {
|
|
21
|
+
readonly cwd: string;
|
|
22
|
+
readonly root: string;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
readonly ok: true;
|
|
25
|
+
readonly writer: TestResultWriter;
|
|
26
|
+
} | {
|
|
27
|
+
readonly ok: false;
|
|
28
|
+
readonly error: string;
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=test-result-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-result-writer.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/test-result-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA6D,MAAM,mBAAmB,CAAC;AAErH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAM7C,wFAAwF;AACxF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC5C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAAC;IAChD,SAAS,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/D,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACjC;AA6BD,8FAA8F;AAC9F,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1D,OAAO,CAAC;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CA8FpH"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { parseTestSourceRef, TEST_FAILURES_FILE, TEST_RESULTS_FILE } from './test-results.js';
|
|
2
|
+
export { taskDirectory } from './verdict.js';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { appendFileSync } from 'node:fs';
|
|
5
|
+
import { open, rename, rm } from 'node:fs/promises';
|
|
6
|
+
import { join, relative, resolve, sep } from 'node:path';
|
|
7
|
+
/** The cursor includes its own decimal digits: converge on their width before publishing. */
|
|
8
|
+
function resultLine(result, offset) {
|
|
9
|
+
let cursor = offset;
|
|
10
|
+
for (;;) {
|
|
11
|
+
const line = `${JSON.stringify({ ...result, cursor })}\n`;
|
|
12
|
+
const next = offset + Buffer.byteLength(line);
|
|
13
|
+
if (next === cursor)
|
|
14
|
+
return { line, cursor };
|
|
15
|
+
cursor = next;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function normalizeSourceRef(sourceRef, sourceRoot) {
|
|
19
|
+
const location = parseTestSourceRef(sourceRef);
|
|
20
|
+
if (location === null)
|
|
21
|
+
return null;
|
|
22
|
+
return `${relative(sourceRoot.root, resolve(sourceRoot.cwd, location.path)).split(sep).join('/')}:${location.line}`;
|
|
23
|
+
}
|
|
24
|
+
async function closeResultFiles(files, stagedPaths = []) {
|
|
25
|
+
const results = await Promise.allSettled([
|
|
26
|
+
...files.map((file) => file.close()),
|
|
27
|
+
...stagedPaths.map((path) => rm(path, { force: true })),
|
|
28
|
+
]);
|
|
29
|
+
const failures = results.flatMap((result) => (result.status === 'rejected' ? [String(result.reason)] : []));
|
|
30
|
+
return failures.length === 0 ? null : `closing test result artifacts: ${failures.join('; ')}`;
|
|
31
|
+
}
|
|
32
|
+
/** A new inode and UUID identify a replacement run, even when it has the same byte length. */
|
|
33
|
+
export async function createTestResultWriter(directory, sourceRoot) {
|
|
34
|
+
const runId = randomUUID();
|
|
35
|
+
const target = join(directory, TEST_RESULTS_FILE);
|
|
36
|
+
const staged = `${target}.${runId}`;
|
|
37
|
+
const causePath = join(directory, TEST_FAILURES_FILE);
|
|
38
|
+
const stagedCauses = `${causePath}.${runId}`;
|
|
39
|
+
const [records, causes] = await Promise.allSettled([open(staged, 'ax'), open(stagedCauses, 'ax')]);
|
|
40
|
+
if (records.status !== 'fulfilled' || causes.status !== 'fulfilled') {
|
|
41
|
+
const cleanup = await closeResultFiles([
|
|
42
|
+
...(records.status === 'fulfilled' ? [records.value] : []),
|
|
43
|
+
...(causes.status === 'fulfilled' ? [causes.value] : []),
|
|
44
|
+
], [staged, stagedCauses]);
|
|
45
|
+
const failures = [records, causes].flatMap((result) => result.status === 'rejected' ? [String(result.reason)] : []);
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
error: `initializing test result stream ${target}: ${failures.join('; ')}${cleanup === null ? '' : `; ${cleanup}`}`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
await rename(stagedCauses, causePath);
|
|
53
|
+
await rename(staged, target);
|
|
54
|
+
}
|
|
55
|
+
catch (cause) {
|
|
56
|
+
const cleanup = await closeResultFiles([records.value, causes.value], [staged, stagedCauses]);
|
|
57
|
+
return {
|
|
58
|
+
ok: false,
|
|
59
|
+
error: `initializing test result stream ${target}: ${String(cause)}${cleanup === null ? '' : `; ${cleanup}`}`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
let offset = 0;
|
|
63
|
+
let causeOffset = 0;
|
|
64
|
+
let failure = null;
|
|
65
|
+
let closing = null;
|
|
66
|
+
const provisional = new Map();
|
|
67
|
+
return {
|
|
68
|
+
ok: true,
|
|
69
|
+
writer: {
|
|
70
|
+
append(result) {
|
|
71
|
+
if (failure !== null)
|
|
72
|
+
return failure;
|
|
73
|
+
if (closing !== null)
|
|
74
|
+
return `appending test result ${result.id} to ${target}: stream is closed`;
|
|
75
|
+
try {
|
|
76
|
+
let causeRef = null;
|
|
77
|
+
if (result.status === 'fail' && result.failureOutput !== null) {
|
|
78
|
+
const endByte = causeOffset + Buffer.byteLength(result.failureOutput);
|
|
79
|
+
appendFileSync(causes.value.fd, result.failureOutput);
|
|
80
|
+
causeRef = { path: TEST_FAILURES_FILE, startByte: causeOffset, endByte };
|
|
81
|
+
causeOffset = endByte;
|
|
82
|
+
}
|
|
83
|
+
const { line, cursor } = resultLine({
|
|
84
|
+
runId,
|
|
85
|
+
id: result.id,
|
|
86
|
+
status: result.status,
|
|
87
|
+
source: result.source,
|
|
88
|
+
...(result.contradictsCursor === undefined ? {} : { contradictsCursor: result.contradictsCursor }),
|
|
89
|
+
durationMs: result.durationMs,
|
|
90
|
+
sourceRef: normalizeSourceRef(result.sourceRef, sourceRoot),
|
|
91
|
+
causeRef,
|
|
92
|
+
}, offset);
|
|
93
|
+
// appendFileSync has no user-space buffering: each LF is visible before append returns.
|
|
94
|
+
appendFileSync(records.value.fd, line);
|
|
95
|
+
offset = cursor;
|
|
96
|
+
if (result.source === 'progress')
|
|
97
|
+
provisional.set(result.id, { status: result.status, cursor });
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
catch (cause) {
|
|
101
|
+
failure = `appending test result ${result.id} to ${target}: ${String(cause)}`;
|
|
102
|
+
return failure;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
reconcile(results) {
|
|
106
|
+
for (const result of results) {
|
|
107
|
+
const prior = provisional.get(result.id);
|
|
108
|
+
if (prior !== undefined && prior.status === result.status)
|
|
109
|
+
continue;
|
|
110
|
+
const error = this.append({
|
|
111
|
+
...result,
|
|
112
|
+
source: 'junit',
|
|
113
|
+
...(prior === undefined ? {} : { contradictsCursor: prior.cursor }),
|
|
114
|
+
});
|
|
115
|
+
if (error !== null)
|
|
116
|
+
return error;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
},
|
|
120
|
+
close() {
|
|
121
|
+
closing ??= closeResultFiles([records.value, causes.value]);
|
|
122
|
+
return closing;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type tags } from 'typia';
|
|
2
|
+
export declare const TEST_RESULTS_FILE = "test-results.jsonl";
|
|
3
|
+
export declare const TEST_FAILURES_FILE = "test-failures.log";
|
|
4
|
+
type ByteOffset = number & tags.Type<'uint64'> & tags.Maximum<9007199254740991>;
|
|
5
|
+
/** Live observations, not gate evidence: report.xml and verdict.json remain authoritative. */
|
|
6
|
+
export interface ClosedTestResult {
|
|
7
|
+
readonly runId: string & tags.Format<'uuid'>;
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly status: 'pass' | 'fail' | 'skip';
|
|
10
|
+
readonly source: 'native' | 'progress' | 'junit';
|
|
11
|
+
/** Set only on a terminal JUnit correction of a provisional progress observation. */
|
|
12
|
+
readonly contradictsCursor?: ByteOffset;
|
|
13
|
+
/** Null when the native runner reports no duration (for example a skipped test). */
|
|
14
|
+
readonly durationMs: (number & tags.Minimum<0>) | null;
|
|
15
|
+
/** Native file:line, never a location inferred from human output. */
|
|
16
|
+
readonly sourceRef: string | null;
|
|
17
|
+
/** UTF-8 byte range [startByte, endByte), relative to the task artifact directory. */
|
|
18
|
+
readonly causeRef: {
|
|
19
|
+
readonly path: typeof TEST_FAILURES_FILE;
|
|
20
|
+
readonly startByte: ByteOffset;
|
|
21
|
+
readonly endByte: ByteOffset;
|
|
22
|
+
} | null;
|
|
23
|
+
/** Next UTF-8 byte offset in test-results.jsonl, including this record's LF. */
|
|
24
|
+
readonly cursor: ByteOffset;
|
|
25
|
+
}
|
|
26
|
+
export declare const isClosedTestResult: (input: unknown) => input is ClosedTestResult;
|
|
27
|
+
/** A producer-normalized workspace-relative declaration location, never inferred from a test name. */
|
|
28
|
+
export declare function parseTestSourceRef(sourceRef: string | null): {
|
|
29
|
+
path: string;
|
|
30
|
+
line: number;
|
|
31
|
+
} | null;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=test-results.d.ts.map
|