@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
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { waitForRun, resolveRunWaitFailure } from '../lib/run-wait.js';
|
|
2
2
|
import { resolveEnvironmentRunTarget, readEnvironmentPreflight, groupEnvironmentTargets, emitEnvironmentDispatchPartial, withEnvironmentTunnel, } from '../lib/environment-tunnel.js';
|
|
3
3
|
import { globalShutdown } from '../lib/interrupt.js';
|
|
4
|
+
import { TunnelLostError } from '../lib/tunnel-session.js';
|
|
4
5
|
import { randomUUID } from 'node:crypto';
|
|
5
6
|
import { Command } from 'commander';
|
|
6
7
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
@@ -8,16 +9,18 @@ import { ApiError, CLIError, InterruptError, RequestTimeoutError, localValidatio
|
|
|
8
9
|
import { REQUEST_TIMEOUT_DEFAULT_MS, REQUEST_TIMEOUT_MAX_MS, } from '../lib/http.js';
|
|
9
10
|
import { resolveProfileName } from '../lib/config.js';
|
|
10
11
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
12
|
+
import { emitCiArtifacts } from '../lib/gh-output.js';
|
|
13
|
+
import { buildRunOutput, listResultReceipt, previewRun, renderRunResults, } from '../lib/run-output.js';
|
|
13
14
|
import { billingConflictLink, describeConflict, insufficientCreditsConflictError, isAllCreditsRefusal, isPausedRefusal, pausedConflictError, summarizeConflicts, } from '../lib/conflict-reason.js';
|
|
14
15
|
import { recordBatchOutcome } from '../lib/telemetry.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { markRunWaitInterrupt } from '../lib/render-error.js';
|
|
17
|
+
import { interruptDetachMessage, launchIds, waitCommand } from '../lib/run-render.js';
|
|
18
|
+
import { assertJUnitReportOptions, buildJUnitReport, parseJUnitReportFormat, skippedJUnitResultsFromSummary, writeJUnitReportFile, writeReportOwing, assertArtifactPath, } from '../lib/junit-report.js';
|
|
18
19
|
import { renderTextTable, resolveTextColumns } from '../lib/text-table.js';
|
|
19
20
|
import { assertIdempotencyKey } from '../lib/validate.js';
|
|
20
|
-
import {
|
|
21
|
+
import { terminalSafeLine, terminalSafeWriter } from '../lib/terminal-text.js';
|
|
22
|
+
/** Why a `--case` id the server reports as not found was not dispatched. */
|
|
23
|
+
const NOT_A_MEMBER_NOTE = 'not a member of this list (not dispatched)';
|
|
21
24
|
// ── helpers ──────────────────────────────────────────────────────────────────
|
|
22
25
|
function resolveCommonOptions(command, env) {
|
|
23
26
|
const g = command.optsWithGlobals();
|
|
@@ -44,7 +47,7 @@ function makeOutput(mode, deps) {
|
|
|
44
47
|
}
|
|
45
48
|
function emitIdempotencyKey(opts, deps, key, supplied) {
|
|
46
49
|
if (supplied === undefined && (opts.output === 'json' || opts.verbose || opts.debug)) {
|
|
47
|
-
const stderr = deps.stderr
|
|
50
|
+
const stderr = terminalSafeWriter(deps.stderr);
|
|
48
51
|
stderr(`idempotency-key: ${key}`);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
@@ -67,17 +70,18 @@ function parseProjectEnvs(pairs) {
|
|
|
67
70
|
}
|
|
68
71
|
const collectRepeatable = (value, acc) => [...acc, value];
|
|
69
72
|
function dryRunStderr(deps) {
|
|
70
|
-
return deps.stderr
|
|
73
|
+
return terminalSafeWriter(deps.stderr);
|
|
71
74
|
}
|
|
72
75
|
// Canned `--dry-run` samples (offline, no network) — the global `--dry-run`
|
|
73
|
-
// contract promises a shape-accurate sample for every command.
|
|
76
|
+
// contract promises a shape-accurate sample for every command. They are wire
|
|
77
|
+
// shapes, printed under the output names like a real response.
|
|
74
78
|
const DRY_RUN_LIST = {
|
|
75
79
|
id: 'tl_dryrun',
|
|
76
80
|
name: 'dry-run test list',
|
|
77
81
|
orgId: 'org_dryrun',
|
|
78
82
|
caseCount: 0,
|
|
79
83
|
projectEnvironments: [],
|
|
80
|
-
|
|
84
|
+
lastRunId: null,
|
|
81
85
|
createdAt: '2026-05-16T00:00:00.000Z',
|
|
82
86
|
updatedAt: '2026-05-16T00:00:00.000Z',
|
|
83
87
|
};
|
|
@@ -85,7 +89,7 @@ const DRY_RUN_DETAIL = {
|
|
|
85
89
|
...DRY_RUN_LIST,
|
|
86
90
|
cases: [],
|
|
87
91
|
stats: { total: 0, passed: 0, failed: 0, blocked: 0, running: 0 },
|
|
88
|
-
|
|
92
|
+
lastRunCreated: null,
|
|
89
93
|
};
|
|
90
94
|
// ── run functions (called directly by tests) ─────────────────────────────────
|
|
91
95
|
export async function runTestlistList(opts, deps = {}) {
|
|
@@ -95,24 +99,24 @@ export async function runTestlistList(opts, deps = {}) {
|
|
|
95
99
|
}
|
|
96
100
|
if (opts.dryRun) {
|
|
97
101
|
emitDryRunBanner(dryRunStderr(deps));
|
|
98
|
-
out
|
|
102
|
+
printTestLists(out, [DRY_RUN_LIST], opts);
|
|
99
103
|
return [DRY_RUN_LIST];
|
|
100
104
|
}
|
|
101
105
|
const client = makeClient(opts, deps);
|
|
102
106
|
const resp = await client.get('/testlist');
|
|
103
|
-
out
|
|
107
|
+
printTestLists(out, resp.items, opts);
|
|
104
108
|
return resp.items;
|
|
105
109
|
}
|
|
106
110
|
export async function runTestlistGet(opts, deps = {}) {
|
|
107
111
|
const out = makeOutput(opts.output, deps);
|
|
108
112
|
if (opts.dryRun) {
|
|
109
113
|
emitDryRunBanner(dryRunStderr(deps));
|
|
110
|
-
out
|
|
114
|
+
printTestListDetail(out, DRY_RUN_DETAIL);
|
|
111
115
|
return DRY_RUN_DETAIL;
|
|
112
116
|
}
|
|
113
117
|
const client = makeClient(opts, deps);
|
|
114
118
|
const detail = await client.get(`/testlist/${encodeURIComponent(opts.listId)}`);
|
|
115
|
-
out
|
|
119
|
+
printTestListDetail(out, detail);
|
|
116
120
|
return detail;
|
|
117
121
|
}
|
|
118
122
|
export async function runTestlistCreate(opts, deps = {}) {
|
|
@@ -128,7 +132,7 @@ export async function runTestlistCreate(opts, deps = {}) {
|
|
|
128
132
|
if (opts.dryRun) {
|
|
129
133
|
emitDryRunBanner(dryRunStderr(deps));
|
|
130
134
|
const sample = { ...DRY_RUN_DETAIL, name: opts.name };
|
|
131
|
-
out
|
|
135
|
+
printTestListDetail(out, sample);
|
|
132
136
|
return sample;
|
|
133
137
|
}
|
|
134
138
|
const client = makeClient(opts, deps);
|
|
@@ -136,7 +140,7 @@ export async function runTestlistCreate(opts, deps = {}) {
|
|
|
136
140
|
body: { name: opts.name, ...(projectEnvironments ? { projectEnvironments } : {}) },
|
|
137
141
|
headers: { 'idempotency-key': idempotencyKey },
|
|
138
142
|
});
|
|
139
|
-
out
|
|
143
|
+
printTestListDetail(out, detail);
|
|
140
144
|
return detail;
|
|
141
145
|
}
|
|
142
146
|
export async function runTestlistUpdate(opts, deps = {}) {
|
|
@@ -151,14 +155,14 @@ export async function runTestlistUpdate(opts, deps = {}) {
|
|
|
151
155
|
if (opts.idempotencyKey !== undefined)
|
|
152
156
|
assertIdempotencyKey(opts.idempotencyKey);
|
|
153
157
|
// `[]` (clear) vs the parsed array vs `undefined` (leave untouched) — the
|
|
154
|
-
// three cases the
|
|
158
|
+
// three cases the update contract distinguishes.
|
|
155
159
|
const projectEnvironments = opts.clearProjectEnv ? [] : parseProjectEnvs(opts.projectEnv);
|
|
156
160
|
const idempotencyKey = opts.idempotencyKey ?? `cli-testlist-update-${randomUUID()}`;
|
|
157
161
|
emitIdempotencyKey(opts, deps, idempotencyKey, opts.idempotencyKey);
|
|
158
162
|
if (opts.dryRun) {
|
|
159
163
|
emitDryRunBanner(dryRunStderr(deps));
|
|
160
164
|
const sample = { ...DRY_RUN_DETAIL, ...(opts.name !== undefined ? { name: opts.name } : {}) };
|
|
161
|
-
out
|
|
165
|
+
printTestListDetail(out, sample);
|
|
162
166
|
return sample;
|
|
163
167
|
}
|
|
164
168
|
const client = makeClient(opts, deps);
|
|
@@ -169,7 +173,7 @@ export async function runTestlistUpdate(opts, deps = {}) {
|
|
|
169
173
|
},
|
|
170
174
|
headers: { 'idempotency-key': idempotencyKey },
|
|
171
175
|
});
|
|
172
|
-
out
|
|
176
|
+
printTestListDetail(out, detail);
|
|
173
177
|
return detail;
|
|
174
178
|
}
|
|
175
179
|
export async function runTestlistDelete(opts, deps = {}) {
|
|
@@ -188,12 +192,12 @@ export async function runTestlistDelete(opts, deps = {}) {
|
|
|
188
192
|
if (opts.dryRun) {
|
|
189
193
|
emitDryRunBanner(dryRunStderr(deps));
|
|
190
194
|
const sample = { listId: opts.listId };
|
|
191
|
-
out.print(sample, data => `Deleted test list ${data.listId}`);
|
|
195
|
+
out.print(sample, data => `Deleted test list ${terminalSafeLine(data.listId)}`);
|
|
192
196
|
return sample;
|
|
193
197
|
}
|
|
194
198
|
const client = makeClient(opts, deps);
|
|
195
199
|
const resp = await client.delete(`/testlist/${encodeURIComponent(opts.listId)}`, { headers: { 'idempotency-key': idempotencyKey } });
|
|
196
|
-
out.print(resp, data => `Deleted test list ${data.listId}`);
|
|
200
|
+
out.print(resp, data => `Deleted test list ${terminalSafeLine(data.listId)}`);
|
|
197
201
|
return resp;
|
|
198
202
|
}
|
|
199
203
|
async function mutateCases(verb, opts, deps) {
|
|
@@ -207,7 +211,7 @@ async function mutateCases(verb, opts, deps) {
|
|
|
207
211
|
emitIdempotencyKey(opts, deps, idempotencyKey, opts.idempotencyKey);
|
|
208
212
|
if (opts.dryRun) {
|
|
209
213
|
emitDryRunBanner(dryRunStderr(deps));
|
|
210
|
-
out
|
|
214
|
+
printTestListDetail(out, DRY_RUN_DETAIL);
|
|
211
215
|
return DRY_RUN_DETAIL;
|
|
212
216
|
}
|
|
213
217
|
const path = verb === 'add'
|
|
@@ -218,7 +222,7 @@ async function mutateCases(verb, opts, deps) {
|
|
|
218
222
|
body: { testIds: opts.testIds },
|
|
219
223
|
headers: { 'idempotency-key': idempotencyKey },
|
|
220
224
|
});
|
|
221
|
-
out
|
|
225
|
+
printTestListDetail(out, detail);
|
|
222
226
|
return detail;
|
|
223
227
|
}
|
|
224
228
|
export const runTestlistAdd = (opts, deps = {}) => mutateCases('add', opts, deps);
|
|
@@ -232,7 +236,7 @@ const WAIT_REQUEST_TIMEOUT_CUSHION_MS = 5_000;
|
|
|
232
236
|
* Under `--wait`, raise the per-request HTTP timeout to cover `--timeout` so a
|
|
233
237
|
* slow trigger / long-poll on a large list isn't cut short by the default 120s
|
|
234
238
|
* request deadline and mis-reported as a member timeout. Mirrors
|
|
235
|
-
* `
|
|
239
|
+
* `run`'s `resolveWaitRequestTimeoutMs` (reimplemented locally to keep this
|
|
236
240
|
* file off the `test.ts` module — see the security-lint note on `run`).
|
|
237
241
|
*/
|
|
238
242
|
export function waitRequestTimeoutMs(opts) {
|
|
@@ -242,7 +246,7 @@ export function waitRequestTimeoutMs(opts) {
|
|
|
242
246
|
const cover = Math.min(opts.timeoutSeconds * 1000 + WAIT_REQUEST_TIMEOUT_CUSHION_MS, REQUEST_TIMEOUT_MAX_MS);
|
|
243
247
|
return Math.max(base, cover);
|
|
244
248
|
}
|
|
245
|
-
/** Parse `--timeout <s>` (1–3600, default 600). Mirrors `
|
|
249
|
+
/** Parse `--timeout <s>` (1–3600, default 600). Mirrors `run`'s bounds. */
|
|
246
250
|
function parseTestlistTimeoutFlag(raw) {
|
|
247
251
|
if (raw === undefined)
|
|
248
252
|
return DEFAULT_TESTLIST_RUN_TIMEOUT_SECONDS;
|
|
@@ -262,9 +266,30 @@ function parseTestlistConcurrencyFlag(raw) {
|
|
|
262
266
|
}
|
|
263
267
|
return n;
|
|
264
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* A list that started nothing and refused nothing (an empty list, or one whose
|
|
271
|
+
* every case was left out) is exit 5, as on `run --project`: a CI gate that is
|
|
272
|
+
* green on zero tests is worse than no gate. `--allow-empty` keeps exit 0.
|
|
273
|
+
* Checked last, so a rate-deferred (7) or unknown (4) case is reported first.
|
|
274
|
+
*/
|
|
275
|
+
function assertDispatched(resp, allowEmpty, stderrFn) {
|
|
276
|
+
if (resp.accepted.length > 0 || resp.conflicts.length > 0)
|
|
277
|
+
return;
|
|
278
|
+
const reason = resp.reason === 'empty_list'
|
|
279
|
+
? 'the list is empty'
|
|
280
|
+
: resp.reason === 'no_matching_cases'
|
|
281
|
+
? 'no test in the list matched'
|
|
282
|
+
: 'the list started no test';
|
|
283
|
+
if (allowEmpty) {
|
|
284
|
+
stderrFn(`[run] 0 tests dispatched (${reason}); --allow-empty set — exiting 0.`);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
throw new CLIError(`No tests were dispatched — ${reason}. A CI gate that passes on zero tests is unsafe; ` +
|
|
288
|
+
'pass --allow-empty to exit 0 intentionally.', 5);
|
|
289
|
+
}
|
|
265
290
|
/**
|
|
266
291
|
* Rate-deferred members were never dispatched → the batch is incomplete (exit 7),
|
|
267
|
-
* mirroring `
|
|
292
|
+
* mirroring `run --project`. The backend applies the same per-key run-rate
|
|
268
293
|
* soft-fold as `POST /tests/batch/run` and returns the overflow here, so a
|
|
269
294
|
* partial dispatch surfaces as a non-zero exit instead of silently passing CI.
|
|
270
295
|
*/
|
|
@@ -285,12 +310,12 @@ function assertNoDeferred(resp) {
|
|
|
285
310
|
function assertNoNotFound(resp) {
|
|
286
311
|
if (!resp.notFound || resp.notFound.length === 0)
|
|
287
312
|
return;
|
|
288
|
-
throw new CLIError(`${resp.notFound.length}
|
|
313
|
+
throw new CLIError(`${resp.notFound.length} test ID(s) not in this list: ${resp.notFound.join(' ')}`, 4);
|
|
289
314
|
}
|
|
290
315
|
/**
|
|
291
|
-
* `testlist
|
|
292
|
-
* with `--wait`, poll every returned
|
|
293
|
-
* JUnit XML report (`--report junit`).
|
|
316
|
+
* `run --testlist` — dispatch the list's cases (optionally a `--case` subset) and,
|
|
317
|
+
* with `--wait`, poll every returned resultId to a verdict, optionally writing a
|
|
318
|
+
* JUnit XML report (`--report junit`).
|
|
294
319
|
*/
|
|
295
320
|
function validateTestlistRunOptions(opts) {
|
|
296
321
|
if (opts.idempotencyKey !== undefined)
|
|
@@ -300,23 +325,26 @@ function validateTestlistRunOptions(opts) {
|
|
|
300
325
|
opts.maxConcurrency > MAX_TESTLIST_RUN_CONCURRENCY) {
|
|
301
326
|
throw localValidationError('max-concurrency', `must be an integer between 1 and ${MAX_TESTLIST_RUN_CONCURRENCY}`);
|
|
302
327
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
throw localValidationError('report', '--report junit requires --wait (verdicts come from the poll)');
|
|
308
|
-
}
|
|
328
|
+
// Same report-flag rules as `run` via the shared
|
|
329
|
+
// validator: orphan --report-file / --report-suite-name and --report junit
|
|
330
|
+
// without --wait are refused before anything is dispatched (#569).
|
|
331
|
+
assertJUnitReportOptions({ ...opts, wait: opts.wait === true, batchPath: true });
|
|
309
332
|
// --gh-output / --summary-file reduce a --wait run's per-member results into the
|
|
310
333
|
// CI summary. They require --wait (without it the command returns after dispatch,
|
|
311
334
|
// before any terminal result exists) — reject loudly, same rule as --report junit
|
|
312
|
-
// above and the sibling `
|
|
313
|
-
// GITHUB_ACTIONS auto-enable must stay silent without --wait, same as `
|
|
335
|
+
// above and the sibling `run` flags. Gate only the EXPLICIT flags; the
|
|
336
|
+
// GITHUB_ACTIONS auto-enable must stay silent without --wait, same as `run`.
|
|
314
337
|
if (opts.ghOutput === true && !opts.wait) {
|
|
315
338
|
throw localValidationError('gh-output', '--gh-output requires --wait (it reduces the terminal run result). Add --wait.');
|
|
316
339
|
}
|
|
317
340
|
if (opts.summaryFile !== undefined && !opts.wait) {
|
|
318
341
|
throw localValidationError('summary-file', '--summary-file requires --wait (it reduces the terminal run result). Add --wait.');
|
|
319
342
|
}
|
|
343
|
+
if (opts.report === 'junit' && opts.reportFile !== undefined) {
|
|
344
|
+
assertArtifactPath('report-file', opts.reportFile);
|
|
345
|
+
}
|
|
346
|
+
if (opts.summaryFile !== undefined)
|
|
347
|
+
assertArtifactPath('summary-file', opts.summaryFile);
|
|
320
348
|
}
|
|
321
349
|
export async function runTestlistRun(opts, deps = {}) {
|
|
322
350
|
validateTestlistRunOptions({ ...opts, wait: opts.wait || (!opts.dryRun && !opts.noWait) });
|
|
@@ -330,7 +358,7 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
330
358
|
validateTestlistRunOptions(opts);
|
|
331
359
|
throw err;
|
|
332
360
|
}
|
|
333
|
-
const stderr = deps.stderr
|
|
361
|
+
const stderr = terminalSafeWriter(deps.stderr);
|
|
334
362
|
let list;
|
|
335
363
|
try {
|
|
336
364
|
list = await readEnvironmentPreflight(client, `/testlist/${encodeURIComponent(opts.listId)}`);
|
|
@@ -375,23 +403,39 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
375
403
|
(!opts.cases?.length || opts.cases.includes(test.testId)))
|
|
376
404
|
.map(test => test.testId);
|
|
377
405
|
cases.push(...(opts.cases ?? []).filter(id => !list.cases?.some(test => test.testId === id)));
|
|
378
|
-
return withEnvironmentTunnel({ ...opts, maxConcurrency, requestTimeoutMs: waitRequestTimeoutMs({ ...opts, wait: true }) }, deps, [...targets.values()], '
|
|
406
|
+
return withEnvironmentTunnel({ ...opts, maxConcurrency, requestTimeoutMs: waitRequestTimeoutMs({ ...opts, wait: true }) }, deps, [...targets.values()], 'run', context => {
|
|
379
407
|
context.targets = targets;
|
|
380
408
|
context.skipped = backend;
|
|
381
409
|
return runTestlistRunCore({ ...opts, cases, wait: true, maxConcurrency }, { ...deps, environmentTunnel: context });
|
|
382
410
|
});
|
|
383
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* Dispatch selected list members and optionally collect their terminal results.
|
|
414
|
+
* On interruption, emit acknowledged runs and settled outcomes before rethrowing;
|
|
415
|
+
* tunnel execution retains its separate cancellation and partial-output handling.
|
|
416
|
+
*/
|
|
384
417
|
async function runTestlistRunCore(opts, deps = {}) {
|
|
385
418
|
validateTestlistRunOptions(opts);
|
|
386
419
|
const out = makeOutput(opts.output, deps);
|
|
387
|
-
const stderrFn = deps.stderr
|
|
420
|
+
const stderrFn = terminalSafeWriter(deps.stderr);
|
|
388
421
|
const idempotencyKey = opts.idempotencyKey ?? `cli-testlist-run-${randomUUID()}`;
|
|
389
422
|
emitIdempotencyKey(opts, deps, idempotencyKey, opts.idempotencyKey);
|
|
390
423
|
if (opts.dryRun) {
|
|
391
424
|
emitDryRunBanner(dryRunStderr(deps));
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
425
|
+
const path = `/api/cli/v1/testlist/${encodeURIComponent(opts.listId)}/run`;
|
|
426
|
+
const preview = previewRun([
|
|
427
|
+
{
|
|
428
|
+
method: 'POST',
|
|
429
|
+
path,
|
|
430
|
+
body: {
|
|
431
|
+
...(opts.cases?.length ? { testIds: opts.cases } : {}),
|
|
432
|
+
maxConcurrency: opts.maxConcurrency,
|
|
433
|
+
},
|
|
434
|
+
idempotencyKey,
|
|
435
|
+
},
|
|
436
|
+
], opts.wait, opts.wait);
|
|
437
|
+
out.print(preview, () => `dry-run: POST ${path}`);
|
|
438
|
+
return preview;
|
|
395
439
|
}
|
|
396
440
|
// Under --wait, raise the per-request timeout to cover --timeout (see helper).
|
|
397
441
|
const client = deps.environmentTunnel?.client ??
|
|
@@ -399,28 +443,42 @@ async function runTestlistRunCore(opts, deps = {}) {
|
|
|
399
443
|
let resp;
|
|
400
444
|
if (deps.environmentTunnel) {
|
|
401
445
|
const targets = deps.environmentTunnel.targets;
|
|
402
|
-
const groups = groupEnvironmentTargets(opts.cases ?? [...targets.keys()], targets
|
|
446
|
+
const groups = groupEnvironmentTargets(opts.cases ?? [...targets.keys()], targets);
|
|
403
447
|
const responses = [];
|
|
404
448
|
try {
|
|
405
449
|
for (const [index, testIds] of groups.entries()) {
|
|
406
450
|
const target = targets.get(testIds[0]);
|
|
407
451
|
const suffix = groups.length > 1 ? `:group${index}` : '';
|
|
408
|
-
if (target)
|
|
409
|
-
await deps.environmentTunnel.waitForCapacity(testIds.length);
|
|
410
452
|
const response = await client.triggerTestListRun(opts.listId, {
|
|
411
453
|
testIds,
|
|
454
|
+
maxConcurrency: target ? deps.environmentTunnel.maxConcurrency : opts.maxConcurrency,
|
|
412
455
|
...(target
|
|
413
456
|
? { targetUrl: target.targetUrl, tunnelClientId: deps.environmentTunnel.clientId }
|
|
414
457
|
: {}),
|
|
415
458
|
}, { idempotencyKey: `${idempotencyKey.slice(0, 256 - suffix.length)}${suffix}` });
|
|
416
459
|
responses.push(response);
|
|
417
|
-
if (target)
|
|
418
|
-
|
|
460
|
+
if (target) {
|
|
461
|
+
// The response also tells the tunnel which launch each result is in.
|
|
462
|
+
await deps.environmentTunnel.confirm(response, response.accepted.flatMap(row => (row.runId ? [row.runId] : [])));
|
|
463
|
+
if (response.accepted.some(row => row.runId) &&
|
|
464
|
+
(!Number.isInteger(response.maxConcurrency) ||
|
|
465
|
+
response.maxConcurrency < 1 ||
|
|
466
|
+
response.maxConcurrency > deps.environmentTunnel.maxConcurrency)) {
|
|
467
|
+
await deps.environmentTunnel.cancelActive();
|
|
468
|
+
throw new ApiError({
|
|
469
|
+
code: 'UNSUPPORTED',
|
|
470
|
+
message: 'The server did not confirm the requested local concurrency limit.',
|
|
471
|
+
nextAction: 'Upgrade the backend before retrying this local test-list run.',
|
|
472
|
+
requestId: 'local',
|
|
473
|
+
details: { field: 'maxConcurrency' },
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
419
477
|
}
|
|
420
478
|
}
|
|
421
479
|
catch (err) {
|
|
422
480
|
if (responses.length)
|
|
423
|
-
await emitEnvironmentDispatchPartial(responses, groups.flat(), opts, deps, 'testlist', err, deps.environmentTunnel);
|
|
481
|
+
await emitEnvironmentDispatchPartial(responses, groups.flat(), opts, deps, 'testlist', err, deps.environmentTunnel, NOT_A_MEMBER_NOTE);
|
|
424
482
|
throw err;
|
|
425
483
|
}
|
|
426
484
|
resp = {
|
|
@@ -437,27 +495,43 @@ async function runTestlistRunCore(opts, deps = {}) {
|
|
|
437
495
|
};
|
|
438
496
|
}
|
|
439
497
|
else {
|
|
440
|
-
resp = await client.triggerTestListRun(opts.listId,
|
|
498
|
+
resp = await client.triggerTestListRun(opts.listId, {
|
|
499
|
+
...(opts.cases?.length ? { testIds: opts.cases } : {}),
|
|
500
|
+
maxConcurrency: opts.maxConcurrency,
|
|
501
|
+
}, { idempotencyKey });
|
|
441
502
|
}
|
|
442
503
|
// Partial `--case` miss: some ids were not members of this list. The matched
|
|
443
504
|
// subset still dispatched; a FULL miss is a 404 upstream and never reaches
|
|
444
505
|
// here. Warn on stderr so JSON stdout stays the machine payload (the ids are
|
|
445
506
|
// also carried on `resp.notFound`).
|
|
446
507
|
if (resp.notFound && resp.notFound.length > 0) {
|
|
447
|
-
stderrFn(`warning: ${resp.notFound.length}
|
|
508
|
+
stderrFn(`warning: ${resp.notFound.length} test ID(s) not in this list, skipped: ${terminalSafeLine(resp.notFound.join(' '))}`);
|
|
448
509
|
}
|
|
449
510
|
if (resp.accepted.length > 0) {
|
|
450
511
|
const link = billingConflictLink(resp.conflicts, client.resolvedBaseUrl);
|
|
451
512
|
if (link)
|
|
452
513
|
stderrFn(`[advisory] Billing refusal for some tests.${link}`);
|
|
453
514
|
}
|
|
515
|
+
const { accepted, ...dispatchMetadata } = resp;
|
|
516
|
+
const runIds = launchIds(accepted);
|
|
517
|
+
const receipts = runIds.map(runId => ({ runId }));
|
|
518
|
+
const dispatched = accepted.map(listResultReceipt);
|
|
519
|
+
const outputOptions = {
|
|
520
|
+
receipts,
|
|
521
|
+
dispatched,
|
|
522
|
+
wait: opts.wait,
|
|
523
|
+
buckets: dispatchMetadata,
|
|
524
|
+
notFoundNote: NOT_A_MEMBER_NOTE,
|
|
525
|
+
cancellation: deps.environmentTunnel?.cancellation,
|
|
526
|
+
};
|
|
454
527
|
// All-conflict: nothing new dispatched because every targeted case is already
|
|
455
528
|
// in flight → exit 6, for BOTH --wait and non-wait (a --wait over zero accepted
|
|
456
529
|
// would otherwise no-op straight to exit 0). Distinct from the empty/no-match
|
|
457
|
-
// case (accepted AND conflicts both empty), which
|
|
458
|
-
//
|
|
530
|
+
// case (accepted AND conflicts both empty), which flows through the tail
|
|
531
|
+
// below so its CI artifacts are still emitted before `assertDispatched`.
|
|
459
532
|
if (resp.accepted.length === 0 && resp.conflicts.length > 0) {
|
|
460
|
-
|
|
533
|
+
const { output, summary } = buildRunOutput(outputOptions);
|
|
534
|
+
out.print({ ...output, ...dispatchMetadata }, () => renderRunResults(output.runs, output.results, opts.wait ? summary : undefined, conflictRows(resp.conflicts)));
|
|
461
535
|
recordBatchOutcome({
|
|
462
536
|
accepted: 0,
|
|
463
537
|
conflicts: resp.conflicts,
|
|
@@ -470,29 +544,20 @@ async function runTestlistRunCore(opts, deps = {}) {
|
|
|
470
544
|
// into the summary as non-passed rows. The non-wait path never emits CI
|
|
471
545
|
// artifacts, matching the main tail below.
|
|
472
546
|
if (opts.wait) {
|
|
473
|
-
const summary = summarizeAcceptedPayload(JSON.stringify({
|
|
474
|
-
accepted: [],
|
|
475
|
-
conflicts: resp.conflicts,
|
|
476
|
-
deferred: resp.deferred,
|
|
477
|
-
// Include notFound too: a mixed `--case` selection can be
|
|
478
|
-
// all-conflict on its matched ids AND carry not-in-list ids, and the
|
|
479
|
-
// CI summary must report the whole requested set (same reason the
|
|
480
|
-
// main --wait envelope threads it). Undefined ⇒ JSON.stringify drops it.
|
|
481
|
-
notFound: resp.notFound,
|
|
482
|
-
}), { notFoundNote: 'not a member of this list (not dispatched)' });
|
|
483
547
|
if (opts.report === 'junit' && opts.reportFile !== undefined) {
|
|
548
|
+
const file = opts.reportFile;
|
|
484
549
|
const suiteName = opts.reportSuiteName ?? `testsprite:testlist:${opts.listId}`;
|
|
485
|
-
await writeJUnitReportFile(
|
|
550
|
+
await writeReportOwing(true, () => writeJUnitReportFile(file, buildJUnitReport({
|
|
486
551
|
suiteName,
|
|
487
552
|
classname: `testlist:${opts.listId}`,
|
|
488
553
|
results: skippedJUnitResultsFromSummary(summary),
|
|
489
|
-
}));
|
|
554
|
+
})), stderrFn, { label: 'run' });
|
|
490
555
|
}
|
|
491
556
|
emitCiArtifacts(summary, opts, {
|
|
492
557
|
env: deps.env ?? process.env,
|
|
493
558
|
stdout: deps.stdout ?? ((line) => process.stdout.write(`${line}\n`)),
|
|
494
559
|
stderr: stderrFn,
|
|
495
|
-
}, '
|
|
560
|
+
}, 'run');
|
|
496
561
|
}
|
|
497
562
|
// Every case refused for credits → exit 12, the same INSUFFICIENT_CREDITS
|
|
498
563
|
// envelope the single-run route answers (a rate-deferred remainder is exit 7
|
|
@@ -503,9 +568,9 @@ async function runTestlistRunCore(opts, deps = {}) {
|
|
|
503
568
|
if (isPausedRefusal(resp)) {
|
|
504
569
|
throw pausedConflictError(resp.conflicts, client.resolvedBaseUrl);
|
|
505
570
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
571
|
+
// `run wait` takes the launch holding each in-flight case; a conflict the
|
|
572
|
+
// backend named no launch for has no command to offer.
|
|
573
|
+
const poll = waitCommand(resp.conflicts.map(c => ({ resultId: c.currentResultId, runId: c.currentRunId })));
|
|
509
574
|
// Name the causes instead of blanket "already in flight" — a list pinned to
|
|
510
575
|
// a local env or a view-only project is not something to poll. The poll hint
|
|
511
576
|
// is emitted only for the cases that actually have an in-flight run. A
|
|
@@ -514,16 +579,16 @@ async function runTestlistRunCore(opts, deps = {}) {
|
|
|
514
579
|
// link — `accepted.length` is 0 in this whole branch, so the advisory
|
|
515
580
|
// printed earlier (guarded on `accepted.length > 0`) never showed it.
|
|
516
581
|
throw new CLIError(`Nothing dispatched — ${resp.conflicts.length} conflict(s): ${summarizeConflicts(resp.conflicts)}` +
|
|
517
|
-
(
|
|
518
|
-
? `. Poll in-flight runs: testsprite test wait ${pollIds.join(' ')}`
|
|
519
|
-
: '') +
|
|
582
|
+
(poll ? `. Poll in-flight runs: ${poll}` : '') +
|
|
520
583
|
billingConflictLink(resp.conflicts, client.resolvedBaseUrl), 6);
|
|
521
584
|
}
|
|
522
585
|
if (!opts.wait) {
|
|
523
|
-
// Print what dispatched, or the empty/no-match reason.
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
586
|
+
// Print what dispatched, or the empty/no-match reason.
|
|
587
|
+
const { output } = buildRunOutput(outputOptions);
|
|
588
|
+
const launch = { ...output, ...dispatchMetadata };
|
|
589
|
+
out.print(launch, () => resp.accepted.length > 0
|
|
590
|
+
? renderRunResults(output.runs, output.results, undefined, conflictRows(resp.conflicts))
|
|
591
|
+
: `No runs dispatched${resp.reason ? ` (${terminalSafeLine(resp.reason)})` : ''}.`);
|
|
527
592
|
recordBatchOutcome({
|
|
528
593
|
accepted: resp.accepted.length,
|
|
529
594
|
conflicts: resp.conflicts,
|
|
@@ -532,233 +597,148 @@ async function runTestlistRunCore(opts, deps = {}) {
|
|
|
532
597
|
});
|
|
533
598
|
assertNoDeferred(resp);
|
|
534
599
|
assertNoNotFound(resp);
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
sleep: deps.sleep,
|
|
567
|
-
onTransition: opts.verbose ? (msg) => stderrFn(`[verbose] ${msg}`) : undefined,
|
|
568
|
-
shutdown: deps.shutdown ?? globalShutdown,
|
|
569
|
-
onTick: (run, elapsedMs) => {
|
|
570
|
-
deps.environmentTunnel?.onPoll(run);
|
|
571
|
-
ticker.update(formatRunProgressLine(run, elapsedMs, `(${entry.testId})`));
|
|
572
|
-
},
|
|
573
|
-
});
|
|
574
|
-
reportDurations.set(entry.runId, durationSecondsBetween(finalRun.startedAt, finalRun.finishedAt, finalRun.createdAt));
|
|
575
|
-
return {
|
|
576
|
-
testId: entry.testId,
|
|
577
|
-
testTitle: finalRun.testTitle ?? null,
|
|
578
|
-
// Give the JUnit `<testcase name>` the human title too (testlist has no
|
|
579
|
-
// separate name sweep like `test run --all`, so this is its only source;
|
|
580
|
-
// renderTestcase falls back to the id when name is absent).
|
|
581
|
-
...(finalRun.testTitle ? { name: finalRun.testTitle } : {}),
|
|
582
|
-
runId: entry.runId,
|
|
583
|
-
projectId: finalRun.projectId,
|
|
584
|
-
status: finalRun.status,
|
|
585
|
-
// Carry both SERVER-built links so the ::error:: annotations and the
|
|
586
|
-
// job-summary are clickable (parity with `test run --all`): the test-case
|
|
587
|
-
// page anchors the Test column title, the execution-result page anchors
|
|
588
|
-
// the Run column. Never a client-built resolvePortalUrl — testlist run is
|
|
589
|
-
// V3-only and the client helper emits the V2 route shape which 404s.
|
|
590
|
-
...(typeof finalRun.dashboardUrl === 'string'
|
|
591
|
-
? { dashboardUrl: finalRun.dashboardUrl }
|
|
592
|
-
: {}),
|
|
593
|
-
...(typeof finalRun.executionUrl === 'string'
|
|
594
|
-
? { executionUrl: finalRun.executionUrl }
|
|
595
|
-
: {}),
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
catch (err) {
|
|
599
|
-
if (deps.environmentTunnel && err instanceof TunnelLostError)
|
|
600
|
-
throw err;
|
|
601
|
-
if (err instanceof TimeoutError) {
|
|
602
|
-
return {
|
|
603
|
-
testId: entry.testId,
|
|
604
|
-
runId: entry.runId,
|
|
605
|
-
status: 'timeout',
|
|
606
|
-
error: {
|
|
607
|
-
code: 'UNSUPPORTED',
|
|
608
|
-
message: `Timed out after ${opts.timeoutSeconds}s`,
|
|
609
|
-
exitCode: 7,
|
|
600
|
+
assertDispatched(resp, opts.allowEmpty === true, stderrFn);
|
|
601
|
+
return launch;
|
|
602
|
+
}
|
|
603
|
+
for (const runId of runIds)
|
|
604
|
+
stderrFn(`Run ${terminalSafeLine(runId)}`);
|
|
605
|
+
const deadline = deps.environmentTunnel?.deadlineMs ?? Date.now() + opts.timeoutSeconds * 1000;
|
|
606
|
+
const outcomes = new Map();
|
|
607
|
+
let failure;
|
|
608
|
+
let requestTimedOut = false;
|
|
609
|
+
if (resp.accepted.some(row => !row.runId))
|
|
610
|
+
failure = new ApiError({
|
|
611
|
+
code: 'UNSUPPORTED',
|
|
612
|
+
message: 'The test-list response did not identify every execution.',
|
|
613
|
+
nextAction: 'Update the server before waiting on this test list.',
|
|
614
|
+
requestId: 'local',
|
|
615
|
+
details: {},
|
|
616
|
+
});
|
|
617
|
+
if (!failure) {
|
|
618
|
+
const stopped = new AbortController();
|
|
619
|
+
await Promise.all(runIds.map(async (runId) => {
|
|
620
|
+
if (stopped.signal.aborted)
|
|
621
|
+
return;
|
|
622
|
+
try {
|
|
623
|
+
const outcome = await waitForRun(client, runId, {
|
|
624
|
+
deadline,
|
|
625
|
+
signal: stopped.signal,
|
|
626
|
+
shutdown: deps.shutdown ?? globalShutdown,
|
|
627
|
+
sleep: deps.sleep,
|
|
628
|
+
onRead: async (snapshot, signal) => {
|
|
629
|
+
outcomes.set(runId, { ...snapshot, runId, timedOut: false, missingResultIds: [] });
|
|
630
|
+
await deps.environmentTunnel?.onRead(snapshot, signal);
|
|
610
631
|
},
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
// Interrupt must reject the whole fan-out (never flatten to a per-member
|
|
614
|
-
// outcome that would swallow the 128+signum exit).
|
|
615
|
-
if (err instanceof InterruptError)
|
|
616
|
-
throw err;
|
|
617
|
-
if (err instanceof RequestTimeoutError) {
|
|
618
|
-
return {
|
|
619
|
-
testId: entry.testId,
|
|
620
|
-
runId: entry.runId,
|
|
621
|
-
status: 'timeout',
|
|
622
|
-
error: { code: 'UNSUPPORTED', message: err.message, exitCode: err.exitCode },
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
if (err instanceof ApiError) {
|
|
626
|
-
// Preserve the real code/exit (AUTH_INVALID=3, NOT_FOUND=4, …) rather
|
|
627
|
-
// than flattening every member failure to a generic 1.
|
|
628
|
-
return {
|
|
629
|
-
testId: entry.testId,
|
|
630
|
-
runId: entry.runId,
|
|
631
|
-
status: 'error',
|
|
632
|
-
error: waitMemberError(err),
|
|
633
|
-
};
|
|
632
|
+
});
|
|
633
|
+
outcomes.set(runId, outcome);
|
|
634
634
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
resolve();
|
|
655
|
-
})
|
|
656
|
-
.catch(reject);
|
|
635
|
+
catch (err) {
|
|
636
|
+
if (err instanceof ApiError)
|
|
637
|
+
outcomes.set(runId, {
|
|
638
|
+
...(outcomes.get(runId) ?? {
|
|
639
|
+
runId,
|
|
640
|
+
run: null,
|
|
641
|
+
results: [],
|
|
642
|
+
timedOut: false,
|
|
643
|
+
missingResultIds: [],
|
|
644
|
+
}),
|
|
645
|
+
error: err,
|
|
646
|
+
});
|
|
647
|
+
else {
|
|
648
|
+
if (failure === undefined || err instanceof InterruptError)
|
|
649
|
+
failure = err;
|
|
650
|
+
if (err instanceof RequestTimeoutError)
|
|
651
|
+
requestTimedOut = true;
|
|
652
|
+
else
|
|
653
|
+
stopped.abort(err);
|
|
657
654
|
}
|
|
655
|
+
if (err instanceof TunnelLostError)
|
|
656
|
+
stopped.abort(err);
|
|
658
657
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
if (
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
...(resp.notFound && resp.notFound.length > 0 ? { notFound: resp.notFound } : {}),
|
|
685
|
-
// Present only on a nothing-dispatched run (empty list / no-match --case);
|
|
686
|
-
// surfaced here so the --wait envelope explains a zero-run report.
|
|
687
|
-
...(resp.reason ? { reason: resp.reason } : {}),
|
|
688
|
-
summary: {
|
|
689
|
-
passed,
|
|
690
|
-
failed,
|
|
691
|
-
timedOut,
|
|
692
|
-
deferred: resp.deferred.length,
|
|
693
|
-
conflicts: resp.conflicts.length,
|
|
694
|
-
total: resp.accepted.length,
|
|
695
|
-
},
|
|
696
|
-
};
|
|
697
|
-
if (opts.report === 'junit' && opts.reportFile !== undefined) {
|
|
698
|
-
// Multi-project list: name the suite/classname by the LIST, not one project
|
|
699
|
-
// (`resolveBatchReportProjectId`'s single-project assumption doesn't hold).
|
|
700
|
-
const suiteName = opts.reportSuiteName ?? `testsprite:testlist:${opts.listId}`;
|
|
701
|
-
const summary = summarizeAcceptedPayload(JSON.stringify(jsonPayload), {
|
|
702
|
-
notFoundNote: 'not a member of this list (not dispatched)',
|
|
703
|
-
});
|
|
704
|
-
const xml = buildJUnitReport({
|
|
705
|
-
suiteName,
|
|
706
|
-
classname: `testlist:${opts.listId}`,
|
|
707
|
-
results: [
|
|
708
|
-
...results.map(r => ({
|
|
709
|
-
...r,
|
|
710
|
-
durationSeconds: r.runId ? reportDurations.get(r.runId) : undefined,
|
|
711
|
-
})),
|
|
712
|
-
...skippedJUnitResultsFromSummary(summary, results),
|
|
713
|
-
],
|
|
714
|
-
});
|
|
715
|
-
await writeJUnitReportFile(opts.reportFile, xml);
|
|
716
|
-
}
|
|
717
|
-
out.print(jsonPayload, () => results.map(r => `${r.runId} ${r.status}`).join('\n'));
|
|
658
|
+
}));
|
|
659
|
+
}
|
|
660
|
+
// Keep launch order even when independent reads finish in a different order.
|
|
661
|
+
const observed = new Map(outcomes);
|
|
662
|
+
outcomes.clear();
|
|
663
|
+
for (const runId of runIds) {
|
|
664
|
+
const outcome = observed.get(runId);
|
|
665
|
+
if (outcome)
|
|
666
|
+
outcomes.set(runId, outcome);
|
|
667
|
+
}
|
|
668
|
+
if (failure === undefined || failure instanceof RequestTimeoutError) {
|
|
669
|
+
failure =
|
|
670
|
+
resolveRunWaitFailure([...outcomes.values()], { timeoutSeconds: opts.timeoutSeconds }, failure) ?? undefined;
|
|
671
|
+
}
|
|
672
|
+
const tunnel = deps.environmentTunnel;
|
|
673
|
+
if (failure && tunnel)
|
|
674
|
+
await tunnel.cancelActive();
|
|
675
|
+
const { output, members: results, summary, diagnosticRows, unfinishedRuns, } = buildRunOutput({
|
|
676
|
+
...outputOptions,
|
|
677
|
+
outcomes,
|
|
678
|
+
failure,
|
|
679
|
+
requestTimedOut,
|
|
680
|
+
});
|
|
681
|
+
const launch = { ...output, ...dispatchMetadata };
|
|
682
|
+
out.print(launch, () => renderRunResults(output.runs, output.results, summary, conflictRows(resp.conflicts)));
|
|
718
683
|
recordBatchOutcome({
|
|
719
684
|
accepted: resp.accepted.length,
|
|
720
685
|
conflicts: resp.conflicts,
|
|
721
686
|
deferred: resp.deferred.length,
|
|
722
|
-
skipped: 0,
|
|
687
|
+
skipped: tunnel?.skipped?.length ?? 0,
|
|
723
688
|
results,
|
|
724
689
|
});
|
|
725
|
-
|
|
726
|
-
// auto-enable under GITHUB_ACTIONS. Emit BEFORE the exit-code gates below so a
|
|
727
|
-
// failing/timed-out/deferred run still gets its ::error:: annotations + the
|
|
728
|
-
// job-summary table. `emitCiArtifacts` is the shared helper the sibling run
|
|
729
|
-
// paths use, keyed off the identical reduced envelope.
|
|
730
|
-
emitCiArtifacts(summarizeAcceptedPayload(JSON.stringify(jsonPayload), {
|
|
731
|
-
notFoundNote: 'not a member of this list (not dispatched)',
|
|
732
|
-
}), opts, {
|
|
690
|
+
emitCiArtifacts(summary, opts, {
|
|
733
691
|
env: deps.env ?? process.env,
|
|
734
|
-
stdout: deps.stdout ?? (
|
|
692
|
+
stdout: deps.stdout ?? (line => process.stdout.write(`${line}\n`)),
|
|
735
693
|
stderr: stderrFn,
|
|
736
|
-
}, '
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
694
|
+
}, 'run');
|
|
695
|
+
const empty = resp.accepted.length === 0 && resp.conflicts.length === 0;
|
|
696
|
+
const owesExit = failure !== undefined ||
|
|
697
|
+
resp.deferred.length > 0 ||
|
|
698
|
+
(resp.notFound?.length ?? 0) > 0 ||
|
|
699
|
+
(empty && opts.allowEmpty !== true);
|
|
700
|
+
if (opts.report === 'junit' && opts.reportFile) {
|
|
701
|
+
const file = opts.reportFile;
|
|
702
|
+
await writeReportOwing(owesExit, () => writeJUnitReportFile(file, buildJUnitReport({
|
|
703
|
+
suiteName: opts.reportSuiteName ?? `testsprite:testlist:${opts.listId}`,
|
|
704
|
+
classname: `testlist:${opts.listId}`,
|
|
705
|
+
results: [
|
|
706
|
+
...results,
|
|
707
|
+
...diagnosticRows,
|
|
708
|
+
...skippedJUnitResultsFromSummary(summary, results),
|
|
709
|
+
],
|
|
710
|
+
})), stderrFn, { label: 'run' });
|
|
711
|
+
}
|
|
712
|
+
if (failure instanceof InterruptError && unfinishedRuns.length) {
|
|
713
|
+
markRunWaitInterrupt(failure, unfinishedRuns);
|
|
714
|
+
if (!tunnel || tunnel.session.adopted)
|
|
715
|
+
stderrFn(interruptDetachMessage(failure, unfinishedRuns));
|
|
716
|
+
}
|
|
743
717
|
if (failure)
|
|
744
718
|
throw failure;
|
|
719
|
+
assertNoDeferred(resp);
|
|
745
720
|
assertNoNotFound(resp);
|
|
746
|
-
|
|
721
|
+
assertDispatched(resp, opts.allowEmpty === true, stderrFn);
|
|
722
|
+
return launch;
|
|
747
723
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
// Reason-aware: a view-only / un-runnable / not-found case is no longer
|
|
754
|
-
// mislabelled "already-in-flight" (see describeConflict).
|
|
755
|
-
lines.push(`${c.currentRunId ?? '(none)'} ${c.testId} ${describeConflict(c)}`);
|
|
756
|
-
}
|
|
757
|
-
if (lines.length === 0)
|
|
758
|
-
return 'No runs dispatched.';
|
|
759
|
-
return lines.join('\n');
|
|
724
|
+
/** One line per refused member: `<in-flight result or (none)> <testId> <reason>`. */
|
|
725
|
+
function conflictRows(conflicts) {
|
|
726
|
+
// Reason-aware: a view-only / un-runnable / not-found case is no longer
|
|
727
|
+
// mislabelled "already-in-flight" (see describeConflict).
|
|
728
|
+
return conflicts.map(c => `${terminalSafeLine(c.currentResultId ?? '(none)')} ${terminalSafeLine(c.testId)} ${terminalSafeLine(describeConflict(c))}`);
|
|
760
729
|
}
|
|
761
730
|
// ── text renderers ───────────────────────────────────────────────────────────
|
|
731
|
+
/**
|
|
732
|
+
* Print test lists under the output names (`lastRunId`). The caller keeps the
|
|
733
|
+
* lists as the backend sent them.
|
|
734
|
+
*/
|
|
735
|
+
function printTestLists(out, lists, options) {
|
|
736
|
+
out.print(lists, data => renderTestListListText(data, options));
|
|
737
|
+
}
|
|
738
|
+
/** Print one list's detail under the output names; see {@link printTestLists}. */
|
|
739
|
+
function printTestListDetail(out, detail) {
|
|
740
|
+
out.print(detail, data => renderTestListDetailText(data));
|
|
741
|
+
}
|
|
762
742
|
const TESTLIST_COLUMNS = [
|
|
763
743
|
{ header: 'ID', width: rows => Math.max(2, ...rows.map(r => r.id.length)), render: r => r.id },
|
|
764
744
|
{
|
|
@@ -768,9 +748,9 @@ const TESTLIST_COLUMNS = [
|
|
|
768
748
|
},
|
|
769
749
|
{ header: 'CASES', width: 5, render: r => String(r.caseCount) },
|
|
770
750
|
// Fixed 36 (a UUID); `width: 0` (skip-padding) is only valid on the LAST
|
|
771
|
-
// column, and UPDATED is last — a `width: 0` here would leave
|
|
751
|
+
// column, and UPDATED is last — a `width: 0` here would leave LAST RUN
|
|
772
752
|
// unpadded and drift UPDATED per row (UUID 36 chars vs "(none)" 6 chars).
|
|
773
|
-
{ header: '
|
|
753
|
+
{ header: 'LAST RUN', width: 36, render: r => r.lastRunId ?? '(none)' },
|
|
774
754
|
{ header: 'UPDATED', width: 0, render: r => r.updatedAt },
|
|
775
755
|
];
|
|
776
756
|
function renderTestListListText(items, options = {}) {
|
|
@@ -783,15 +763,17 @@ function renderTestListListText(items, options = {}) {
|
|
|
783
763
|
}
|
|
784
764
|
function renderTestListDetailText(d) {
|
|
785
765
|
const lines = [
|
|
786
|
-
`ID: ${d.id}`,
|
|
787
|
-
`Name: ${d.name}`,
|
|
766
|
+
`ID: ${terminalSafeLine(d.id)}`,
|
|
767
|
+
`Name: ${terminalSafeLine(d.name)}`,
|
|
788
768
|
`Cases: ${d.stats.total} (passed ${d.stats.passed}, failed ${d.stats.failed}, blocked ${d.stats.blocked}, running ${d.stats.running})`,
|
|
789
769
|
];
|
|
790
770
|
if (d.projectEnvironments.length > 0) {
|
|
791
|
-
lines.push(`Envs: ${d.projectEnvironments
|
|
771
|
+
lines.push(`Envs: ${d.projectEnvironments
|
|
772
|
+
.map(e => `${terminalSafeLine(e.projectId)}:${terminalSafeLine(e.environmentName)}`)
|
|
773
|
+
.join(', ')}`);
|
|
792
774
|
}
|
|
793
|
-
lines.push(`Last
|
|
794
|
-
lines.push(`Updated: ${d.updatedAt}`);
|
|
775
|
+
lines.push(`Last run: ${terminalSafeLine(d.lastRunId ?? '(none)')}`);
|
|
776
|
+
lines.push(`Updated: ${terminalSafeLine(d.updatedAt)}`);
|
|
795
777
|
if (d.cases.length > 0) {
|
|
796
778
|
lines.push('');
|
|
797
779
|
const caseTable = renderTextTable(d.cases, [
|
|
@@ -908,52 +890,28 @@ export function createTestListCommand(deps = {}) {
|
|
|
908
890
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
909
891
|
}, deps);
|
|
910
892
|
});
|
|
911
|
-
testlist
|
|
912
|
-
.command('run <list-id>')
|
|
913
|
-
.summary('Run a test list')
|
|
914
|
-
.description("Run a test list (dispatch its cases and return pollable run ids). Environments come from the list's --project-env mapping; loopback ones open one tunnel and wait (backend cases are skipped).\n" +
|
|
915
|
-
'\nExit codes:\n' +
|
|
916
|
-
' 0 dispatched (or all passed with --wait)\n' +
|
|
917
|
-
' 1 a run failed / blocked / cancelled\n' +
|
|
918
|
-
' 3 auth error\n' +
|
|
919
|
-
' 4 a --case id is not in the list\n' +
|
|
920
|
-
' 6 nothing dispatched: every case conflicted (already running, or cannot run here)\n' +
|
|
921
|
-
' 7 timeout, or some cases were rate-deferred (retry the printed ids)\n' +
|
|
922
|
-
' 12 insufficient credits (non-retriable; top up)\n' +
|
|
923
|
-
' 13 feature gated / workspace paused')
|
|
924
|
-
.option('--case <test-id>', 'run only this case (repeatable; default: every case in the list)', collectRepeatable, [])
|
|
925
|
-
.option('--wait', 'poll every dispatched run until terminal or --timeout', false)
|
|
926
|
-
.option('--no-wait', 'detach without opening an automatic environment tunnel')
|
|
927
|
-
.option('--skip-preflight', 'skip the loopback port probe before opening a tunnel')
|
|
928
|
-
.option('--timeout <s>', 'with --wait, max seconds to wait (1–3600, default 600)')
|
|
929
|
-
.option('--max-concurrency <n>', `with a tunnel, max runs in flight (1-10, default 5); otherwise with --wait, max polls (1-${MAX_TESTLIST_RUN_CONCURRENCY}, default ${DEFAULT_TESTLIST_RUN_CONCURRENCY})`)
|
|
930
|
-
.option('--idempotency-key <key>', 'caller-supplied idempotency key (1-256 chars)')
|
|
931
|
-
.option('--report <format>', 'with --wait: write a JUnit XML sidecar after polling (accepted: junit)')
|
|
932
|
-
.option('--report-file <path>', 'output path for --report (atomic write)')
|
|
933
|
-
.option('--report-suite-name <name>', 'JUnit <testsuite name=...> override (default: testsprite:testlist:<listId>)')
|
|
934
|
-
.option('--gh-output', 'with --wait: emit GitHub annotations (::error:: failed/timed-out, ::warning:: never dispatched) and a job-summary table when $GITHUB_STEP_SUMMARY is set; auto-enabled when GITHUB_ACTIONS=true')
|
|
935
|
-
.option('--summary-file <path>', 'with --wait: also write summary JSON {total, passed, failed, skipped, timedOut, runs[]} to this file')
|
|
936
|
-
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
937
|
-
.action(async (listId, cmdOpts, command) => {
|
|
938
|
-
const wait = cmdOpts.wait === true;
|
|
939
|
-
await runTestlistRun({
|
|
940
|
-
...resolveCommonOptions(command, deps.env),
|
|
941
|
-
listId,
|
|
942
|
-
cases: cmdOpts.case,
|
|
943
|
-
wait,
|
|
944
|
-
noWait: command.getOptionValueSource('wait') === 'cli' && cmdOpts.wait === false,
|
|
945
|
-
skipPreflight: cmdOpts.skipPreflight === true,
|
|
946
|
-
concurrencyIsDefault: cmdOpts.maxConcurrency === undefined,
|
|
947
|
-
timeoutSeconds: parseTestlistTimeoutFlag(cmdOpts.timeout),
|
|
948
|
-
maxConcurrency: parseTestlistConcurrencyFlag(cmdOpts.maxConcurrency),
|
|
949
|
-
idempotencyKey: cmdOpts.idempotencyKey,
|
|
950
|
-
report: parseJUnitReportFormat(cmdOpts.report),
|
|
951
|
-
reportFile: cmdOpts.reportFile,
|
|
952
|
-
reportSuiteName: cmdOpts.reportSuiteName,
|
|
953
|
-
ghOutput: cmdOpts.ghOutput,
|
|
954
|
-
summaryFile: cmdOpts.summaryFile,
|
|
955
|
-
}, deps);
|
|
956
|
-
});
|
|
957
893
|
return testlist;
|
|
958
894
|
}
|
|
895
|
+
/** Root run's list mode keeps this module's parsers and native list receipt. */
|
|
896
|
+
export async function runTestlistRunFromCommand(command, listId, testIds, deps = {}) {
|
|
897
|
+
const opts = command.opts();
|
|
898
|
+
await runTestlistRun({
|
|
899
|
+
...resolveCommonOptions(command, deps.env),
|
|
900
|
+
listId,
|
|
901
|
+
cases: testIds.length ? testIds : undefined,
|
|
902
|
+
wait: opts.wait === true,
|
|
903
|
+
noWait: command.getOptionValueSource('wait') === 'cli' && opts.wait === false,
|
|
904
|
+
skipPreflight: opts.skipPreflight === true,
|
|
905
|
+
concurrencyIsDefault: opts.maxConcurrency === undefined,
|
|
906
|
+
timeoutSeconds: parseTestlistTimeoutFlag(opts.timeout),
|
|
907
|
+
maxConcurrency: parseTestlistConcurrencyFlag(opts.maxConcurrency),
|
|
908
|
+
idempotencyKey: opts.idempotencyKey,
|
|
909
|
+
report: parseJUnitReportFormat(opts.report),
|
|
910
|
+
reportFile: opts.reportFile,
|
|
911
|
+
reportSuiteName: opts.reportSuiteName,
|
|
912
|
+
ghOutput: opts.ghOutput,
|
|
913
|
+
summaryFile: opts.summaryFile,
|
|
914
|
+
allowEmpty: opts.allowEmpty === true,
|
|
915
|
+
}, deps);
|
|
916
|
+
}
|
|
959
917
|
//# sourceMappingURL=testlist.js.map
|