@testsprite/testsprite-cli 0.9.0 → 0.11.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 +64 -41
- package/dist/commands/auth.d.ts +5 -1
- package/dist/commands/auth.js +17 -5
- package/dist/commands/init.d.ts +6 -1
- package/dist/commands/init.js +13 -5
- package/dist/commands/project.d.ts +30 -0
- package/dist/commands/project.js +193 -27
- package/dist/commands/test.d.ts +14 -2
- package/dist/commands/test.js +141 -33
- package/dist/commands/tunnel.d.ts +2 -2
- package/dist/commands/tunnel.js +139 -31
- package/dist/index.js +29 -11
- package/dist/lib/client-factory.d.ts +4 -1
- package/dist/lib/client-factory.js +12 -4
- package/dist/lib/credentials.d.ts +4 -0
- package/dist/lib/credentials.js +43 -4
- package/dist/lib/dry-run/samples.js +16 -9
- package/dist/lib/http.d.ts +14 -2
- package/dist/lib/http.js +38 -6
- package/dist/lib/response-schemas.d.ts +5 -2
- package/dist/lib/response-schemas.js +21 -1
- package/dist/lib/runs.types.d.ts +11 -0
- package/dist/lib/target-url.d.ts +1 -1
- package/dist/lib/target-url.js +4 -0
- package/dist/lib/telemetry.d.ts +6 -2
- package/dist/lib/telemetry.js +12 -0
- package/dist/lib/tunnel-session.d.ts +13 -2
- package/dist/lib/tunnel-session.js +92 -23
- package/dist/lib/tunnel.types.d.ts +3 -1
- package/dist/vendor/tunnel-client/client.d.ts +11 -0
- package/dist/vendor/tunnel-client/client.js +383 -56
- package/dist/vendor/tunnel-client/config.d.ts +11 -3
- package/dist/vendor/tunnel-client/config.js +11 -3
- package/dist/vendor/tunnel-client/types.d.ts +26 -1
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +3 -2
- package/dist/vendor/tunnel-client/ws-compat.js +3 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/skills/testsprite-onboard.skill.md +80 -59
- package/skills/testsprite-verify.codex.md +82 -97
- package/skills/testsprite-verify.skill.md +67 -16
package/dist/commands/test.js
CHANGED
|
@@ -11,7 +11,7 @@ import { assertJUnitReportOptions, buildJUnitReport, durationSecondsBetween, res
|
|
|
11
11
|
import { ApiError, CLIError, InterruptError, RequestTimeoutError, TransportError, isAuthCode, localValidationError, } from '../lib/errors.js';
|
|
12
12
|
import { globalShutdown } from '../lib/interrupt.js';
|
|
13
13
|
import { assertIdempotencyKey, requireArrayLength, requireEnum, requireString, } from '../lib/validate.js';
|
|
14
|
-
import { REQUEST_TIMEOUT_DEFAULT_MS, REQUEST_TIMEOUT_MAX_MS } from '../lib/http.js';
|
|
14
|
+
import { isStandingRateLimit, REQUEST_TIMEOUT_DEFAULT_MS, REQUEST_TIMEOUT_MAX_MS, } from '../lib/http.js';
|
|
15
15
|
import { VERSION } from '../version.js';
|
|
16
16
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
17
17
|
import { fetchSinglePage, paginate, validatePaginationFlags, } from '../lib/pagination.js';
|
|
@@ -24,7 +24,7 @@ import { isProxyAgentActive } from '../lib/proxy.js';
|
|
|
24
24
|
import { assertNotLocal } from '../lib/target-url.js';
|
|
25
25
|
import { assertTargetUrlReachable } from '../lib/target-url-preflight.js';
|
|
26
26
|
import { assertLocalPortListening, buildLocalTargetUrl, DEFAULT_LOCAL_HOST, LOOPBACK_HOSTS, normalizeLocalHost, parseLocalPort, } from '../lib/local-target.js';
|
|
27
|
-
import { openTunnelSession, TunnelLostError, } from '../lib/tunnel-session.js';
|
|
27
|
+
import { openTunnelSession, TUNNEL_DATA_PLANE_PROXY_BYPASS_DESCRIPTION, TunnelLostError, } from '../lib/tunnel-session.js';
|
|
28
28
|
import { TunnelClient } from '../vendor/tunnel-client/index.js';
|
|
29
29
|
import { formatTextTableRow, measureTextColumns, renderTextTable, resolveTextColumns, } from '../lib/text-table.js';
|
|
30
30
|
import { createLiveRunProgress, formatRunProgressLine } from '../lib/run-progress.js';
|
|
@@ -96,7 +96,9 @@ function stillRunningAndBillingSubject(runIds) {
|
|
|
96
96
|
const TUNNEL_INTERRUPT_OPT_OUT_CONSEQUENCE = 'Passing --no-cancel-on-interrupt keeps the run executing without its tunnel; it cannot ' +
|
|
97
97
|
'reach your app and is still billed.';
|
|
98
98
|
function tunnelRerunCommand(detach) {
|
|
99
|
-
return `testsprite test run ${detach.testId} --local ${detach.localPort}
|
|
99
|
+
return (`testsprite test run ${detach.testId} --local ${detach.localPort}` +
|
|
100
|
+
(detach.localHost !== DEFAULT_LOCAL_HOST ? ` --local-host ${detach.localHost}` : '') +
|
|
101
|
+
(detach.reason === 'timeout' ? ' --timeout 1800' : ''));
|
|
100
102
|
}
|
|
101
103
|
/** Minimum wall-clock gap between adopted-client liveness reads. */
|
|
102
104
|
const BORROWED_TUNNEL_LIVENESS_INTERVAL_MS = 15_000;
|
|
@@ -185,6 +187,20 @@ async function cancelDoomedTunnelRun(args) {
|
|
|
185
187
|
*/
|
|
186
188
|
export function tunnelDetachMessage(detach, interrupt) {
|
|
187
189
|
const { runId, reason, cancel } = detach;
|
|
190
|
+
if (detach.ownerGone === true) {
|
|
191
|
+
const cause = `The borrowed tunnel for run ${runId} is no longer registered.`;
|
|
192
|
+
const outcome = {
|
|
193
|
+
cancelled: `Run ${runId} was cancelled. A run cancelled before it finished is not charged ` +
|
|
194
|
+
'(the server refunds it).',
|
|
195
|
+
'already-terminal': `Run ${runId} had already finished, so there was nothing to cancel.`,
|
|
196
|
+
failed: `Run ${runId} could NOT be cancelled from here — stop it with: ` +
|
|
197
|
+
`testsprite test cancel ${runId}.`,
|
|
198
|
+
skipped: `Run ${runId} cancellation was skipped because --no-cancel-on-interrupt was passed. ` +
|
|
199
|
+
'It may still be executing and billed.',
|
|
200
|
+
};
|
|
201
|
+
return (`${cause} ${outcome[cancel]}\n` +
|
|
202
|
+
` Check the run before re-running: testsprite test wait ${runId}.`);
|
|
203
|
+
}
|
|
188
204
|
if (reason === 'interrupt' && cancel === 'cancelled') {
|
|
189
205
|
return (`Interrupted${interrupt ? ` by ${interrupt.signal}` : ''}. Run ${runId} was reaching your ` +
|
|
190
206
|
`machine through a tunnel that closes with this process, so it was cancelled (exit ` +
|
|
@@ -232,6 +248,9 @@ function detachHintLines(runId, detach) {
|
|
|
232
248
|
`hint Cancel with: testsprite test cancel ${runId}`,
|
|
233
249
|
];
|
|
234
250
|
}
|
|
251
|
+
if (detach.ownerGone === true) {
|
|
252
|
+
return [`hint Check before re-running: testsprite test wait ${runId}`];
|
|
253
|
+
}
|
|
235
254
|
return detach.cancel === 'cancelled' || detach.cancel === 'already-terminal'
|
|
236
255
|
? ['hint The tunnel closed with this process, so the run was stopped.']
|
|
237
256
|
: [`hint Stop the run with: testsprite test cancel ${runId}`];
|
|
@@ -1663,8 +1682,14 @@ export const DEFERRED_RETRY_DEFAULT_SLEEP_MS = 61_000;
|
|
|
1663
1682
|
* a secondary guard. If both fields are absent we treat the error as permanent
|
|
1664
1683
|
* to avoid silently burning the entire retry budget on a non-recoverable state.
|
|
1665
1684
|
*
|
|
1685
|
+
* A 429 whose `details.reason` names a standing condition (see
|
|
1686
|
+
* `STANDING_RATE_LIMIT_REASONS` in `lib/http.ts` — e.g. the live
|
|
1687
|
+
* tunnel-binding cap) is also permanent, even though it now carries a real
|
|
1688
|
+
* `Retry-After`: that header says when a retry COULD first succeed if the
|
|
1689
|
+
* caller frees the resource, not that the condition clears on its own.
|
|
1690
|
+
*
|
|
1666
1691
|
* Limitation: a hypothetical future backend that emits `RATE_LIMITED` for a
|
|
1667
|
-
*
|
|
1692
|
+
* new reason without a `Retry-After` header AND without the per-minute
|
|
1668
1693
|
* wording would be classified as permanent here. Document this if it occurs.
|
|
1669
1694
|
*/
|
|
1670
1695
|
export function isTransientRateLimit(err) {
|
|
@@ -1673,6 +1698,9 @@ export function isTransientRateLimit(err) {
|
|
|
1673
1698
|
// so a credits-429 with a stray Retry-After header is never retried.
|
|
1674
1699
|
if (/insufficient credits/i.test(err.message))
|
|
1675
1700
|
return false;
|
|
1701
|
+
// Standing-condition 429s are permanent regardless of Retry-After too.
|
|
1702
|
+
if (isStandingRateLimit(err))
|
|
1703
|
+
return false;
|
|
1676
1704
|
// Primary transient signal: Retry-After header was present and parsed (set on
|
|
1677
1705
|
// the error by HttpClient when retryOnRateLimit: false is used and the HTTP
|
|
1678
1706
|
// layer throws after a single 429).
|
|
@@ -2715,6 +2743,7 @@ testIdToDashboardState) {
|
|
|
2715
2743
|
if (err instanceof InterruptError)
|
|
2716
2744
|
throw err;
|
|
2717
2745
|
if (err instanceof TimeoutError) {
|
|
2746
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
2718
2747
|
if (opts.output !== 'json') {
|
|
2719
2748
|
stderrFn(`[batch-run] ${testId} (runId: ${triggerResponse.runId}) — timed out after ${timeoutSeconds}s`);
|
|
2720
2749
|
}
|
|
@@ -3936,8 +3965,8 @@ export async function runSteps(opts, deps = {}) {
|
|
|
3936
3965
|
out.print(page, data => renderStepsText(data));
|
|
3937
3966
|
return page;
|
|
3938
3967
|
}
|
|
3939
|
-
// Bare `test steps <id>`
|
|
3940
|
-
//
|
|
3968
|
+
// Bare `test steps <id>` reads the latest run on V3. Older backends may
|
|
3969
|
+
// return a cumulative log; pagination and the page shape stay unchanged.
|
|
3941
3970
|
const paginationFlags = validatePaginationFlags({
|
|
3942
3971
|
pageSize: opts.pageSize,
|
|
3943
3972
|
startingToken: opts.startingToken,
|
|
@@ -3952,6 +3981,25 @@ export async function runSteps(opts, deps = {}) {
|
|
|
3952
3981
|
else {
|
|
3953
3982
|
page = await paginate(async ({ pageSize, cursor }) => client.get(path, { query: { pageSize, cursor } }), paginationFlags);
|
|
3954
3983
|
}
|
|
3984
|
+
if (page.items.length === 0 && opts.startingToken === undefined && !opts.dryRun) {
|
|
3985
|
+
// One history page and a short total deadline keep this advisory best-effort.
|
|
3986
|
+
const deadline = new AbortController();
|
|
3987
|
+
const timer = setTimeout(() => deadline.abort(), 5_000);
|
|
3988
|
+
try {
|
|
3989
|
+
const historyClient = makeClient(opts, deps, AbortSignal.any([shutdownOf(deps).signal, deadline.signal]));
|
|
3990
|
+
const history = await historyClient.listTestRuns(opts.testId, { pageSize: 20 }, { retry: false });
|
|
3991
|
+
const earlier = history.runs.slice(1).find(run => isTerminalStatus(run.status));
|
|
3992
|
+
stderrFn(earlier
|
|
3993
|
+
? `Latest run has no steps; inspect an earlier run: testsprite test steps ${opts.testId} --run-id ${earlier.runId}`
|
|
3994
|
+
: `Latest run has no steps; inspect run history: testsprite test result ${opts.testId} --history`);
|
|
3995
|
+
}
|
|
3996
|
+
catch {
|
|
3997
|
+
// Missing history must not change the steps page or the command's exit code.
|
|
3998
|
+
}
|
|
3999
|
+
finally {
|
|
4000
|
+
clearTimeout(timer);
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
3955
4003
|
// Bare cumulative path: when the returned items span multiple runIds,
|
|
3956
4004
|
// print a stderr advisory pointing at --run-id so the next invocation
|
|
3957
4005
|
// can scope. Stdout is unchanged (still the full §6.4 wire shape), so
|
|
@@ -4311,6 +4359,7 @@ export async function runFailureGet(opts, deps = {}) {
|
|
|
4311
4359
|
* Default timeout in seconds for `--wait`. Range 1..3600.
|
|
4312
4360
|
*/
|
|
4313
4361
|
const DEFAULT_RUN_TIMEOUT_SECONDS = 600;
|
|
4362
|
+
const DEFAULT_LOCAL_RUN_TIMEOUT_SECONDS = 1200;
|
|
4314
4363
|
const MAX_RUN_TIMEOUT_SECONDS = 3600;
|
|
4315
4364
|
/**
|
|
4316
4365
|
* Map a terminal `RunResponse.status` to the CLI exit code.
|
|
@@ -4833,7 +4882,7 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
4833
4882
|
await assertLocalPortListening(localHost, opts.localPort, { skipPreflight: opts.skipPreflight }, stderrFn);
|
|
4834
4883
|
if (isProxyAgentActive()) {
|
|
4835
4884
|
stderrFn('[advisory] An HTTP proxy is configured for this process. The tunnel control channel ' +
|
|
4836
|
-
|
|
4885
|
+
`honours it, but ${TUNNEL_DATA_PLANE_PROXY_BYPASS_DESCRIPTION} — if the ` +
|
|
4837
4886
|
'run cannot reach your machine, an egress proxy is the first thing to rule out.');
|
|
4838
4887
|
}
|
|
4839
4888
|
}
|
|
@@ -5007,6 +5056,10 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
5007
5056
|
throw err;
|
|
5008
5057
|
}
|
|
5009
5058
|
}
|
|
5059
|
+
stderrFn(`Run ${triggerResponse.runId}`);
|
|
5060
|
+
const receiptUrl = triggerResponse.dashboardUrl ?? triggerResponse.executionUrl;
|
|
5061
|
+
if (receiptUrl)
|
|
5062
|
+
stderrFn(`Dashboard: ${receiptUrl}`);
|
|
5010
5063
|
// Response-driven, not assumption-driven: the backend is the ground
|
|
5011
5064
|
// truth for whether --target-url was actually applied — V3
|
|
5012
5065
|
// deliberately returns `targetUrl: ''` rather than echoing an override it
|
|
@@ -5094,8 +5147,9 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
5094
5147
|
// source through the shared poll loop for every ordinary run.
|
|
5095
5148
|
if (!isTerminalStatus(run.status)) {
|
|
5096
5149
|
const fatal = tunnelSession?.fatalReason();
|
|
5097
|
-
if (fatal !== undefined)
|
|
5098
|
-
throw new TunnelLostError(fatal, triggerResponse.runId);
|
|
5150
|
+
if (fatal !== undefined) {
|
|
5151
|
+
throw new TunnelLostError(fatal, triggerResponse.runId, tunnelSession?.fatalMessage());
|
|
5152
|
+
}
|
|
5099
5153
|
}
|
|
5100
5154
|
live.onTick(run, elapsedMs);
|
|
5101
5155
|
},
|
|
@@ -5106,13 +5160,14 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
5106
5160
|
// Stop redrawing BEFORE any final line below is written, so a stale
|
|
5107
5161
|
// "running · Ns" can never land after "timed out" / "interrupted".
|
|
5108
5162
|
live.stop();
|
|
5109
|
-
//
|
|
5110
|
-
//
|
|
5111
|
-
//
|
|
5112
|
-
//
|
|
5113
|
-
const settleTunnelDetach = async (reason) => {
|
|
5114
|
-
if (tunnelSession === undefined || tunnelSession.adopted)
|
|
5163
|
+
// An owned tunnel closes on every non-terminal exit, so its run is doomed.
|
|
5164
|
+
// An adopted tunnel survives this process and normally detaches; only an
|
|
5165
|
+
// owner-gone observation proves that the borrowed run has lost its route.
|
|
5166
|
+
// `cancelOnInterrupt` defaults on for both doomed cases.
|
|
5167
|
+
const settleTunnelDetach = async (reason, ownerGone = false) => {
|
|
5168
|
+
if (tunnelSession === undefined || (tunnelSession.adopted && !ownerGone))
|
|
5115
5169
|
return undefined;
|
|
5170
|
+
const borrowedOwnerGone = tunnelSession.adopted && ownerGone;
|
|
5116
5171
|
const cancel = await cancelDoomedTunnelRun({
|
|
5117
5172
|
runId: triggerResponse.runId,
|
|
5118
5173
|
enabled: opts.cancelOnInterrupt !== false,
|
|
@@ -5123,14 +5178,16 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
5123
5178
|
runId: triggerResponse.runId,
|
|
5124
5179
|
testId: opts.testId,
|
|
5125
5180
|
localPort: opts.localPort,
|
|
5181
|
+
localHost,
|
|
5126
5182
|
reason,
|
|
5183
|
+
...(borrowedOwnerGone ? { ownerGone: true } : {}),
|
|
5127
5184
|
cancel: cancel.outcome,
|
|
5128
5185
|
...(cancel.terminalStatus !== undefined ? { terminalStatus: cancel.terminalStatus } : {}),
|
|
5129
5186
|
};
|
|
5130
5187
|
};
|
|
5131
5188
|
if (err instanceof TunnelLostError) {
|
|
5132
5189
|
ticker.finalize(`Run ${triggerResponse.runId} — tunnel disconnected`);
|
|
5133
|
-
const detach = await settleTunnelDetach('tunnel-lost');
|
|
5190
|
+
const detach = await settleTunnelDetach('tunnel-lost', err.getDetail('reason') === 'owner-gone');
|
|
5134
5191
|
const partial = {
|
|
5135
5192
|
runId: triggerResponse.runId,
|
|
5136
5193
|
status: detachPartialStatus(detach),
|
|
@@ -5159,6 +5216,16 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
5159
5216
|
// JSON consumers and AI agents can grab the runId and chain into
|
|
5160
5217
|
// `testsprite test wait <runId>` without parsing the stderr error envelope.
|
|
5161
5218
|
const detach = await settleTunnelDetach('timeout');
|
|
5219
|
+
deps.onWaitTimeout?.({
|
|
5220
|
+
reason: 'wait_timeout',
|
|
5221
|
+
...(tunnelSession
|
|
5222
|
+
? {
|
|
5223
|
+
cancelOutcome: detach?.cancel === 'already-terminal'
|
|
5224
|
+
? 'already_terminal'
|
|
5225
|
+
: (detach?.cancel ?? 'skipped'),
|
|
5226
|
+
}
|
|
5227
|
+
: {}),
|
|
5228
|
+
});
|
|
5162
5229
|
const timeoutPartial = {
|
|
5163
5230
|
runId: triggerResponse.runId,
|
|
5164
5231
|
status: detachPartialStatus(detach),
|
|
@@ -5188,7 +5255,7 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
5188
5255
|
: `Timed out after ${opts.timeoutSeconds}s waiting for run ${triggerResponse.runId}. ` +
|
|
5189
5256
|
stillRunningAndBillingSubject(triggerResponse.runId),
|
|
5190
5257
|
nextAction: detach
|
|
5191
|
-
? `Start
|
|
5258
|
+
? `Start a new run with: ${tunnelRerunCommand(detach)} (or raise --timeout up to 3600); a retry mints a fresh tunnel.`
|
|
5192
5259
|
: `Resume polling: testsprite test wait ${triggerResponse.runId}, or cancel it: testsprite test cancel ${triggerResponse.runId}`,
|
|
5193
5260
|
requestId: 'local',
|
|
5194
5261
|
details: { runId: triggerResponse.runId, timeoutSeconds: opts.timeoutSeconds },
|
|
@@ -5444,8 +5511,10 @@ export async function runTestWaitMany(opts, deps = {}) {
|
|
|
5444
5511
|
// would extend the invocation by ~1s per queued run past --timeout).
|
|
5445
5512
|
// Re-evaluated on every iteration so a retry obeys the same rule.
|
|
5446
5513
|
const remainingSeconds = Math.ceil((deadlineMs - Date.now()) / 1000);
|
|
5447
|
-
if (remainingSeconds <= 0)
|
|
5514
|
+
if (remainingSeconds <= 0) {
|
|
5515
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
5448
5516
|
return { kind: 'timeout' };
|
|
5517
|
+
}
|
|
5449
5518
|
try {
|
|
5450
5519
|
const run = await pollRunUntilTerminal(client, runId, {
|
|
5451
5520
|
timeoutSeconds: remainingSeconds,
|
|
@@ -5461,8 +5530,10 @@ export async function runTestWaitMany(opts, deps = {}) {
|
|
|
5461
5530
|
return { kind: 'result', run };
|
|
5462
5531
|
}
|
|
5463
5532
|
catch (err) {
|
|
5464
|
-
if (err instanceof TimeoutError)
|
|
5533
|
+
if (err instanceof TimeoutError) {
|
|
5534
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
5465
5535
|
return { kind: 'timeout' };
|
|
5536
|
+
}
|
|
5466
5537
|
if (err instanceof RequestTimeoutError)
|
|
5467
5538
|
throw err;
|
|
5468
5539
|
// Interrupt must reject the fan-out (handled at the collect point), not
|
|
@@ -5487,8 +5558,10 @@ export async function runTestWaitMany(opts, deps = {}) {
|
|
|
5487
5558
|
// makes ("Timed out … during rate-limit backoff"). Reporting the 429
|
|
5488
5559
|
// instead would let the exit-11 escalation below claim "nothing else
|
|
5489
5560
|
// went wrong" for an invocation that in fact exhausted `--timeout`.
|
|
5490
|
-
if (clampedRetryMs <= 0)
|
|
5561
|
+
if (clampedRetryMs <= 0) {
|
|
5562
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
5491
5563
|
return { kind: 'timeout' };
|
|
5564
|
+
}
|
|
5492
5565
|
stderrFn(`[wait] ${runId} — rate limited (attempt ${rateLimitAttempt}/${WAIT_POLL_RATE_MAX_OUTER_RETRIES}): retrying in ${Math.ceil(clampedRetryMs / 1000)}s`);
|
|
5493
5566
|
// Arm the graceful-detach scope across the backoff. `pollRunUntilTerminal`
|
|
5494
5567
|
// disarms in its own `finally`, so without this the sleep is a window
|
|
@@ -5676,7 +5749,7 @@ export async function runTestCancel(opts, deps = {}) {
|
|
|
5676
5749
|
const result = await client.cancelRun(runId);
|
|
5677
5750
|
out.print(result, data => {
|
|
5678
5751
|
const r = data;
|
|
5679
|
-
return
|
|
5752
|
+
return renderCancelResponseText(r);
|
|
5680
5753
|
});
|
|
5681
5754
|
if (result.alreadyCancelled) {
|
|
5682
5755
|
stderrFn(`[advisory] run ${runId} was already cancelled`);
|
|
@@ -5757,15 +5830,40 @@ function renderCancelSummaryText(summary) {
|
|
|
5757
5830
|
lines.push(`${e.runId} error (${e.message})`);
|
|
5758
5831
|
return lines.join('\n');
|
|
5759
5832
|
}
|
|
5833
|
+
function renderCancelResponseText(response) {
|
|
5834
|
+
const runCard = renderRunResponseText(response);
|
|
5835
|
+
if (!response.refund)
|
|
5836
|
+
return runCard;
|
|
5837
|
+
let refundLine;
|
|
5838
|
+
switch (response.refund.status) {
|
|
5839
|
+
case 'refunded':
|
|
5840
|
+
refundLine =
|
|
5841
|
+
response.refund.amount === undefined
|
|
5842
|
+
? 'refund credits returned'
|
|
5843
|
+
: `refund credits returned: ${response.refund.amount}`;
|
|
5844
|
+
break;
|
|
5845
|
+
case 'not_charged':
|
|
5846
|
+
refundLine = 'refund run was never charged; nothing to return';
|
|
5847
|
+
break;
|
|
5848
|
+
case 'failed':
|
|
5849
|
+
refundLine =
|
|
5850
|
+
'refund failed — cancellation succeeded, but credits were not returned; contact TestSprite support';
|
|
5851
|
+
break;
|
|
5852
|
+
default:
|
|
5853
|
+
refundLine = `refund ${String(response.refund.status)}`;
|
|
5854
|
+
}
|
|
5855
|
+
return `${runCard}\n${refundLine}`;
|
|
5856
|
+
}
|
|
5760
5857
|
export function createTestCancelCommand(deps) {
|
|
5761
5858
|
const cancel = new Command('cancel');
|
|
5762
5859
|
cancel
|
|
5763
5860
|
.argument('<run-id...>', 'one or more run ids to cancel')
|
|
5764
5861
|
.description('Cancel one or more queued/running runs.\n' +
|
|
5765
5862
|
'\nCtrl-C during --wait only detaches — it does NOT cancel the server-side\n' +
|
|
5766
|
-
'run. This is the real stop button.
|
|
5767
|
-
'
|
|
5768
|
-
'
|
|
5863
|
+
'run. This is the real stop button. A frontend V3 run cancelled before a\n' +
|
|
5864
|
+
'terminal state has its original charge returned; an uncharged run says so.\n' +
|
|
5865
|
+
'Backend and V2 runs keep their existing billing behavior; an in-flight Lambda\n' +
|
|
5866
|
+
'finishes on its own and its result is discarded once cancelled.\n' +
|
|
5769
5867
|
'\nExit codes:\n' +
|
|
5770
5868
|
' 0 cancelled (fresh or already-cancelled — naturally idempotent)\n' +
|
|
5771
5869
|
' 4 run id not found (single id), or ANY id not found (multi-id — outranks conflict)\n' +
|
|
@@ -5842,6 +5940,7 @@ export async function runTestWait(opts, deps = {}) {
|
|
|
5842
5940
|
// "running · Ns" can never land after "timed out" / "interrupted".
|
|
5843
5941
|
live.stop();
|
|
5844
5942
|
if (err instanceof TimeoutError) {
|
|
5943
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
5845
5944
|
ticker.finalize(`Run ${opts.runId} — timed out after ${opts.timeoutSeconds}s`);
|
|
5846
5945
|
// Mirror the RequestTimeoutError path: emit a partial run to stdout so
|
|
5847
5946
|
// JSON consumers and AI agents can grab the runId and chain into
|
|
@@ -6523,7 +6622,9 @@ export async function runTestRunAll(opts, deps = {}) {
|
|
|
6523
6622
|
: {}),
|
|
6524
6623
|
};
|
|
6525
6624
|
}
|
|
6526
|
-
catch {
|
|
6625
|
+
catch (err) {
|
|
6626
|
+
if (err instanceof TimeoutError)
|
|
6627
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
6527
6628
|
// fall through to the timeout result below
|
|
6528
6629
|
}
|
|
6529
6630
|
return {
|
|
@@ -6571,6 +6672,7 @@ export async function runTestRunAll(opts, deps = {}) {
|
|
|
6571
6672
|
}
|
|
6572
6673
|
catch (err) {
|
|
6573
6674
|
if (err instanceof TimeoutError) {
|
|
6675
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
6574
6676
|
return {
|
|
6575
6677
|
testId: entry.testId,
|
|
6576
6678
|
runId,
|
|
@@ -7036,8 +7138,10 @@ export async function runTestRerun(opts, deps = {}) {
|
|
|
7036
7138
|
return { kind: 'terminal', run: finalRun };
|
|
7037
7139
|
}
|
|
7038
7140
|
catch (err) {
|
|
7039
|
-
if (err instanceof TimeoutError)
|
|
7141
|
+
if (err instanceof TimeoutError) {
|
|
7142
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
7040
7143
|
return { kind: 'timeout' };
|
|
7144
|
+
}
|
|
7041
7145
|
// Preserve the two intentional whole-fan-out aborts: each has a
|
|
7042
7146
|
// dedicated outer-catch branch (RequestTimeoutError → all-running
|
|
7043
7147
|
// partial + re-attach hints + exit 7; InterruptError → DEV-331
|
|
@@ -7309,6 +7413,7 @@ export async function runTestRerun(opts, deps = {}) {
|
|
|
7309
7413
|
}
|
|
7310
7414
|
catch (err) {
|
|
7311
7415
|
if (err instanceof TimeoutError) {
|
|
7416
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
7312
7417
|
ticker.finalize(`Run ${rerunResp.runId} — timed out after ${opts.timeoutSeconds}s`);
|
|
7313
7418
|
// Mirror the RequestTimeoutError path: emit a partial run to stdout so
|
|
7314
7419
|
// JSON consumers and AI agents can grab the runId and chain into
|
|
@@ -7838,6 +7943,7 @@ export async function runTestRerun(opts, deps = {}) {
|
|
|
7838
7943
|
}
|
|
7839
7944
|
catch (err) {
|
|
7840
7945
|
if (err instanceof TimeoutError) {
|
|
7946
|
+
deps.onWaitTimeout?.({ reason: 'wait_timeout' });
|
|
7841
7947
|
return {
|
|
7842
7948
|
testId: entry.testId,
|
|
7843
7949
|
runId: entry.runId,
|
|
@@ -8446,11 +8552,11 @@ export function createTestCommand(deps = {}) {
|
|
|
8446
8552
|
});
|
|
8447
8553
|
test
|
|
8448
8554
|
.command('steps <test-id>')
|
|
8449
|
-
.description('List the steps
|
|
8555
|
+
.description('List the steps of the latest run (use --run-id for a specific run)')
|
|
8450
8556
|
.option('--page-size <n>', 'service page size hint (1-100, default 25)')
|
|
8451
8557
|
.option('--max-items <n>', 'stop after this many items across auto-paged pages')
|
|
8452
8558
|
.option('--starting-token <token>', 'opaque cursor from a previous response')
|
|
8453
|
-
.option('--run-id <id>',
|
|
8559
|
+
.option('--run-id <id>', 'Show steps of the specified run instead of the latest run.')
|
|
8454
8560
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
8455
8561
|
.action(async (testId, cmdOpts, command) => {
|
|
8456
8562
|
await runSteps({
|
|
@@ -8645,11 +8751,11 @@ export function createTestCommand(deps = {}) {
|
|
|
8645
8751
|
.option('--tunnel-client <id>', 'with --local, attach to a tunnel already running under `testsprite tunnel start` instead ' +
|
|
8646
8752
|
'of opening a new one. The id is the non-secret handle that command prints; the tunnel ' +
|
|
8647
8753
|
'stays owned by that process and is not closed when this run finishes.')
|
|
8648
|
-
.option('--no-cancel-on-interrupt', 'with --local,
|
|
8649
|
-
'
|
|
8650
|
-
'
|
|
8754
|
+
.option('--no-cancel-on-interrupt', 'with --local, skip automatic cancellation when an owned tunnel is about to close or a ' +
|
|
8755
|
+
"borrowed tunnel's owner disappears. An ordinary interrupt of a borrowed run never " +
|
|
8756
|
+
'cancels it because its tunnel remains alive.')
|
|
8651
8757
|
.option('--wait', 'poll until terminal status or --timeout elapses', false)
|
|
8652
|
-
.option('--timeout <s>',
|
|
8758
|
+
.option('--timeout <s>', 'with --wait, max seconds to wait (1–3600; default 600, or 1200 with --local)')
|
|
8653
8759
|
.option('--idempotency-key <key>', 'opaque key for safe retries (1–256 chars). Printed to stderr at --debug if auto-generated.')
|
|
8654
8760
|
.option('--all', 'run all tests in the project (wave-ordered fresh run; uses --project or TESTSPRITE_PROJECT_ID). Mutually exclusive with <test-id>.', false)
|
|
8655
8761
|
.option('--project <id>', 'project id (with --all, overrides TESTSPRITE_PROJECT_ID; returned by `testsprite project list`)')
|
|
@@ -8801,7 +8907,9 @@ export function createTestCommand(deps = {}) {
|
|
|
8801
8907
|
...(cmdOpts.tunnelClient !== undefined ? { tunnelClientId: cmdOpts.tunnelClient } : {}),
|
|
8802
8908
|
cancelOnInterrupt: cmdOpts.cancelOnInterrupt !== false,
|
|
8803
8909
|
wait: effectiveWait,
|
|
8804
|
-
timeoutSeconds:
|
|
8910
|
+
timeoutSeconds: usingLocal && cmdOpts.timeout === undefined
|
|
8911
|
+
? DEFAULT_LOCAL_RUN_TIMEOUT_SECONDS
|
|
8912
|
+
: parseTimeoutFlag(cmdOpts.timeout, 'timeout'),
|
|
8805
8913
|
// B2(c): tell runTestRun whether --timeout was explicitly provided.
|
|
8806
8914
|
timeoutIsDefault: cmdOpts.timeout === undefined,
|
|
8807
8915
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
@@ -65,8 +65,8 @@ export declare function runTunnelStatus(opts: TunnelClientIdOptions, deps?: Tunn
|
|
|
65
65
|
* already-deleted binding is a success, because the requested end state holds.
|
|
66
66
|
*
|
|
67
67
|
* Worth knowing: this removes the ability to ATTACH a run to that client, and
|
|
68
|
-
* removes the client from the tunnel server.
|
|
69
|
-
*
|
|
68
|
+
* removes the client from the tunnel server. A running `tunnel start`
|
|
69
|
+
* observes the revocation on its next status check and exits.
|
|
70
70
|
*/
|
|
71
71
|
export declare function runTunnelStop(opts: TunnelClientIdOptions, deps?: TunnelDeps): Promise<void>;
|
|
72
72
|
export declare function createTunnelCommand(deps?: TunnelDeps): Command;
|