@testsprite/testsprite-cli 0.16.0 → 0.18.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 +52 -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 +40 -56
- 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 +741 -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 +434 -43
- 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 +19 -186
- package/dist/commands/project.js +108 -926
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +216 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1838
- package/dist/commands/test.js +1880 -13917
- package/dist/commands/testlist.d.ts +130 -5
- package/dist/commands/testlist.js +300 -342
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +23 -20
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +191 -110
- 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 +12 -4
- package/dist/lib/client-factory.js +41 -30
- 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 +75 -0
- package/dist/lib/conversation/api.js +151 -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 +29 -0
- package/dist/lib/conversation/context.js +82 -0
- package/dist/lib/conversation/environment.d.ts +16 -0
- package/dist/lib/conversation/environment.js +21 -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 +318 -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 +158 -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 +100 -0
- package/dist/lib/download.js +408 -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 +19 -30
- package/dist/lib/environment-tunnel.js +168 -202
- 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 +20 -30
- package/dist/lib/first-suite-hint.js +57 -72
- 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 +354 -291
- 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 +8 -7
- package/dist/lib/local-target.js +14 -13
- package/dist/lib/output.d.ts +2 -41
- package/dist/lib/output.js +13 -51
- 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 +170 -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 +73 -0
- package/dist/lib/result/evidence.js +422 -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 +8 -8
- package/dist/lib/target-url.js +14 -24
- package/dist/lib/telemetry.d.ts +35 -15
- package/dist/lib/telemetry.js +38 -9
- 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 +8 -2
- package/dist/lib/tunnel-session.js +24 -11
- 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 +52 -23
- package/skills/testsprite-onboard.skill.md +70 -153
- package/skills/testsprite-verify.codex.md +54 -58
- package/skills/testsprite-verify.skill.md +189 -358
- 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
|
@@ -3,10 +3,10 @@ import { type ShutdownHandle } from './interrupt.js';
|
|
|
3
3
|
import { openTunnelSession, type TunnelClientHandle } from './tunnel-session.js';
|
|
4
4
|
import { type TunnelClientOptions } from '../vendor/tunnel-client/index.js';
|
|
5
5
|
import type { HttpClient } from './http.js';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
6
|
+
import type { RunWaitSnapshot } from './run-wait.js';
|
|
7
|
+
import type { CliTestListRunResponse } from './testlist.types.js';
|
|
8
8
|
import { ApiError } from './errors.js';
|
|
9
|
-
import { type
|
|
9
|
+
import { type StoredLocalTarget } from './local-target.js';
|
|
10
10
|
export interface RunTargetTest {
|
|
11
11
|
type: 'frontend' | 'backend';
|
|
12
12
|
projectId: string;
|
|
@@ -21,6 +21,8 @@ export interface ResolvedRunTarget extends StoredLocalTarget {
|
|
|
21
21
|
targetUrl: string;
|
|
22
22
|
automatic: boolean;
|
|
23
23
|
environmentName?: string;
|
|
24
|
+
/** Whether that environment is the project's default, when the server says. */
|
|
25
|
+
environmentIsDefault?: boolean;
|
|
24
26
|
}
|
|
25
27
|
export declare const ENVIRONMENT_PREFLIGHT_TIMEOUT_MS = 5000;
|
|
26
28
|
/** Advisory-only reads must not inherit the run's long wait or retry budget. */
|
|
@@ -39,8 +41,6 @@ export declare function resolveEnvironmentRunTarget(args: {
|
|
|
39
41
|
dryRun?: boolean;
|
|
40
42
|
projectId?: string;
|
|
41
43
|
environment?: string;
|
|
42
|
-
localPort?: number;
|
|
43
|
-
localHost?: LoopbackHost;
|
|
44
44
|
targetUrl?: string;
|
|
45
45
|
tunnelClientId?: string;
|
|
46
46
|
noWait?: boolean;
|
|
@@ -48,7 +48,6 @@ export declare function resolveEnvironmentRunTarget(args: {
|
|
|
48
48
|
stderr: (line: string) => void;
|
|
49
49
|
cache?: Map<string, Environment[] | undefined>;
|
|
50
50
|
}): Promise<ResolvedRunTarget | undefined>;
|
|
51
|
-
export declare function tunnelScopeError(err: unknown): unknown;
|
|
52
51
|
export declare function unsupportedTunnelError(command: string): ApiError;
|
|
53
52
|
export interface EnvironmentTunnelContext {
|
|
54
53
|
client: HttpClient;
|
|
@@ -57,47 +56,36 @@ export interface EnvironmentTunnelContext {
|
|
|
57
56
|
maxConcurrency: number;
|
|
58
57
|
deadlineMs: number;
|
|
59
58
|
session: Awaited<ReturnType<typeof openTunnelSession>>;
|
|
60
|
-
cancellation: (runId: string) => 'cancelled' | 'cancel-failed' | undefined;
|
|
59
|
+
cancellation: (runId: string) => 'cancelled' | 'cancel-failed' | 'already-terminal' | undefined;
|
|
60
|
+
cancelActive: () => Promise<void>;
|
|
61
61
|
skipped?: Array<{
|
|
62
62
|
testId: string;
|
|
63
63
|
reason: 'backend-test';
|
|
64
64
|
}>;
|
|
65
|
-
|
|
66
|
-
waitForCapacity: (incoming: number) => Promise<void>;
|
|
65
|
+
resultStatus: (resultId: string) => string | undefined;
|
|
67
66
|
confirm: (response: {
|
|
68
67
|
tunnelClientId?: string;
|
|
69
68
|
}, runIds: string[], requireEcho?: boolean) => Promise<void>;
|
|
70
|
-
|
|
71
|
-
runId: string;
|
|
72
|
-
status: string;
|
|
73
|
-
}) => void;
|
|
69
|
+
onRead: (snapshot: RunWaitSnapshot, signal: AbortSignal) => Promise<void>;
|
|
74
70
|
}
|
|
75
|
-
/**
|
|
71
|
+
/** Own tunnel lifecycle and executions, without a client-side dispatch capacity loop. */
|
|
76
72
|
export declare function withEnvironmentTunnel<T>(opts: CommonOptions & {
|
|
77
73
|
skipPreflight?: boolean;
|
|
78
74
|
maxConcurrency?: number;
|
|
79
75
|
timeoutSeconds?: number;
|
|
76
|
+
tunnelClientId?: string;
|
|
77
|
+
cancelOnInterrupt?: boolean;
|
|
80
78
|
}, deps: ClientFactoryDeps & {
|
|
81
79
|
shutdown?: ShutdownHandle;
|
|
82
80
|
createTunnelClient?: (options: TunnelClientOptions) => TunnelClientHandle;
|
|
83
81
|
sleep?: (ms: number) => Promise<void>;
|
|
84
82
|
}, targets: ResolvedRunTarget[], command: string, operation: (context: EnvironmentTunnelContext) => Promise<T>): Promise<T>;
|
|
85
83
|
/** Keep each dispatch on one verbatim loopback URL; public runs omit tunnel fields. */
|
|
86
|
-
export declare function groupEnvironmentTargets(ids: string[], targets: ReadonlyMap<string,
|
|
84
|
+
export declare function groupEnvironmentTargets(ids: string[], targets: ReadonlyMap<string, {
|
|
85
|
+
targetUrl: string;
|
|
86
|
+
}>): string[][];
|
|
87
87
|
export declare function quoteEnvironmentName(name: string): string;
|
|
88
|
-
export declare function emitEnvironmentDispatchPartial(responses:
|
|
89
|
-
accepted: Array<{
|
|
90
|
-
testId: string;
|
|
91
|
-
runId: string;
|
|
92
|
-
}>;
|
|
93
|
-
conflicts: Array<{
|
|
94
|
-
testId: string;
|
|
95
|
-
}>;
|
|
96
|
-
deferred: Array<{
|
|
97
|
-
testId: string;
|
|
98
|
-
}>;
|
|
99
|
-
notFound?: string[];
|
|
100
|
-
}>, testIds: string[], opts: CommonOptions & {
|
|
88
|
+
export declare function emitEnvironmentDispatchPartial(responses: readonly CliTestListRunResponse[], testIds: string[], opts: CommonOptions & {
|
|
101
89
|
report?: 'junit';
|
|
102
90
|
reportFile?: string;
|
|
103
91
|
reportSuiteName?: string;
|
|
@@ -105,6 +93,7 @@ export declare function emitEnvironmentDispatchPartial(responses: Array<{
|
|
|
105
93
|
summaryFile?: string;
|
|
106
94
|
}, deps: ClientFactoryDeps & {
|
|
107
95
|
stdout?: (line: string) => void;
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
}, label: string, error: unknown, context: EnvironmentTunnelContext,
|
|
97
|
+
/** The reason a `notFound` id was not dispatched (`run --testlist`: not a member of the list). */
|
|
98
|
+
notFoundNote?: string): Promise<void>;
|
|
110
99
|
export {};
|
|
@@ -1,38 +1,57 @@
|
|
|
1
|
+
import { isProxyAgentActive } from './proxy.js';
|
|
1
2
|
import { makeHttpClient, resolveRequestTimeoutMs, } from './client-factory.js';
|
|
2
3
|
import { globalShutdown } from './interrupt.js';
|
|
3
|
-
import { openTunnelSession, TunnelLostError } from './tunnel-session.js';
|
|
4
|
+
import { TUNNEL_DATA_PLANE_PROXY_BYPASS_DESCRIPTION, openTunnelSession, TunnelLostError, } from './tunnel-session.js';
|
|
4
5
|
import { TunnelClient } from '../vendor/tunnel-client/index.js';
|
|
5
6
|
import { assertLocalPortListening } from './local-target.js';
|
|
6
|
-
import { recordTelemetryTunnelOpened } from './telemetry.js';
|
|
7
|
+
import { recordTelemetryExtras, recordTelemetryTunnelOpened } from './telemetry.js';
|
|
7
8
|
import { Output } from './output.js';
|
|
8
|
-
import { emitCiArtifacts,
|
|
9
|
-
import { buildJUnitReport, writeJUnitReportFile } from './junit-report.js';
|
|
10
|
-
import {
|
|
9
|
+
import { emitCiArtifacts, isNonDispatchedStatus } from './gh-output.js';
|
|
10
|
+
import { buildJUnitReport, skippedRowFromSummary, writeJUnitReportFile } from './junit-report.js';
|
|
11
|
+
import { launchIds } from './run-render.js';
|
|
12
|
+
import { buildRunOutput, listResultReceipt, renderRunResults } from './run-output.js';
|
|
11
13
|
import { ApiError, InterruptError, RequestTimeoutError, localValidationError } from './errors.js';
|
|
12
|
-
import {
|
|
14
|
+
import { parseLoopbackTargetUrl } from './local-target.js';
|
|
15
|
+
import { terminalSafeLine, terminalSafeWriter } from './terminal-text.js';
|
|
13
16
|
export const ENVIRONMENT_PREFLIGHT_TIMEOUT_MS = 5_000;
|
|
14
17
|
/** Advisory-only reads must not inherit the run's long wait or retry budget. */
|
|
15
18
|
export function readEnvironmentPreflight(client, path) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
// Abort with a RequestTimeoutError as the reason, not AbortSignal.timeout's
|
|
20
|
+
// raw DOMException: HttpClient passes a RequestTimeoutError through
|
|
21
|
+
// untouched, so a stalled preflight read surfaces as REQUEST_TIMEOUT
|
|
22
|
+
// (exit 7) instead of reaching the top-level catch as an uncaught
|
|
23
|
+
// exception. The 5s deadline here is fixed — --request-timeout does not
|
|
24
|
+
// govern it — so the message and nextAction name the preflight read
|
|
25
|
+
// rather than pointing at the flag.
|
|
26
|
+
const controller = new AbortController();
|
|
27
|
+
const timer = setTimeout(() => {
|
|
28
|
+
controller.abort(new RequestTimeoutError(ENVIRONMENT_PREFLIGHT_TIMEOUT_MS, 'local', {
|
|
29
|
+
message: `Environment preflight read timed out after ` +
|
|
30
|
+
`${ENVIRONMENT_PREFLIGHT_TIMEOUT_MS / 1000}s (client-side).`,
|
|
31
|
+
nextAction: 'The environment preflight read timed out. ' +
|
|
32
|
+
'Check that the backend is reachable and not overloaded, then retry.',
|
|
33
|
+
}));
|
|
34
|
+
}, ENVIRONMENT_PREFLIGHT_TIMEOUT_MS);
|
|
35
|
+
timer.unref?.();
|
|
36
|
+
return client
|
|
37
|
+
.get(path, { retry: false, signal: controller.signal })
|
|
38
|
+
.finally(() => clearTimeout(timer));
|
|
20
39
|
}
|
|
21
40
|
export function assertNoTunnelOptions(args) {
|
|
22
41
|
if (args.tunnelClientId !== undefined)
|
|
23
|
-
throw localValidationError('tunnel-client', '--tunnel-client only applies
|
|
24
|
-
'tunnel).
|
|
42
|
+
throw localValidationError('tunnel-client', '--tunnel-client only applies to a run on a local environment (it attaches the run to an ' +
|
|
43
|
+
'already-running tunnel). Run on one with --env <name>, or remove --tunnel-client');
|
|
25
44
|
if (args.cancelOnInterrupt === false)
|
|
26
|
-
throw localValidationError('cancel-on-interrupt', '--no-cancel-on-interrupt only applies
|
|
45
|
+
throw localValidationError('cancel-on-interrupt', '--no-cancel-on-interrupt only applies to a run on a local environment. An ordinary run is never ' +
|
|
27
46
|
'cancelled when this command stops waiting — Ctrl-C detaches, and `testsprite test ' +
|
|
28
47
|
'cancel <run-id>` is the way to stop one');
|
|
29
48
|
}
|
|
30
49
|
const announcedEnvironments = new WeakMap();
|
|
31
50
|
/** One resolver for fresh runs, replay, chained creation and test-list runs. */
|
|
32
51
|
export async function resolveEnvironmentRunTarget(args) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (args.targetUrl !== undefined
|
|
52
|
+
// A run aimed at an address of its own (a pull request preview) leaves the
|
|
53
|
+
// environment's address, and its tunnel, alone.
|
|
54
|
+
if (args.targetUrl !== undefined)
|
|
36
55
|
return undefined;
|
|
37
56
|
let test = args.knownTest;
|
|
38
57
|
if (!test && args.testId && !args.skipTestLookup) {
|
|
@@ -42,27 +61,11 @@ export async function resolveEnvironmentRunTarget(args) {
|
|
|
42
61
|
catch (err) {
|
|
43
62
|
if (err instanceof InterruptError)
|
|
44
63
|
throw err;
|
|
45
|
-
if (explicit) {
|
|
46
|
-
if (err instanceof ApiError &&
|
|
47
|
-
(err.httpStatus === 403 || err.httpStatus === 404 || err.code === 'UNAVAILABLE')) {
|
|
48
|
-
throw new ApiError({
|
|
49
|
-
code: err.code,
|
|
50
|
-
message: `Cannot read test ${args.testId} for --local preflight.`,
|
|
51
|
-
nextAction: 'Check the test ID and read:tests permission, then retry.',
|
|
52
|
-
requestId: err.requestId,
|
|
53
|
-
details: {},
|
|
54
|
-
}, err.httpStatus);
|
|
55
|
-
}
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
64
|
return undefined;
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
|
-
if (test?.type === 'backend' && !args.includeBackend)
|
|
62
|
-
if (explicit)
|
|
63
|
-
throw localValidationError('local', `backend tests don't open a browser; the tunnel is not used. Run: testsprite test run ${args.testId}`);
|
|
67
|
+
if (test?.type === 'backend' && !args.includeBackend)
|
|
64
68
|
return undefined;
|
|
65
|
-
}
|
|
66
69
|
const projectId = test?.projectId ?? args.projectId;
|
|
67
70
|
let environments;
|
|
68
71
|
if (projectId) {
|
|
@@ -87,10 +90,6 @@ export async function resolveEnvironmentRunTarget(args) {
|
|
|
87
90
|
const selected = args.environment === undefined
|
|
88
91
|
? (environments?.find(row => row.isDefault) ?? environments?.find(row => !row.isTemporary))
|
|
89
92
|
: environments?.find(row => row.name === args.environment);
|
|
90
|
-
if (explicit && args.environment !== undefined && environments && !selected) {
|
|
91
|
-
const available = environments.map(row => row.name).sort();
|
|
92
|
-
throw localValidationError('env', `unknown environment '${args.environment}'; use one of: ${available.join(', ')}`, available);
|
|
93
|
-
}
|
|
94
93
|
const localOf = (row) => {
|
|
95
94
|
if (!row || typeof row.url !== 'string')
|
|
96
95
|
return undefined;
|
|
@@ -111,28 +110,6 @@ export async function resolveEnvironmentRunTarget(args) {
|
|
|
111
110
|
args.stderr(line);
|
|
112
111
|
announced.add(key);
|
|
113
112
|
};
|
|
114
|
-
const explicitTarget = (target) => {
|
|
115
|
-
if (args.environment !== undefined && selected && !localOf(selected))
|
|
116
|
-
announce(`sign-in:${projectId}:${selected.name}:${target.targetUrl}`, `Using environment "${selected.name}" sign-in against ${target.targetUrl} through a tunnel.`);
|
|
117
|
-
return target;
|
|
118
|
-
};
|
|
119
|
-
if (explicitUrl)
|
|
120
|
-
return explicitTarget({ ...explicitUrl, targetUrl: args.targetUrl, automatic: false });
|
|
121
|
-
if (args.localPort !== undefined) {
|
|
122
|
-
const selectedHost = localOf(selected)?.host;
|
|
123
|
-
const matching = environments?.filter(row => !row.isTemporary && localOf(row)?.port === args.localPort) ?? [];
|
|
124
|
-
const hosts = new Set(matching.map(row => localOf(row).host));
|
|
125
|
-
const host = args.localHost ??
|
|
126
|
-
selectedHost ??
|
|
127
|
-
(hosts.size === 1 ? [...hosts][0] : undefined) ??
|
|
128
|
-
(environments === undefined ? '127.0.0.1' : DEFAULT_LOCAL_HOST);
|
|
129
|
-
return explicitTarget({
|
|
130
|
-
host,
|
|
131
|
-
port: args.localPort,
|
|
132
|
-
targetUrl: buildLocalTargetUrl(host, args.localPort),
|
|
133
|
-
automatic: false,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
113
|
const local = localOf(selected);
|
|
137
114
|
if (!local)
|
|
138
115
|
return undefined;
|
|
@@ -143,40 +120,33 @@ export async function resolveEnvironmentRunTarget(args) {
|
|
|
143
120
|
if (!args.tunnelClientId && test?.type !== 'backend') {
|
|
144
121
|
const key = `${projectId}:${selected.name}:${selected.url}`;
|
|
145
122
|
announce(key, args.dryRun
|
|
146
|
-
? `Would open a tunnel to ${selected.url} (environment "${selected.name}").`
|
|
147
|
-
: `Environment "${selected.name}" is on this machine (${selected.url}) — opening a tunnel.`);
|
|
123
|
+
? `Would open a tunnel to ${terminalSafeLine(selected.url)} (environment "${terminalSafeLine(selected.name)}").`
|
|
124
|
+
: `Environment "${terminalSafeLine(selected.name)}" is on this machine (${terminalSafeLine(selected.url)}) — opening a tunnel.`);
|
|
148
125
|
}
|
|
149
126
|
return {
|
|
150
127
|
...local,
|
|
151
128
|
targetUrl: selected.url,
|
|
152
129
|
automatic: args.tunnelClientId === undefined,
|
|
153
130
|
environmentName: selected.name,
|
|
131
|
+
...(selected.isDefault !== undefined ? { environmentIsDefault: selected.isDefault } : {}),
|
|
154
132
|
};
|
|
155
133
|
}
|
|
156
|
-
export function tunnelScopeError(err) {
|
|
157
|
-
if (!(err instanceof ApiError) || err.httpStatus !== 403)
|
|
158
|
-
return err;
|
|
159
|
-
return new ApiError({
|
|
160
|
-
code: err.code,
|
|
161
|
-
message: err.message,
|
|
162
|
-
requestId: err.requestId,
|
|
163
|
-
details: err.details,
|
|
164
|
-
nextAction: `${err.nextAction ?? ''} A tunnel is required for this environment; use an API key with run:tunnel permission.`,
|
|
165
|
-
}, err.httpStatus);
|
|
166
|
-
}
|
|
167
134
|
export function unsupportedTunnelError(command) {
|
|
168
135
|
return new ApiError({
|
|
169
136
|
code: 'UNSUPPORTED',
|
|
170
137
|
message: `This server did not confirm tunnel use for ${command}. Cancellation was attempted for the started runs; no tunnel-free result can be trusted.`,
|
|
171
|
-
nextAction: 'Update the server, or use testsprite
|
|
138
|
+
nextAction: 'Update the server, or use testsprite run <id> with the saved environment.',
|
|
172
139
|
requestId: 'local',
|
|
173
140
|
details: {},
|
|
174
141
|
});
|
|
175
142
|
}
|
|
176
|
-
/**
|
|
143
|
+
/** Own tunnel lifecycle and executions, without a client-side dispatch capacity loop. */
|
|
177
144
|
export async function withEnvironmentTunnel(opts, deps, targets, command, operation) {
|
|
178
|
-
const stderr = deps.stderr
|
|
145
|
+
const stderr = terminalSafeWriter(deps.stderr);
|
|
179
146
|
const shutdown = deps.shutdown ?? globalShutdown;
|
|
147
|
+
if (isProxyAgentActive())
|
|
148
|
+
stderr(`[advisory] An HTTP proxy is configured for this process. The tunnel control channel honours it, but ${TUNNEL_DATA_PLANE_PROXY_BYPASS_DESCRIPTION} — if the run cannot reach your machine, an egress proxy is the first thing to rule out.`);
|
|
149
|
+
recordTelemetryExtras({ localConcurrencyLimit: opts.maxConcurrency ?? 5 });
|
|
180
150
|
const seen = new Set();
|
|
181
151
|
for (const target of targets) {
|
|
182
152
|
if (seen.has(target.targetUrl))
|
|
@@ -198,130 +168,113 @@ export async function withEnvironmentTunnel(opts, deps, targets, command, operat
|
|
|
198
168
|
};
|
|
199
169
|
const cleanup = (operation) => request(10_000, operation);
|
|
200
170
|
const client = makeHttpClient(opts, { ...deps, shutdownSignal: shutdown.signal, shutdown });
|
|
171
|
+
const livenessClient = makeHttpClient({ ...opts, debug: false, verbose: false }, { ...deps, shutdownSignal: shutdown.signal, shutdown });
|
|
201
172
|
const active = new Set();
|
|
202
|
-
const
|
|
203
|
-
const getRun = client.getRun.bind(client);
|
|
204
|
-
client.getRun = async (runId, options) => {
|
|
205
|
-
const cached = terminalRuns.get(runId);
|
|
206
|
-
if (cached)
|
|
207
|
-
return cached;
|
|
208
|
-
const run = await getRun(runId, options);
|
|
209
|
-
if (isTerminalStatus(run.status))
|
|
210
|
-
terminalRuns.set(runId, run);
|
|
211
|
-
return run;
|
|
212
|
-
};
|
|
173
|
+
const statuses = new Map();
|
|
213
174
|
const cancellations = new Map();
|
|
214
175
|
let failure;
|
|
215
|
-
let
|
|
216
|
-
|
|
176
|
+
let session;
|
|
177
|
+
let ownerGone = false;
|
|
178
|
+
let lastLivenessRead = -Infinity;
|
|
179
|
+
const cancel = async (force = false) => {
|
|
180
|
+
if (!force && (opts.cancelOnInterrupt === false || (session?.adopted && !ownerGone)))
|
|
181
|
+
return;
|
|
217
182
|
for (const runId of active) {
|
|
218
183
|
try {
|
|
219
|
-
await cleanup(transport => transport.cancelRun(runId));
|
|
220
|
-
cancellations.set(runId, 'cancelled');
|
|
221
|
-
stderr(
|
|
184
|
+
const cancelled = await cleanup(transport => transport.cancelRun(runId));
|
|
185
|
+
cancellations.set(runId, cancelled.alreadyFinished ? 'already-terminal' : 'cancelled');
|
|
186
|
+
stderr(cancelled.alreadyFinished
|
|
187
|
+
? `[tunnel] Run ${terminalSafeLine(runId)} had already finished; no cancellation was needed.`
|
|
188
|
+
: `[tunnel] Cancellation requested for run ${terminalSafeLine(runId)}; its tunnel is closing.`);
|
|
189
|
+
for (const result of cancelled.results)
|
|
190
|
+
if (result.refund?.status === 'failed')
|
|
191
|
+
stderr(`[tunnel] Refund failed for result ${terminalSafeLine(result.resultId)}: inspect the cancellation response or contact support.`);
|
|
222
192
|
}
|
|
223
193
|
catch (err) {
|
|
224
|
-
cancellations.set(runId, 'failed');
|
|
225
|
-
stderr(`[tunnel] Could not cancel ${runId}: ${err instanceof Error ? err.message : String(err)}. Use testsprite
|
|
194
|
+
cancellations.set(runId, 'cancel-failed');
|
|
195
|
+
stderr(`[tunnel] Could not cancel run ${terminalSafeLine(runId)}: ${terminalSafeLine(err instanceof Error ? err.message : String(err))}. Use testsprite run cancel ${terminalSafeLine(runId)}.`);
|
|
226
196
|
}
|
|
227
197
|
active.delete(runId);
|
|
228
198
|
}
|
|
229
199
|
};
|
|
230
200
|
const disarm = shutdown.arm();
|
|
231
|
-
let session;
|
|
232
201
|
try {
|
|
233
202
|
try {
|
|
234
|
-
session = await openTunnelSession({
|
|
203
|
+
session = await openTunnelSession({
|
|
204
|
+
log: stderr,
|
|
205
|
+
onMinted: ({ clientId }) => stderr(`[tunnel] Minted tunnel client ${terminalSafeLine(clientId)}`),
|
|
206
|
+
logLevel: opts.debug ? 'debug' : opts.verbose ? 'info' : 'error',
|
|
207
|
+
...(opts.tunnelClientId
|
|
208
|
+
? { adopt: { clientId: opts.tunnelClientId, expiresAt: '' } }
|
|
209
|
+
: {}),
|
|
210
|
+
}, {
|
|
235
211
|
mint: ttlSeconds => request(requestTimeoutMs, transport => transport.mintTunnel({ ...(ttlSeconds ? { ttlSeconds } : {}) })),
|
|
236
212
|
destroy: clientId => cleanup(transport => transport.deleteTunnel(clientId)),
|
|
237
213
|
createClient: shutdownAwareTunnelClient(deps.createTunnelClient ?? (options => new TunnelClient(options)), shutdown.signal),
|
|
238
214
|
});
|
|
239
215
|
}
|
|
240
216
|
catch (err) {
|
|
241
|
-
|
|
217
|
+
if (shutdown.signal.aborted)
|
|
218
|
+
throw shutdown.signal.reason;
|
|
219
|
+
throw err;
|
|
242
220
|
}
|
|
243
|
-
recordTelemetryTunnelOpened(
|
|
244
|
-
|
|
245
|
-
throw shutdown.signal.reason;
|
|
246
|
-
const checkDispatch = () => {
|
|
221
|
+
recordTelemetryTunnelOpened(!session.adopted);
|
|
222
|
+
const dispatch = (operation) => {
|
|
247
223
|
if (shutdown.signal.aborted)
|
|
248
224
|
throw shutdown.signal.reason;
|
|
249
225
|
if (session.fatalReason())
|
|
250
|
-
throw new TunnelLostError(session.fatalReason(),
|
|
251
|
-
|
|
252
|
-
// Retain a charged response across the first interrupt, with a total retry deadline.
|
|
253
|
-
const dispatch = (operation) => {
|
|
254
|
-
checkDispatch();
|
|
226
|
+
throw new TunnelLostError(session.fatalReason(), {}, session.fatalMessage());
|
|
227
|
+
// Keep the response across the first interrupt so its owned run can be cancelled.
|
|
255
228
|
return request(requestTimeoutMs, operation);
|
|
256
229
|
};
|
|
257
|
-
client.
|
|
258
|
-
client.triggerBatchRerun = (...args) => dispatch(transport => transport.triggerBatchRerun(...args));
|
|
230
|
+
client.triggerProjectRun = (...args) => dispatch(transport => transport.triggerProjectRun(...args));
|
|
259
231
|
client.triggerTestListRun = (...args) => dispatch(transport => transport.triggerTestListRun(...args));
|
|
260
|
-
|
|
261
|
-
const deadlineMs = Date.now() + (opts.timeoutSeconds ?? 600) * 1000;
|
|
262
|
-
const assertCapacityDeadline = () => {
|
|
263
|
-
if (Date.now() >= deadlineMs)
|
|
264
|
-
throw new ApiError({
|
|
265
|
-
code: 'UNSUPPORTED',
|
|
266
|
-
message: `Timed out after ${opts.timeoutSeconds ?? 600}s waiting for tunnel batch capacity.`,
|
|
267
|
-
nextAction: 'The owned tunnel is closing; inspect cancellation with testsprite test cancel <run-id>.',
|
|
268
|
-
requestId: 'local',
|
|
269
|
-
details: {},
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
context = {
|
|
232
|
+
return await operation({
|
|
273
233
|
client,
|
|
274
234
|
session,
|
|
275
|
-
deadlineMs,
|
|
276
|
-
cancellation: id => {
|
|
277
|
-
const outcome = cancellations.get(id);
|
|
278
|
-
return outcome === 'failed' ? 'cancel-failed' : outcome;
|
|
279
|
-
},
|
|
280
235
|
clientId: session.clientId,
|
|
281
236
|
maxConcurrency: opts.maxConcurrency ?? 5,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
237
|
+
deadlineMs: Date.now() + (opts.timeoutSeconds ?? 600) * 1000,
|
|
238
|
+
cancellation: runId => cancellations.get(runId),
|
|
239
|
+
cancelActive: () => cancel(),
|
|
240
|
+
resultStatus: resultId => statuses.get(resultId),
|
|
241
|
+
confirm: async (response, runIds, requireEcho = true) => {
|
|
242
|
+
for (const runId of runIds)
|
|
243
|
+
active.add(runId);
|
|
244
|
+
if (requireEcho && runIds.length > 0 && response.tunnelClientId !== session.clientId) {
|
|
245
|
+
await cancel(true);
|
|
246
|
+
throw unsupportedTunnelError(command);
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
onRead: async ({ run, results }, signal) => {
|
|
250
|
+
for (const result of results)
|
|
251
|
+
statuses.set(result.resultId, result.testStatus.toLowerCase());
|
|
252
|
+
if (run.status === 'finished') {
|
|
253
|
+
active.delete(run.runId);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (!active.has(run.runId))
|
|
257
|
+
return;
|
|
258
|
+
const fatal = session.fatalReason();
|
|
259
|
+
if (fatal)
|
|
260
|
+
throw new TunnelLostError(fatal, { runId: run.runId }, session.fatalMessage());
|
|
261
|
+
if (session.adopted && Date.now() - lastLivenessRead >= 15_000) {
|
|
262
|
+
lastLivenessRead = Date.now();
|
|
287
263
|
try {
|
|
288
|
-
await
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
sleep: deps.sleep,
|
|
292
|
-
onTick: run => context.onPoll(run),
|
|
264
|
+
const observed = await livenessClient.getTunnelStatus(session.clientId, {
|
|
265
|
+
signal,
|
|
266
|
+
retry: false,
|
|
293
267
|
});
|
|
268
|
+
ownerGone = observed.status.toLowerCase() === 'offline';
|
|
294
269
|
}
|
|
295
270
|
catch (err) {
|
|
296
|
-
|
|
297
|
-
throw err;
|
|
298
|
-
throw new ApiError({
|
|
299
|
-
code: 'UNSUPPORTED',
|
|
300
|
-
message: err.message,
|
|
301
|
-
nextAction: `The owned tunnel is closing; inspect cancellation with testsprite test cancel ${runId}.`,
|
|
302
|
-
requestId: 'local',
|
|
303
|
-
details: { runId },
|
|
304
|
-
});
|
|
271
|
+
ownerGone = err instanceof ApiError && err.httpStatus === 404;
|
|
305
272
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
confirm: async (response, runIds, requireEcho = true) => {
|
|
310
|
-
for (const id of runIds)
|
|
311
|
-
active.add(id);
|
|
312
|
-
if (requireEcho && runIds.length && response.tunnelClientId !== session.clientId) {
|
|
313
|
-
await cancel();
|
|
314
|
-
throw unsupportedTunnelError(command);
|
|
273
|
+
if (ownerGone)
|
|
274
|
+
throw new TunnelLostError('owner-gone', { runId: run.runId });
|
|
315
275
|
}
|
|
316
276
|
},
|
|
317
|
-
|
|
318
|
-
if (['passed', 'failed', 'blocked', 'cancelled'].includes(run.status))
|
|
319
|
-
active.delete(run.runId);
|
|
320
|
-
else if (active.has(run.runId) && session.fatalReason())
|
|
321
|
-
throw new TunnelLostError(session.fatalReason(), run.runId, session.fatalMessage());
|
|
322
|
-
},
|
|
323
|
-
};
|
|
324
|
-
return await operation(context);
|
|
277
|
+
});
|
|
325
278
|
}
|
|
326
279
|
catch (err) {
|
|
327
280
|
failure = err;
|
|
@@ -330,18 +283,18 @@ export async function withEnvironmentTunnel(opts, deps, targets, command, operat
|
|
|
330
283
|
finally {
|
|
331
284
|
const closing = [...active];
|
|
332
285
|
await cancel();
|
|
333
|
-
if (failure instanceof InterruptError && closing.length) {
|
|
334
|
-
const
|
|
335
|
-
const
|
|
336
|
-
? '
|
|
337
|
-
: '
|
|
338
|
-
const retry = [...(context?.targets ?? [])]
|
|
339
|
-
.map(([id, target]) => `testsprite test run ${id}${target.environmentName ? ` --env ${quoteEnvironmentName(target.environmentName)}` : ''}`)
|
|
340
|
-
.join('; ') || 'testsprite test run <id>';
|
|
341
|
-
const nextAction = `The owned tunnel is closing; cancellation was ${cancelOutcome === 'cancelled' ? 'requested' : 'attempted'} for ${closing.join(' ')}. Inspect with testsprite test cancel ${closing.join(' ')}. Start a new run with ${retry}.`;
|
|
286
|
+
if (failure instanceof InterruptError && closing.length && (!session?.adopted || ownerGone)) {
|
|
287
|
+
const cancelled = closing.every(id => cancellations.get(id) === 'cancelled');
|
|
288
|
+
const nextAction = cancelled
|
|
289
|
+
? `The owned tunnel closed; cancellation was requested for runs ${closing.join(' ')}. Start a new run to test the local target again.`
|
|
290
|
+
: `The owned tunnel closed; cancellation was not confirmed. Stop the runs with testsprite run cancel ${closing.join(' ')}.`;
|
|
342
291
|
Object.assign(failure, {
|
|
343
292
|
runWaitContext: true,
|
|
344
|
-
tunnelDetach: {
|
|
293
|
+
tunnelDetach: {
|
|
294
|
+
runId: closing[0],
|
|
295
|
+
cancel: cancelled ? 'cancelled' : opts.cancelOnInterrupt === false ? 'skipped' : 'failed',
|
|
296
|
+
nextAction,
|
|
297
|
+
},
|
|
345
298
|
});
|
|
346
299
|
}
|
|
347
300
|
try {
|
|
@@ -379,7 +332,7 @@ function shutdownAwareTunnelClient(create, signal) {
|
|
|
379
332
|
};
|
|
380
333
|
}
|
|
381
334
|
/** Keep each dispatch on one verbatim loopback URL; public runs omit tunnel fields. */
|
|
382
|
-
export function groupEnvironmentTargets(ids, targets
|
|
335
|
+
export function groupEnvironmentTargets(ids, targets) {
|
|
383
336
|
const groups = new Map();
|
|
384
337
|
for (const id of ids) {
|
|
385
338
|
const key = targets.get(id)?.targetUrl;
|
|
@@ -387,28 +340,24 @@ export function groupEnvironmentTargets(ids, targets, maxLocalGroupSize = Infini
|
|
|
387
340
|
group.push(id);
|
|
388
341
|
groups.set(key, group);
|
|
389
342
|
}
|
|
390
|
-
return [...groups.values()]
|
|
391
|
-
if (!targets.has(group[0]) || !Number.isFinite(maxLocalGroupSize))
|
|
392
|
-
return [group];
|
|
393
|
-
const chunks = [];
|
|
394
|
-
for (let index = 0; index < group.length; index += maxLocalGroupSize)
|
|
395
|
-
chunks.push(group.slice(index, index + maxLocalGroupSize));
|
|
396
|
-
return chunks;
|
|
397
|
-
});
|
|
343
|
+
return [...groups.values()];
|
|
398
344
|
}
|
|
399
345
|
export function quoteEnvironmentName(name) {
|
|
400
346
|
return "'" + name.replaceAll("'", "'\\''") + "'";
|
|
401
347
|
}
|
|
402
|
-
export async function emitEnvironmentDispatchPartial(responses, testIds, opts, deps, label, error, context
|
|
348
|
+
export async function emitEnvironmentDispatchPartial(responses, testIds, opts, deps, label, error, context,
|
|
349
|
+
/** The reason a `notFound` id was not dispatched (`run --testlist`: not a member of the list). */
|
|
350
|
+
notFoundNote) {
|
|
403
351
|
const message = error instanceof Error ? error.message : String(error);
|
|
404
352
|
const timedOut = error instanceof RequestTimeoutError ||
|
|
405
353
|
(error instanceof ApiError && error.code === 'UNSUPPORTED' && message.startsWith('Timed out'));
|
|
406
354
|
const accepted = responses
|
|
407
355
|
.flatMap(response => response.accepted)
|
|
356
|
+
.map(listResultReceipt)
|
|
408
357
|
.map(row => ({
|
|
409
358
|
...row,
|
|
410
|
-
status: context.cancellation(row.runId) ??
|
|
411
|
-
context.
|
|
359
|
+
status: (row.runId ? context.cancellation(row.runId) : undefined) ??
|
|
360
|
+
context.resultStatus(row.resultId) ??
|
|
412
361
|
(timedOut ? 'timeout' : 'running'),
|
|
413
362
|
}));
|
|
414
363
|
const conflicts = responses.flatMap(response => response.conflicts);
|
|
@@ -418,24 +367,34 @@ export async function emitEnvironmentDispatchPartial(responses, testIds, opts, d
|
|
|
418
367
|
for (const id of notFound)
|
|
419
368
|
seen.add(id);
|
|
420
369
|
const notRunTestIds = testIds.filter(id => !seen.has(id));
|
|
421
|
-
const
|
|
422
|
-
accepted,
|
|
370
|
+
const buckets = {
|
|
423
371
|
conflicts,
|
|
424
372
|
deferred,
|
|
425
373
|
...(context.skipped?.length ? { skipped: context.skipped } : {}),
|
|
426
|
-
notRunTestIds,
|
|
427
374
|
...(responses.some(response => response.notFound) ? { notFound } : {}),
|
|
428
375
|
};
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
376
|
+
const { output, summary } = buildRunOutput({
|
|
377
|
+
receipts: launchIds(accepted).map(runId => ({ runId })),
|
|
378
|
+
dispatched: accepted,
|
|
379
|
+
wait: true,
|
|
380
|
+
failure: error,
|
|
381
|
+
requestTimedOut: timedOut,
|
|
382
|
+
incompleteDispatch: true,
|
|
383
|
+
cancellation: context.cancellation,
|
|
384
|
+
buckets: {
|
|
385
|
+
...buckets,
|
|
386
|
+
skipped: [
|
|
387
|
+
...(context.skipped ?? []),
|
|
388
|
+
...notRunTestIds.map(testId => ({
|
|
389
|
+
testId,
|
|
390
|
+
reason: 'not dispatched before the owned tunnel closed',
|
|
391
|
+
})),
|
|
392
|
+
],
|
|
393
|
+
},
|
|
394
|
+
notFoundNote,
|
|
395
|
+
});
|
|
396
|
+
const stderr = terminalSafeWriter(deps.stderr);
|
|
397
|
+
new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr }).print({ ...output, ...buckets, notRunTestIds }, () => renderRunResults(output.runs, output.results, summary));
|
|
439
398
|
emitCiArtifacts(summary, opts, {
|
|
440
399
|
env: deps.env ?? process.env,
|
|
441
400
|
stdout: deps.stdout ?? (line => process.stdout.write(`${line}\n`)),
|
|
@@ -446,12 +405,19 @@ export async function emitEnvironmentDispatchPartial(responses, testIds, opts, d
|
|
|
446
405
|
await writeJUnitReportFile(opts.reportFile, buildJUnitReport({
|
|
447
406
|
suiteName: opts.reportSuiteName ?? `testsprite:${label}`,
|
|
448
407
|
classname: label,
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
408
|
+
// A test that never dispatched is skipped with its own reason. A
|
|
409
|
+
// dispatched one keeps the status it reached (running, timeout, a
|
|
410
|
+
// verdict) and names the error that closed the tunnel, which is why
|
|
411
|
+
// this is not `junitRowsFromSummary`.
|
|
412
|
+
results: summary.results.map(row => isNonDispatchedStatus(row.status)
|
|
413
|
+
? skippedRowFromSummary(row)
|
|
414
|
+
: {
|
|
415
|
+
testId: row.testId ?? row.resultId ?? '(unknown)',
|
|
416
|
+
resultId: row.resultId,
|
|
417
|
+
runId: row.runId,
|
|
418
|
+
status: row.status,
|
|
419
|
+
error: { code: error instanceof ApiError ? error.code : 'UNSUPPORTED', message },
|
|
420
|
+
}),
|
|
455
421
|
}));
|
|
456
422
|
}
|
|
457
423
|
catch (err) {
|