@testsprite/testsprite-cli 0.16.0 → 0.17.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 +51 -147
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +48 -63
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +38 -54
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +293 -487
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +702 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +129 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +108 -66
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +388 -37
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -229
- package/dist/commands/project.d.ts +15 -186
- package/dist/commands/project.js +89 -924
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +215 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1816
- package/dist/commands/test.js +1951 -13902
- package/dist/commands/testlist.d.ts +128 -5
- package/dist/commands/testlist.js +269 -339
- package/dist/commands/tunnel.d.ts +2 -2
- package/dist/commands/tunnel.js +23 -19
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +182 -104
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +10 -2
- package/dist/lib/client-factory.js +38 -26
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +9 -3
- package/dist/lib/conflict-reason.js +6 -3
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +71 -0
- package/dist/lib/conversation/api.js +150 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +19 -0
- package/dist/lib/conversation/context.js +70 -0
- package/dist/lib/conversation/environment.d.ts +15 -0
- package/dist/lib/conversation/environment.js +33 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +315 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +156 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +71 -0
- package/dist/lib/download.js +274 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +375 -747
- package/dist/lib/environment-tunnel.d.ts +16 -27
- package/dist/lib/environment-tunnel.js +161 -154
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +16 -22
- package/dist/lib/first-suite-hint.js +38 -47
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +352 -289
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +57 -4
- package/dist/lib/junit-report.js +202 -32
- package/dist/lib/local-target.d.ts +3 -3
- package/dist/lib/local-target.js +3 -3
- package/dist/lib/output.d.ts +1 -40
- package/dist/lib/output.js +11 -49
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +154 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +207 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +71 -0
- package/dist/lib/result/evidence.js +420 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +118 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +1 -1
- package/dist/lib/target-url.js +6 -16
- package/dist/lib/telemetry.d.ts +31 -11
- package/dist/lib/telemetry.js +37 -8
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +7 -1
- package/dist/lib/tunnel-session.js +22 -9
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/skills/testsprite-ci.skill.md +48 -18
- package/skills/testsprite-onboard.skill.md +66 -151
- package/skills/testsprite-verify.codex.md +50 -52
- package/skills/testsprite-verify.skill.md +184 -351
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -32
- package/dist/lib/deprecate.js +0 -39
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/lib/interrupt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Termination signals: without a handler, Node terminates the process abruptly
|
|
5
5
|
* with no output, so a user (Ctrl+C), a CI runner or `docker stop` (SIGTERM), or
|
|
6
6
|
* a closed terminal/SSH session (SIGHUP) that interrupts a long
|
|
7
|
-
* `
|
|
7
|
+
* `run --wait` is left unsure whether the run was cancelled or is still
|
|
8
8
|
* executing server-side (it is: the CLI only polls; the run lives on the
|
|
9
9
|
* backend). The handler prints a one-line explanation plus how to resume, then
|
|
10
10
|
* exits with the conventional `128 + signal` code.
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* Broken pipe: when output is piped to a reader that closes early
|
|
13
13
|
* (`testsprite ... | head`), the kernel raises `EPIPE` on the next stdout write.
|
|
14
14
|
* Node turns an `'error'` with no listener into an uncaughtException and dumps a
|
|
15
|
-
* raw `write EPIPE` stack (exit 1). Outside an armed lifetime the guard
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* raw `write EPIPE` stack (exit 1). Outside an armed lifetime the guard lets
|
|
16
|
+
* the command settle so its own exit code (a failing verdict included) stands,
|
|
17
|
+
* with a backstop exit for a process left idle; a clean result still exits 0.
|
|
18
|
+
* While armed it first requests coordinated shutdown so tunnel cleanup can
|
|
19
|
+
* finish, then the same synthetic interrupt reason preserves exit 0.
|
|
19
20
|
*
|
|
20
21
|
* `process` and the streams are injectable so the wiring is unit-testable
|
|
21
22
|
* without spawning a subprocess or sending a real signal.
|
|
@@ -49,7 +50,7 @@ export interface ShutdownHandle {
|
|
|
49
50
|
* Two modes, chosen by whether a graceful-detach scope is armed when the
|
|
50
51
|
* signal arrives:
|
|
51
52
|
*
|
|
52
|
-
* - **Armed** (inside `
|
|
53
|
+
* - **Armed** (inside `waitForRun` or a tunnel lifetime): the handler only aborts
|
|
53
54
|
* `signal` with an `InterruptError` — no I/O, no exit. The in-flight fetch
|
|
54
55
|
* and every backoff sleep bail immediately; the `--wait` catch blocks own
|
|
55
56
|
* the cleanup (finalize the ticker, print the honest partial envelope +
|
|
@@ -138,12 +139,17 @@ export interface BrokenPipeDeps {
|
|
|
138
139
|
exit?: (code: number) => void;
|
|
139
140
|
/** Shutdown coordinator. Defaults to {@link globalShutdown}. */
|
|
140
141
|
shutdown?: ShutdownController;
|
|
142
|
+
/** Backstop timer. Defaults to `setTimeout`. */
|
|
143
|
+
setTimer?: (callback: () => void, delayMs: number) => Pick<NodeJS.Timeout, 'unref'>;
|
|
144
|
+
/** The exit code set so far. Defaults to reading `process.exitCode`. */
|
|
145
|
+
exitCode?: () => number | string | null | undefined;
|
|
141
146
|
}
|
|
142
147
|
/**
|
|
143
148
|
* Guard against `EPIPE` on stdout/stderr so piping to a reader that closes
|
|
144
149
|
* early (`testsprite ... | head`) exits cleanly instead of crashing with an
|
|
145
150
|
* unhandled `write EPIPE` stack. An armed stdout path requests graceful
|
|
146
|
-
* shutdown before exiting 0; a disarmed one
|
|
147
|
-
*
|
|
151
|
+
* shutdown before exiting 0; a disarmed one leaves the exit code to the
|
|
152
|
+
* command and only arms a backstop. Only `EPIPE` is swallowed; any other
|
|
153
|
+
* stream error is left to surface normally.
|
|
148
154
|
*/
|
|
149
155
|
export declare function installBrokenPipeGuard(deps?: BrokenPipeDeps): void;
|
package/dist/lib/interrupt.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Termination signals: without a handler, Node terminates the process abruptly
|
|
5
5
|
* with no output, so a user (Ctrl+C), a CI runner or `docker stop` (SIGTERM), or
|
|
6
6
|
* a closed terminal/SSH session (SIGHUP) that interrupts a long
|
|
7
|
-
* `
|
|
7
|
+
* `run --wait` is left unsure whether the run was cancelled or is still
|
|
8
8
|
* executing server-side (it is: the CLI only polls; the run lives on the
|
|
9
9
|
* backend). The handler prints a one-line explanation plus how to resume, then
|
|
10
10
|
* exits with the conventional `128 + signal` code.
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* Broken pipe: when output is piped to a reader that closes early
|
|
13
13
|
* (`testsprite ... | head`), the kernel raises `EPIPE` on the next stdout write.
|
|
14
14
|
* Node turns an `'error'` with no listener into an uncaughtException and dumps a
|
|
15
|
-
* raw `write EPIPE` stack (exit 1). Outside an armed lifetime the guard
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* raw `write EPIPE` stack (exit 1). Outside an armed lifetime the guard lets
|
|
16
|
+
* the command settle so its own exit code (a failing verdict included) stands,
|
|
17
|
+
* with a backstop exit for a process left idle; a clean result still exits 0.
|
|
18
|
+
* While armed it first requests coordinated shutdown so tunnel cleanup can
|
|
19
|
+
* finish, then the same synthetic interrupt reason preserves exit 0.
|
|
19
20
|
*
|
|
20
21
|
* `process` and the streams are injectable so the wiring is unit-testable
|
|
21
22
|
* without spawning a subprocess or sending a real signal.
|
|
@@ -38,7 +39,7 @@ export function armInterruptExitBackstop(code, deps = {}) {
|
|
|
38
39
|
* Two modes, chosen by whether a graceful-detach scope is armed when the
|
|
39
40
|
* signal arrives:
|
|
40
41
|
*
|
|
41
|
-
* - **Armed** (inside `
|
|
42
|
+
* - **Armed** (inside `waitForRun` or a tunnel lifetime): the handler only aborts
|
|
42
43
|
* `signal` with an `InterruptError` — no I/O, no exit. The in-flight fetch
|
|
43
44
|
* and every backoff sleep bail immediately; the `--wait` catch blocks own
|
|
44
45
|
* the cleanup (finalize the ticker, print the honest partial envelope +
|
|
@@ -146,7 +147,9 @@ class BrokenPipeInterruptError extends InterruptError {
|
|
|
146
147
|
export const globalShutdown = new ShutdownController();
|
|
147
148
|
export function formatInterruptMessage(signal = 'SIGINT') {
|
|
148
149
|
return (`Interrupted (${signal}). Any run already started keeps executing on the server; ` +
|
|
149
|
-
'check it with `testsprite
|
|
150
|
+
'check it with `testsprite run wait <run-id>` or `testsprite result list --run <run-id>`, ' +
|
|
151
|
+
// This line is printed before a command had a run id to print, usually.
|
|
152
|
+
'or, with no run id printed yet, find it with `testsprite result list --test <test-id>`.');
|
|
150
153
|
}
|
|
151
154
|
const CRITICAL_OPERATION_GRACE_MS = 2_000;
|
|
152
155
|
/** How often the grace period re-checks whether tracked work is still running. */
|
|
@@ -272,14 +275,18 @@ export function installSignalHandlers(deps = {}) {
|
|
|
272
275
|
* Guard against `EPIPE` on stdout/stderr so piping to a reader that closes
|
|
273
276
|
* early (`testsprite ... | head`) exits cleanly instead of crashing with an
|
|
274
277
|
* unhandled `write EPIPE` stack. An armed stdout path requests graceful
|
|
275
|
-
* shutdown before exiting 0; a disarmed one
|
|
276
|
-
*
|
|
278
|
+
* shutdown before exiting 0; a disarmed one leaves the exit code to the
|
|
279
|
+
* command and only arms a backstop. Only `EPIPE` is swallowed; any other
|
|
280
|
+
* stream error is left to surface normally.
|
|
277
281
|
*/
|
|
278
282
|
export function installBrokenPipeGuard(deps = {}) {
|
|
279
283
|
const stdout = deps.stdout ?? process.stdout;
|
|
280
284
|
const stderr = deps.stderr ?? process.stderr;
|
|
281
285
|
const exit = deps.exit ?? ((code) => process.exit(code));
|
|
282
286
|
const shutdown = deps.shutdown ?? globalShutdown;
|
|
287
|
+
const setTimer = deps.setTimer ?? setTimeout;
|
|
288
|
+
const exitCode = deps.exitCode ?? (() => process.exitCode);
|
|
289
|
+
let backstopArmed = false;
|
|
283
290
|
stdout.on('error', (error) => {
|
|
284
291
|
// Reader went away (`| head`, `| less` then q): exit cleanly like SIGPIPE
|
|
285
292
|
// rather than dumping an unhandled `write EPIPE` stack. Any other stdout
|
|
@@ -292,7 +299,18 @@ export function installBrokenPipeGuard(deps = {}) {
|
|
|
292
299
|
shutdown.brokenPipe();
|
|
293
300
|
return;
|
|
294
301
|
}
|
|
295
|
-
exit
|
|
302
|
+
// Exiting here would race index.ts, which sets a failing verdict's exit
|
|
303
|
+
// code only after an async telemetry flush, and turn it into 0. Let the
|
|
304
|
+
// command settle; once the event loop drains the process exits with the
|
|
305
|
+
// code it set. The unref'd backstop only fires when something keeps the
|
|
306
|
+
// process alive (an idle prompt, a stdout `drain` that never comes).
|
|
307
|
+
if (backstopArmed)
|
|
308
|
+
return;
|
|
309
|
+
backstopArmed = true;
|
|
310
|
+
setTimer(() => {
|
|
311
|
+
const code = Number(exitCode() ?? 0);
|
|
312
|
+
exit(Number.isInteger(code) ? code : 0);
|
|
313
|
+
}, INTERRUPT_EXIT_BACKSTOP_MS).unref();
|
|
296
314
|
return;
|
|
297
315
|
}
|
|
298
316
|
throw error;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { type CiSummary } from './gh-output.js';
|
|
1
|
+
import { type CiRunRow, type CiSummary } from './gh-output.js';
|
|
2
2
|
export type JUnitReportFormat = 'junit';
|
|
3
|
-
/** Minimal testcase input shared by batch run and
|
|
3
|
+
/** Minimal testcase input shared by the batch `run` and `run --testlist` poll results. */
|
|
4
4
|
export interface JUnitTestResult {
|
|
5
5
|
testId: string;
|
|
6
|
+
/** The result id (wire name); the `resultId` attribute of the testcase. */
|
|
7
|
+
resultId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The launch the result belongs to (wire name). When every case that names
|
|
10
|
+
* a result shares it, it is the `resultId` attribute of the testsuite.
|
|
11
|
+
*/
|
|
6
12
|
runId?: string;
|
|
7
13
|
status: string;
|
|
8
14
|
/** Observed on polled runs; used for classname when --project is omitted. */
|
|
@@ -45,7 +51,7 @@ export interface JUnitReportFlagOptions {
|
|
|
45
51
|
reportFile?: string;
|
|
46
52
|
reportSuiteName?: string;
|
|
47
53
|
wait: boolean;
|
|
48
|
-
/** True when the invocation is a batch path (
|
|
54
|
+
/** True when the invocation is a batch path (a project or several named IDs). */
|
|
49
55
|
batchPath: boolean;
|
|
50
56
|
}
|
|
51
57
|
/**
|
|
@@ -75,11 +81,29 @@ export declare function escapeXml(text: string): string;
|
|
|
75
81
|
* Build a JUnit XML document from batch results, including skipped members. Per-`testcase` `time` is
|
|
76
82
|
* the run's wall-clock duration (from `startedAt`/`finishedAt`); the `testsuite`
|
|
77
83
|
* `time` is their sum. `time` falls back to `0` for a run with no timing.
|
|
84
|
+
*
|
|
85
|
+
* A testcase carries the `resultId` it names. The testsuite carries `resultId`:
|
|
86
|
+
* the launch the testcases that ran here share, and only when every testcase
|
|
87
|
+
* that names a result, skipped ones included, belongs to it too. So a suite
|
|
88
|
+
* with a skipped test another run holds, one whose tests ran in several
|
|
89
|
+
* launches, one where nothing ran (all of it held by an earlier run), or one
|
|
90
|
+
* from a backend that names no launch, carries none. A test this invocation
|
|
91
|
+
* joined (already running, then waited on) ran here, so a batch that only
|
|
92
|
+
* joined one run names that run. A test that never got a result names no
|
|
93
|
+
* launch and does not count.
|
|
78
94
|
*/
|
|
79
95
|
export declare function buildJUnitReport(opts: JUnitReportBuildOptions): string;
|
|
96
|
+
/**
|
|
97
|
+
* One non-dispatched summary row as a skipped JUnit result, with its reason
|
|
98
|
+
* (or its status when it has none). A test another run already holds keeps
|
|
99
|
+
* that run's result and launch.
|
|
100
|
+
*/
|
|
101
|
+
export declare function skippedRowFromSummary(row: CiRunRow): JUnitTestResult;
|
|
80
102
|
/**
|
|
81
103
|
* The summary's non-dispatched rows (deferred / conflict / not-found) as
|
|
82
|
-
* skipped JUnit results.
|
|
104
|
+
* skipped JUnit results. A test another run already holds names that run's
|
|
105
|
+
* result and launch, so the suite does not name its launch as this
|
|
106
|
+
* invocation's run (see `buildJUnitReport`). Accepted rows carry run statuses and today never
|
|
83
107
|
* match `isNonDispatchedStatus`, but the two vocabularies are only disjoint
|
|
84
108
|
* by convention: `skipped` is a word both could use. So a member already in
|
|
85
109
|
* `dispatched` (the polled results the caller is writing) is left out here
|
|
@@ -87,7 +111,36 @@ export declare function buildJUnitReport(opts: JUnitReportBuildOptions): string;
|
|
|
87
111
|
* member twice if the server ever reports such a status for an admitted run.
|
|
88
112
|
*/
|
|
89
113
|
export declare function skippedJUnitResultsFromSummary(summary: CiSummary, dispatched?: ReadonlyArray<Pick<JUnitTestResult, 'testId'>>): JUnitTestResult[];
|
|
114
|
+
/**
|
|
115
|
+
* The summary's rows as the report of a batch that stopped before its runs
|
|
116
|
+
* were awaited: a test that never dispatched is skipped with its reason, and
|
|
117
|
+
* every other row is an error with its own note, or `failure` when it has
|
|
118
|
+
* none. Each row keeps its result and launch.
|
|
119
|
+
*/
|
|
120
|
+
export declare function junitRowsFromSummary(summary: CiSummary, failure: string): JUnitTestResult[];
|
|
121
|
+
/**
|
|
122
|
+
* Check that an output artifact path (`--report-file`, `--summary-file`) can be
|
|
123
|
+
* written: non-empty, not a directory, and inside an existing directory.
|
|
124
|
+
* Returns the resolved absolute path.
|
|
125
|
+
*
|
|
126
|
+
* Called in each command's pre-flight, before anything is dispatched or billed,
|
|
127
|
+
* so a mistyped directory fails fast with exit 5 instead of surfacing only after
|
|
128
|
+
* a full batch has run. The write itself re-checks (the directory can vanish in
|
|
129
|
+
* between).
|
|
130
|
+
*/
|
|
131
|
+
export declare function assertArtifactPath(field: 'report-file' | 'summary-file', rawPath: string): string;
|
|
90
132
|
/**
|
|
91
133
|
* Atomically write JUnit XML to `--report-file` (temp sibling + rename).
|
|
92
134
|
*/
|
|
93
135
|
export declare function writeJUnitReportFile(rawPath: string, xml: string): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Write a run's JUnit report (`write`) when the command may already owe an
|
|
138
|
+
* exit: a failed or timed-out test, one not dispatched, a refused request.
|
|
139
|
+
* Then the report is best-effort: one that cannot be written (its directory
|
|
140
|
+
* gone, say) is a line on stderr and the exit owed stands. With nothing owed,
|
|
141
|
+
* the write's error is the command's. An interrupt always propagates.
|
|
142
|
+
*/
|
|
143
|
+
export declare function writeReportOwing(owesAnExit: boolean, write: () => Promise<void>, stderr: (line: string) => void, context: {
|
|
144
|
+
label: string;
|
|
145
|
+
what?: string;
|
|
146
|
+
}): Promise<void>;
|
package/dist/lib/junit-report.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { createWriteStream } from 'node:fs';
|
|
2
|
-
import { rename,
|
|
1
|
+
import { createWriteStream, statSync } from 'node:fs';
|
|
2
|
+
import { rename, unlink } from 'node:fs/promises';
|
|
3
3
|
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
|
-
import { localValidationError, TransportError } from './errors.js';
|
|
5
|
+
import { InterruptError, localValidationError, TransportError } from './errors.js';
|
|
6
6
|
import { isNonDispatchedStatus } from './gh-output.js';
|
|
7
|
+
import { sharedLaunchId } from './run-render.js';
|
|
7
8
|
/**
|
|
8
9
|
* Duration in seconds between two ISO timestamps, or `undefined` when either is
|
|
9
10
|
* missing / unparseable / negative (clock skew). Prefer startedAt, falling back
|
|
@@ -52,7 +53,7 @@ export function assertJUnitReportOptions(opts) {
|
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
55
|
if (!opts.batchPath) {
|
|
55
|
-
throw localValidationError('report', '--report junit only applies to batch --wait runs (
|
|
56
|
+
throw localValidationError('report', '--report junit only applies to batch --wait runs (run --project, or multiple test ids)');
|
|
56
57
|
}
|
|
57
58
|
if (!opts.wait) {
|
|
58
59
|
throw localValidationError('report', '--report junit requires --wait (the report is written after batch polling completes)');
|
|
@@ -80,11 +81,22 @@ export function resolveBatchReportProjectId(opts, results) {
|
|
|
80
81
|
return [...known][0];
|
|
81
82
|
throw localValidationError('project', '--report junit requires --project <id> when the project cannot be inferred from run results');
|
|
82
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Characters XML 1.0 forbids anywhere in a document: the `Char` production
|
|
86
|
+
* allows only #x9, #xA, #xD, [#x20-#xD7FF], [#xE000-#xFFFD] and
|
|
87
|
+
* [#x10000-#x10FFFF]. No entity can represent the excluded characters, so
|
|
88
|
+
* they are stripped rather than escaped — a single one in a free-text run
|
|
89
|
+
* message (LLM / server supplied) makes strict parsers reject the whole
|
|
90
|
+
* report. Tab, newline and carriage return are legal and preserved.
|
|
91
|
+
*/
|
|
92
|
+
// eslint-disable-next-line no-control-regex
|
|
93
|
+
const XML_1_0_ILLEGAL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g;
|
|
83
94
|
/**
|
|
84
95
|
* Escape text for inclusion in XML element bodies and double-quoted attributes.
|
|
85
96
|
*/
|
|
86
97
|
export function escapeXml(text) {
|
|
87
98
|
return text
|
|
99
|
+
.replace(XML_1_0_ILLEGAL_CHARS, '')
|
|
88
100
|
.replace(/&/g, '&')
|
|
89
101
|
.replace(/</g, '<')
|
|
90
102
|
.replace(/>/g, '>')
|
|
@@ -94,7 +106,7 @@ export function escapeXml(text) {
|
|
|
94
106
|
function classifyJUnitOutcome(status, error) {
|
|
95
107
|
if (status === 'passed')
|
|
96
108
|
return 'passed';
|
|
97
|
-
if (isNonDispatchedStatus(status))
|
|
109
|
+
if (status === 'running' || isNonDispatchedStatus(status))
|
|
98
110
|
return 'skipped';
|
|
99
111
|
if (status === 'error' || error?.exitCode === 3)
|
|
100
112
|
return 'error';
|
|
@@ -107,25 +119,30 @@ function failureMessage(result) {
|
|
|
107
119
|
return result.error.code;
|
|
108
120
|
return result.status;
|
|
109
121
|
}
|
|
110
|
-
function renderTestcase(result, classname) {
|
|
122
|
+
function renderTestcase(result, classname, displayName) {
|
|
111
123
|
const outcome = classifyJUnitOutcome(result.status, result.error);
|
|
112
124
|
// A readable CI test tab keys on `name`: prefer the human test name, fall back
|
|
113
125
|
// to the id. The UUID is preserved as a `testId` attribute (ignored by
|
|
114
126
|
// renderers, read by machine consumers) so the switch loses no information.
|
|
115
|
-
|
|
127
|
+
// `displayName` carries the precomputed disambiguated name for colliding
|
|
128
|
+
// groups (see resolveJUnitDisplayNames).
|
|
129
|
+
const name = escapeXml(displayName ?? (result.name?.trim() || result.testId));
|
|
116
130
|
const cls = escapeXml(classname);
|
|
117
131
|
const time = formatTime(result.durationSeconds);
|
|
118
132
|
const idAttr = ` testId="${escapeXml(result.testId)}"`;
|
|
119
|
-
|
|
133
|
+
// The testcase names its own result. Its launch is the suite's, when the
|
|
134
|
+
// suite has one.
|
|
135
|
+
const { resultId } = { resultId: result.resultId };
|
|
136
|
+
const resultAttr = resultId ? ` resultId="${escapeXml(resultId)}"` : '';
|
|
120
137
|
const lines = [
|
|
121
|
-
` <testcase classname="${cls}" name="${name}"${idAttr}${
|
|
138
|
+
` <testcase classname="${cls}" name="${name}"${idAttr}${resultAttr} time="${time}">`,
|
|
122
139
|
];
|
|
123
140
|
if (outcome === 'failure') {
|
|
124
141
|
const message = escapeXml(failureMessage(result));
|
|
125
142
|
const type = escapeXml(result.status);
|
|
126
143
|
const body = escapeXml([
|
|
127
144
|
`status: ${result.status}`,
|
|
128
|
-
|
|
145
|
+
resultId ? `resultId: ${resultId}` : undefined,
|
|
129
146
|
result.error?.code ? `code: ${result.error.code}` : undefined,
|
|
130
147
|
result.error?.message ? `message: ${result.error.message}` : undefined,
|
|
131
148
|
]
|
|
@@ -139,22 +156,89 @@ function renderTestcase(result, classname) {
|
|
|
139
156
|
const body = escapeXml([
|
|
140
157
|
result.error?.code ? `code: ${result.error.code}` : undefined,
|
|
141
158
|
result.error?.message ? `message: ${result.error.message}` : undefined,
|
|
142
|
-
|
|
159
|
+
resultId ? `resultId: ${resultId}` : undefined,
|
|
143
160
|
]
|
|
144
161
|
.filter(Boolean)
|
|
145
162
|
.join('\n'));
|
|
146
163
|
lines.push(` <error message="${message}" type="${type}">${body}</error>`);
|
|
147
164
|
}
|
|
148
165
|
else if (outcome === 'skipped') {
|
|
149
|
-
|
|
166
|
+
const reason = result.status === 'running'
|
|
167
|
+
? 'Still running when the wait ended'
|
|
168
|
+
: (result.skipReason ?? failureMessage(result));
|
|
169
|
+
lines.push(` <skipped message="${escapeXml(reason)}"/>`);
|
|
150
170
|
}
|
|
151
171
|
lines.push(' </testcase>');
|
|
152
172
|
return lines.join('\n');
|
|
153
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Standard JUnit consumers (GitLab, Jenkins) key a testcase on classname+name
|
|
176
|
+
* and ignore extra attributes, so rows sharing both collapse into one — a
|
|
177
|
+
* same-name pair from a multi-project list then loses one verdict and one
|
|
178
|
+
* run's diagnostics (#515). The stable logical testId — not the ephemeral
|
|
179
|
+
* result id, which would break cross-run comparison — joins the standard identity
|
|
180
|
+
* for colliding groups only: unique names render exactly as before.
|
|
181
|
+
*/
|
|
182
|
+
function resolveJUnitDisplayNames(results, fallbackClassname) {
|
|
183
|
+
const rawNames = results.map(result => result.name?.trim() || result.testId);
|
|
184
|
+
const names = [...rawNames];
|
|
185
|
+
// XML consumers normalize attribute whitespace: line endings collapse first
|
|
186
|
+
// (CRLF/CR → LF), then tabs/newlines/carriage returns each become a space.
|
|
187
|
+
// Raw-distinct names can therefore share an identity downstream, so the
|
|
188
|
+
// collision keys use the normalized form; rendering keeps the original text.
|
|
189
|
+
const attributeKey = (value) => value.replace(/\r\n?/g, '\n').replace(/[\n\t]/g, ' ');
|
|
190
|
+
const keyOf = (classname, name) => `${attributeKey(classname)}\u0000${attributeKey(name)}`;
|
|
191
|
+
// The suffix must stay injective under attributeKey normalization, or two raw-distinct
|
|
192
|
+
// ids ("a\tb" vs "a b") re-collide after suffixing and the round cap gives up leaving
|
|
193
|
+
// duplicate identities. JSON-escaping (minus the surrounding quotes) encodes control
|
|
194
|
+
// characters as visible two-char escapes, so distinct ids render distinct suffixes
|
|
195
|
+
// that normalization cannot fold; ids without escapes render unchanged.
|
|
196
|
+
const displayTestId = (testId) => JSON.stringify(testId).slice(1, -1);
|
|
197
|
+
// Suffixing can itself collide with a row whose human title already looks
|
|
198
|
+
// like a suffixed one ("Checkout [case-a]" as a literal name), so iterate
|
|
199
|
+
// until no (classname, name) pair collides. Each round's colliding set gets
|
|
200
|
+
// an injective encoded suffix, so the set ends pairwise distinct and the
|
|
201
|
+
// loop terminates. A group whose rows all share one testId can never be
|
|
202
|
+
// separated by any suffix — the rows are exact duplicates — so it is left
|
|
203
|
+
// alone instead of spinning to the round cap (run --testlist can pass the
|
|
204
|
+
// same id twice, billing each row).
|
|
205
|
+
for (let round = 0; round <= results.length; round++) {
|
|
206
|
+
const groups = new Map();
|
|
207
|
+
results.forEach((result, index) => {
|
|
208
|
+
const key = keyOf(result.classname ?? fallbackClassname, names[index]);
|
|
209
|
+
const group = groups.get(key) ?? { count: 0, testIds: new Set() };
|
|
210
|
+
group.count += 1;
|
|
211
|
+
group.testIds.add(result.testId);
|
|
212
|
+
groups.set(key, group);
|
|
213
|
+
});
|
|
214
|
+
let changed = false;
|
|
215
|
+
results.forEach((result, index) => {
|
|
216
|
+
const key = keyOf(result.classname ?? fallbackClassname, names[index]);
|
|
217
|
+
const group = groups.get(key);
|
|
218
|
+
if (group.count > 1 && group.testIds.size > 1) {
|
|
219
|
+
names[index] = `${names[index]} [${displayTestId(result.testId)}]`;
|
|
220
|
+
changed = true;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
if (!changed)
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
return names.map((name, index) => (name === rawNames[index] ? undefined : name));
|
|
227
|
+
}
|
|
154
228
|
/**
|
|
155
229
|
* Build a JUnit XML document from batch results, including skipped members. Per-`testcase` `time` is
|
|
156
230
|
* the run's wall-clock duration (from `startedAt`/`finishedAt`); the `testsuite`
|
|
157
231
|
* `time` is their sum. `time` falls back to `0` for a run with no timing.
|
|
232
|
+
*
|
|
233
|
+
* A testcase carries the `resultId` it names. The testsuite carries `resultId`:
|
|
234
|
+
* the launch the testcases that ran here share, and only when every testcase
|
|
235
|
+
* that names a result, skipped ones included, belongs to it too. So a suite
|
|
236
|
+
* with a skipped test another run holds, one whose tests ran in several
|
|
237
|
+
* launches, one where nothing ran (all of it held by an earlier run), or one
|
|
238
|
+
* from a backend that names no launch, carries none. A test this invocation
|
|
239
|
+
* joined (already running, then waited on) ran here, so a batch that only
|
|
240
|
+
* joined one run names that run. A test that never got a result names no
|
|
241
|
+
* launch and does not count.
|
|
158
242
|
*/
|
|
159
243
|
export function buildJUnitReport(opts) {
|
|
160
244
|
const results = opts.results;
|
|
@@ -175,20 +259,44 @@ export function buildJUnitReport(opts) {
|
|
|
175
259
|
}
|
|
176
260
|
}
|
|
177
261
|
const suiteName = escapeXml(opts.suiteName);
|
|
178
|
-
|
|
262
|
+
// The run this invocation's tests ran in, and only when no testcase, skipped
|
|
263
|
+
// ones included, names a result of another run.
|
|
264
|
+
const own = sharedLaunchId(results.filter(result => !isNonDispatchedStatus(result.status)));
|
|
265
|
+
const launchId = own !== undefined && sharedLaunchId(results) === own ? own : undefined;
|
|
266
|
+
const runAttr = launchId !== undefined ? ` runId="${escapeXml(launchId)}"` : '';
|
|
267
|
+
const displayNames = resolveJUnitDisplayNames(results, opts.classname);
|
|
268
|
+
const testcases = results
|
|
269
|
+
.map((r, index) => renderTestcase(r, r.classname ?? opts.classname, displayNames[index]))
|
|
270
|
+
.join('\n');
|
|
179
271
|
return [
|
|
180
272
|
XML_DECL,
|
|
181
273
|
'<testsuites>',
|
|
182
|
-
` <testsuite name="${suiteName}" tests="${results.length}" failures="${failures}" errors="${errors}" skipped="${skipped}" time="${formatTime(totalSeconds)}">`,
|
|
274
|
+
` <testsuite name="${suiteName}"${runAttr} tests="${results.length}" failures="${failures}" errors="${errors}" skipped="${skipped}" time="${formatTime(totalSeconds)}">`,
|
|
183
275
|
testcases,
|
|
184
276
|
' </testsuite>',
|
|
185
277
|
'</testsuites>',
|
|
186
278
|
'',
|
|
187
279
|
].join('\n');
|
|
188
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* One non-dispatched summary row as a skipped JUnit result, with its reason
|
|
283
|
+
* (or its status when it has none). A test another run already holds keeps
|
|
284
|
+
* that run's result and launch.
|
|
285
|
+
*/
|
|
286
|
+
export function skippedRowFromSummary(row) {
|
|
287
|
+
return {
|
|
288
|
+
testId: row.testId ?? row.resultId ?? row.runId ?? '(unknown)',
|
|
289
|
+
...(row.resultId !== undefined ? { resultId: row.resultId } : {}),
|
|
290
|
+
...(row.runId !== undefined ? { runId: row.runId } : {}),
|
|
291
|
+
status: 'skipped',
|
|
292
|
+
skipReason: row.error ?? row.status,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
189
295
|
/**
|
|
190
296
|
* The summary's non-dispatched rows (deferred / conflict / not-found) as
|
|
191
|
-
* skipped JUnit results.
|
|
297
|
+
* skipped JUnit results. A test another run already holds names that run's
|
|
298
|
+
* result and launch, so the suite does not name its launch as this
|
|
299
|
+
* invocation's run (see `buildJUnitReport`). Accepted rows carry run statuses and today never
|
|
192
300
|
* match `isNonDispatchedStatus`, but the two vocabularies are only disjoint
|
|
193
301
|
* by convention: `skipped` is a word both could use. So a member already in
|
|
194
302
|
* `dispatched` (the polled results the caller is writing) is left out here
|
|
@@ -197,38 +305,80 @@ export function buildJUnitReport(opts) {
|
|
|
197
305
|
*/
|
|
198
306
|
export function skippedJUnitResultsFromSummary(summary, dispatched = []) {
|
|
199
307
|
const alreadyIncluded = new Set(dispatched.map(row => row.testId));
|
|
200
|
-
return summary.
|
|
201
|
-
.filter(row => isNonDispatchedStatus(row.status) && !alreadyIncluded.has(row.testId))
|
|
202
|
-
.map(
|
|
308
|
+
return summary.results
|
|
309
|
+
.filter(row => isNonDispatchedStatus(row.status) && (!row.testId || !alreadyIncluded.has(row.testId)))
|
|
310
|
+
.map(skippedRowFromSummary);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The summary's rows as the report of a batch that stopped before its runs
|
|
314
|
+
* were awaited: a test that never dispatched is skipped with its reason, and
|
|
315
|
+
* every other row is an error with its own note, or `failure` when it has
|
|
316
|
+
* none. Each row keeps its result and launch.
|
|
317
|
+
*/
|
|
318
|
+
export function junitRowsFromSummary(summary, failure) {
|
|
319
|
+
return summary.results.map(row => isNonDispatchedStatus(row.status)
|
|
320
|
+
? skippedRowFromSummary(row)
|
|
321
|
+
: {
|
|
322
|
+
testId: row.testId ?? row.resultId ?? row.runId ?? '(unknown)',
|
|
323
|
+
...(row.resultId !== undefined ? { resultId: row.resultId } : {}),
|
|
324
|
+
...(row.runId !== undefined ? { runId: row.runId } : {}),
|
|
325
|
+
status: 'error',
|
|
326
|
+
error: { code: 'UNSUPPORTED', message: row.error ?? failure, exitCode: 7 },
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
function errorCode(err) {
|
|
330
|
+
return err?.code ?? 'unknown error';
|
|
331
|
+
}
|
|
332
|
+
function isAbsentPathError(err) {
|
|
333
|
+
const code = errorCode(err);
|
|
334
|
+
return code === 'ENOENT' || code === 'ENOTDIR';
|
|
203
335
|
}
|
|
204
|
-
|
|
336
|
+
/**
|
|
337
|
+
* Check that an output artifact path (`--report-file`, `--summary-file`) can be
|
|
338
|
+
* written: non-empty, not a directory, and inside an existing directory.
|
|
339
|
+
* Returns the resolved absolute path.
|
|
340
|
+
*
|
|
341
|
+
* Called in each command's pre-flight, before anything is dispatched or billed,
|
|
342
|
+
* so a mistyped directory fails fast with exit 5 instead of surfacing only after
|
|
343
|
+
* a full batch has run. The write itself re-checks (the directory can vanish in
|
|
344
|
+
* between).
|
|
345
|
+
*/
|
|
346
|
+
export function assertArtifactPath(field, rawPath) {
|
|
205
347
|
if (typeof rawPath !== 'string' || rawPath.length === 0) {
|
|
206
|
-
throw localValidationError(
|
|
348
|
+
throw localValidationError(field, 'must be a non-empty file path');
|
|
207
349
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
throw localValidationError('report-file', 'must point to a file, not a directory');
|
|
350
|
+
if (/[\\/]$/.test(rawPath)) {
|
|
351
|
+
throw localValidationError(field, 'must point to a file, not a directory');
|
|
211
352
|
}
|
|
353
|
+
const resolved = isAbsolute(rawPath) ? rawPath : resolve(process.cwd(), rawPath);
|
|
212
354
|
const parent = dirname(resolved);
|
|
213
355
|
let parentStat;
|
|
214
356
|
try {
|
|
215
|
-
|
|
357
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- inspect the user-selected artifact parent before dispatch; no file content is read.
|
|
358
|
+
parentStat = statSync(parent);
|
|
216
359
|
}
|
|
217
|
-
catch {
|
|
218
|
-
|
|
360
|
+
catch (err) {
|
|
361
|
+
if (isAbsentPathError(err))
|
|
362
|
+
throw localValidationError(field, `parent directory does not exist: ${parent}`);
|
|
363
|
+
throw localValidationError(field, `cannot access parent directory ${parent}: ${errorCode(err)}`);
|
|
219
364
|
}
|
|
220
365
|
if (!parentStat.isDirectory()) {
|
|
221
|
-
throw localValidationError(
|
|
366
|
+
throw localValidationError(field, `parent path is not a directory: ${parent}`);
|
|
222
367
|
}
|
|
223
368
|
let targetStat;
|
|
224
369
|
try {
|
|
225
|
-
|
|
370
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- inspect the user-selected artifact target to reject directories and inaccessible paths before dispatch.
|
|
371
|
+
targetStat = statSync(resolved);
|
|
226
372
|
}
|
|
227
|
-
catch {
|
|
228
|
-
|
|
373
|
+
catch (err) {
|
|
374
|
+
// Only a missing target is fine (it will be created); anything else (EACCES, ELOOP...) would fail the
|
|
375
|
+
// write after the run was dispatched, which is exactly what this pre-flight exists to prevent.
|
|
376
|
+
if (isAbsentPathError(err))
|
|
377
|
+
return resolved;
|
|
378
|
+
throw localValidationError(field, `cannot access ${resolved}: ${errorCode(err)}`);
|
|
229
379
|
}
|
|
230
380
|
if (targetStat.isDirectory()) {
|
|
231
|
-
throw localValidationError(
|
|
381
|
+
throw localValidationError(field, `must point to a file, not a directory: ${resolved}`);
|
|
232
382
|
}
|
|
233
383
|
return resolved;
|
|
234
384
|
}
|
|
@@ -236,7 +386,7 @@ async function assertReportFileParent(rawPath) {
|
|
|
236
386
|
* Atomically write JUnit XML to `--report-file` (temp sibling + rename).
|
|
237
387
|
*/
|
|
238
388
|
export async function writeJUnitReportFile(rawPath, xml) {
|
|
239
|
-
const resolved =
|
|
389
|
+
const resolved = assertArtifactPath('report-file', rawPath);
|
|
240
390
|
const parent = dirname(resolved);
|
|
241
391
|
const tmpPath = join(parent, `.${basename(resolved)}.tmp-${randomUUID()}`);
|
|
242
392
|
await new Promise((resolvePromise, reject) => {
|
|
@@ -265,4 +415,24 @@ export async function writeJUnitReportFile(rawPath, xml) {
|
|
|
265
415
|
});
|
|
266
416
|
});
|
|
267
417
|
}
|
|
418
|
+
/**
|
|
419
|
+
* Write a run's JUnit report (`write`) when the command may already owe an
|
|
420
|
+
* exit: a failed or timed-out test, one not dispatched, a refused request.
|
|
421
|
+
* Then the report is best-effort: one that cannot be written (its directory
|
|
422
|
+
* gone, say) is a line on stderr and the exit owed stands. With nothing owed,
|
|
423
|
+
* the write's error is the command's. An interrupt always propagates.
|
|
424
|
+
*/
|
|
425
|
+
export async function writeReportOwing(owesAnExit, write, stderr, context) {
|
|
426
|
+
if (!owesAnExit)
|
|
427
|
+
return write();
|
|
428
|
+
try {
|
|
429
|
+
await write();
|
|
430
|
+
}
|
|
431
|
+
catch (err) {
|
|
432
|
+
if (err instanceof InterruptError)
|
|
433
|
+
throw err;
|
|
434
|
+
stderr(`[${context.label}] could not write ${context.what ?? 'the JUnit report'}: ` +
|
|
435
|
+
`${err instanceof Error ? err.message : String(err)}; continuing`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
268
438
|
//# sourceMappingURL=junit-report.js.map
|
|
@@ -103,9 +103,9 @@ export declare function parseStoredLocalTarget(opts: {
|
|
|
103
103
|
url?: string;
|
|
104
104
|
}): StoredLocalTarget | undefined;
|
|
105
105
|
/**
|
|
106
|
-
* Refuse a stored-target write
|
|
107
|
-
*
|
|
108
|
-
* caught before a row exists anywhere. `skipPreflight` is a pure no-op.
|
|
106
|
+
* Refuse a stored-target write (`project env create` / `project env update`
|
|
107
|
+
* with `--local`) whose loopback port has nothing listening, so a typo in the
|
|
108
|
+
* port is caught before a row exists anywhere. `skipPreflight` is a pure no-op.
|
|
109
109
|
*/
|
|
110
110
|
export declare function assertStoredLocalTargetListening(target: StoredLocalTarget, opts: {
|
|
111
111
|
skipPreflight?: boolean;
|
package/dist/lib/local-target.js
CHANGED
|
@@ -154,9 +154,9 @@ function flagPairError(message) {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
|
-
* Refuse a stored-target write
|
|
158
|
-
*
|
|
159
|
-
* caught before a row exists anywhere. `skipPreflight` is a pure no-op.
|
|
157
|
+
* Refuse a stored-target write (`project env create` / `project env update`
|
|
158
|
+
* with `--local`) whose loopback port has nothing listening, so a typo in the
|
|
159
|
+
* port is caught before a row exists anywhere. `skipPreflight` is a pure no-op.
|
|
160
160
|
*/
|
|
161
161
|
export async function assertStoredLocalTargetListening(target, opts, deps = {}) {
|
|
162
162
|
if (opts.skipPreflight)
|