@testsprite/testsprite-cli 0.5.0 → 0.6.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 +1 -0
- package/dist/commands/test.d.ts +41 -1
- package/dist/commands/test.js +396 -69
- package/dist/lib/gh-output.d.ts +25 -3
- package/dist/lib/gh-output.js +109 -6
- package/dist/lib/http.js +73 -1
- package/dist/lib/poll.js +72 -36
- package/dist/lib/response-schemas.js +23 -13
- package/dist/lib/v3-advisory.d.ts +20 -0
- package/dist/lib/v3-advisory.js +23 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
package/dist/commands/test.js
CHANGED
|
@@ -22,7 +22,8 @@ import { formatTextTableRow, measureTextColumns, renderTextTable, resolveTextCol
|
|
|
22
22
|
import { createTicker } from '../lib/ticker.js';
|
|
23
23
|
import { RateThrottle } from '../lib/rate-throttle.js';
|
|
24
24
|
import { resolvePortalBase, resolvePortalUrl } from '../lib/facade.js';
|
|
25
|
-
import {
|
|
25
|
+
import { emitTargetUrlV3Advisory } from '../lib/v3-advisory.js';
|
|
26
|
+
import { emitGithubOutputs, summarizeAcceptedPayload, summarizeSingleRun, } from '../lib/gh-output.js';
|
|
26
27
|
import { loadConfig } from '../lib/config.js';
|
|
27
28
|
import { flakyExitCode, renderFlakyText, summarizeFlaky, } from '../lib/flaky.js';
|
|
28
29
|
/** The effective shutdown handle for a command invocation (DEV-331). */
|
|
@@ -198,13 +199,24 @@ async function emitDupNameAdvisoryIfNeeded(client, projectId, name, stderrFn) {
|
|
|
198
199
|
// Use an AbortController with a 5 s deadline. When the timer fires it
|
|
199
200
|
// calls ac.abort(), which causes client.get (via the `signal` option) to
|
|
200
201
|
// throw an AbortError — caught below and swallowed. This ensures a stalled
|
|
201
|
-
//
|
|
202
|
-
//
|
|
202
|
+
// listing endpoint can't delay an otherwise-healthy create by the full
|
|
203
|
+
// request-timeout (120 s).
|
|
203
204
|
// No secondary setTimeout is used to avoid leaking timers in tests.
|
|
205
|
+
//
|
|
206
|
+
// The deadline alone is NOT sufficient, because `signal` is composed into
|
|
207
|
+
// the fetch only — `sleepBeforeRetry` observes the process-lifetime
|
|
208
|
+
// shutdown signal and nothing else, so a retry sleep runs to completion
|
|
209
|
+
// no matter what this controller does. A 429 carrying `Retry-After` is
|
|
210
|
+
// honoured up to 60 s per attempt across 3 attempts, which would park the
|
|
211
|
+
// create behind a best-effort advisory for up to ~2 minutes. `429` is a
|
|
212
|
+
// live response for CLI callers (the in-flight run cap returns it), so
|
|
213
|
+
// this is reachable, not theoretical. `retryOnRateLimit: false` makes the
|
|
214
|
+
// 429 throw straight into the catch below, which is the correct outcome
|
|
215
|
+
// for a lookup whose entire purpose is to be skippable.
|
|
204
216
|
const ac = new AbortController();
|
|
205
217
|
const timer = setTimeout(() => ac.abort(), DUP_NAME_ADVISORY_TIMEOUT_MS);
|
|
206
218
|
try {
|
|
207
|
-
const listing = await client.get(`/tests?projectId=${encodeURIComponent(projectId)}&pageSize=100`, { signal: ac.signal });
|
|
219
|
+
const listing = await client.get(`/tests?projectId=${encodeURIComponent(projectId)}&pageSize=100`, { signal: ac.signal, retryOnRateLimit: false });
|
|
208
220
|
const nameLower = name.toLowerCase();
|
|
209
221
|
const match = listing.items?.find(t => t.name.toLowerCase() === nameLower);
|
|
210
222
|
if (match) {
|
|
@@ -382,10 +394,32 @@ export async function runCreate(opts, deps = {}) {
|
|
|
382
394
|
// the merged { ...createContext, run } envelope in JSON mode and
|
|
383
395
|
// appears on the Dashboard: stderr line in text mode.
|
|
384
396
|
// R1: suppress under --dry-run (fake canned test id).
|
|
385
|
-
|
|
397
|
+
// DEV-737: prefer a server-provided dashboardUrl over the client guess
|
|
398
|
+
// (`withDashboardUrl`/`resolveDashboardUrl` above); when the server
|
|
399
|
+
// explicitly withheld one, never fall back to the client-computed
|
|
400
|
+
// V2-shaped link and tell the caller where to find the test instead.
|
|
401
|
+
const { entity: createContextWithUrl, suppressed: dashboardSuppressedOnRun } = withDashboardUrl(response, () => opts.dryRun
|
|
386
402
|
? undefined
|
|
387
|
-
: resolvePortalUrl(resolveApiUrl(opts, deps), projectId, response.testId);
|
|
388
|
-
const
|
|
403
|
+
: resolvePortalUrl(resolveApiUrl(opts, deps), projectId, response.testId));
|
|
404
|
+
const runDashboardStderrFn = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
405
|
+
if (dashboardSuppressedOnRun) {
|
|
406
|
+
emitDashboardLinkSuppressedAdvisory(response.testId, runDashboardStderrFn);
|
|
407
|
+
}
|
|
408
|
+
else if (opts.output !== 'json' && createContextWithUrl.dashboardUrl !== undefined) {
|
|
409
|
+
// Finding 3 (dogfood 2026-08-09): the merged create+run chain suppresses
|
|
410
|
+
// the create's own print (delegating to `runTestRun` -> `printRunOrChain`),
|
|
411
|
+
// whose text-mode header renders `createContext` via `renderCreateText` —
|
|
412
|
+
// which never prints `dashboardUrl` — and there is otherwise no stderr
|
|
413
|
+
// emission point for it on this chain (unlike the non-`--run` path below,
|
|
414
|
+
// which prints this same line explicitly). Without this, a text-mode
|
|
415
|
+
// `create --run` silently drops the authoritative link — worst on a
|
|
416
|
+
// no-wait V3 create, where the client cannot recompute it at all. Mirrors
|
|
417
|
+
// the non-run path's three-state handling exactly: a suppressed (`null`)
|
|
418
|
+
// server link takes the advisory branch above instead (no legacy guess);
|
|
419
|
+
// an absent key already resolved to the legacy client fallback (or
|
|
420
|
+
// `undefined` when unmapped) via `createContextWithUrl` above.
|
|
421
|
+
runDashboardStderrFn(`Dashboard: ${createContextWithUrl.dashboardUrl}`);
|
|
422
|
+
}
|
|
389
423
|
await runTestRun({
|
|
390
424
|
...opts,
|
|
391
425
|
testId: response.testId,
|
|
@@ -407,11 +441,16 @@ export async function runCreate(opts, deps = {}) {
|
|
|
407
441
|
// (no extra network call — both come from opts / response).
|
|
408
442
|
// R1: suppress under --dry-run — the test id is a fake canned value
|
|
409
443
|
// (e.g. "test_dryrun_create_2026") and a live-looking URL would mislead.
|
|
410
|
-
|
|
444
|
+
// DEV-737: prefer a server-provided dashboardUrl over the client guess;
|
|
445
|
+
// never fall back when the server explicitly withheld one (see
|
|
446
|
+
// `withDashboardUrl`/`resolveDashboardUrl` above), and tell the caller
|
|
447
|
+
// where to find the test instead of printing a link that would 404.
|
|
448
|
+
const { entity: responseWithDashboardUrl, suppressed: dashboardSuppressed } = withDashboardUrl(response, () => opts.dryRun
|
|
411
449
|
? undefined
|
|
412
|
-
: resolvePortalUrl(resolveApiUrl(opts, deps), projectId, response.testId);
|
|
450
|
+
: resolvePortalUrl(resolveApiUrl(opts, deps), projectId, response.testId));
|
|
451
|
+
const dashboardUrl = responseWithDashboardUrl.dashboardUrl ?? undefined;
|
|
413
452
|
if (opts.output === 'json') {
|
|
414
|
-
out.print(
|
|
453
|
+
out.print(responseWithDashboardUrl, data => renderCreateText(data));
|
|
415
454
|
}
|
|
416
455
|
else {
|
|
417
456
|
out.print(response, data => renderCreateText(data));
|
|
@@ -420,6 +459,9 @@ export async function runCreate(opts, deps = {}) {
|
|
|
420
459
|
stderrFn(`Dashboard: ${dashboardUrl}`);
|
|
421
460
|
}
|
|
422
461
|
}
|
|
462
|
+
if (dashboardSuppressed) {
|
|
463
|
+
emitDashboardLinkSuppressedAdvisory(response.testId, deps.stderr ?? (line => process.stderr.write(`${line}\n`)));
|
|
464
|
+
}
|
|
423
465
|
return response;
|
|
424
466
|
}
|
|
425
467
|
/**
|
|
@@ -1493,9 +1535,14 @@ export async function runCreateFromPlan(opts, deps = {}) {
|
|
|
1493
1535
|
// Fix 5 (plan-from coverage): the projectId for the deep-link comes from
|
|
1494
1536
|
// the validated PLAN body (not opts — `--plan-from` has no --project-id
|
|
1495
1537
|
// flag). Same dry-run suppression as runCreate (fake canned test id).
|
|
1496
|
-
|
|
1538
|
+
// DEV-737: prefer a server-provided dashboardUrl over the client guess
|
|
1539
|
+
// (`withDashboardUrl`/`resolveDashboardUrl`, defined near
|
|
1540
|
+
// `withRunDashboardUrl`); never fall back when the server explicitly
|
|
1541
|
+
// withheld one, and tell the caller where to find the test instead.
|
|
1542
|
+
const { entity: responseWithDashboardUrl, suppressed: planDashboardSuppressed } = withDashboardUrl(response, () => opts.dryRun
|
|
1497
1543
|
? undefined
|
|
1498
|
-
: resolvePortalUrl(resolveApiUrl(opts, deps), plan.projectId, response.testId);
|
|
1544
|
+
: resolvePortalUrl(resolveApiUrl(opts, deps), plan.projectId, response.testId));
|
|
1545
|
+
const planDashboardUrl = responseWithDashboardUrl.dashboardUrl ?? undefined;
|
|
1499
1546
|
// --run chain (M3.3 piece-3): trigger + optionally wait. Per codex
|
|
1500
1547
|
// round-1 P1: suppress the create's own print when chaining;
|
|
1501
1548
|
// `runTestRun` emits a single merged envelope on stdout.
|
|
@@ -1503,7 +1550,9 @@ export async function runCreateFromPlan(opts, deps = {}) {
|
|
|
1503
1550
|
// Idempotency key for the run is the create key + ":run" suffix so a
|
|
1504
1551
|
// retry of the whole chain gets the same runId. Per piece-3 spec.
|
|
1505
1552
|
const runIdempotencyKey = `${idempotencyKey}:run`;
|
|
1506
|
-
|
|
1553
|
+
if (planDashboardSuppressed) {
|
|
1554
|
+
emitDashboardLinkSuppressedAdvisory(response.testId, stderrFn);
|
|
1555
|
+
}
|
|
1507
1556
|
return runTestRun({
|
|
1508
1557
|
...opts,
|
|
1509
1558
|
testId: response.testId,
|
|
@@ -1513,11 +1562,11 @@ export async function runCreateFromPlan(opts, deps = {}) {
|
|
|
1513
1562
|
// first-run hint fires for `test create --plan-from --run --wait`.
|
|
1514
1563
|
timeoutIsDefault: opts.timeoutIsDefault ?? false,
|
|
1515
1564
|
wait: opts.wait === true,
|
|
1516
|
-
createContext:
|
|
1565
|
+
createContext: responseWithDashboardUrl,
|
|
1517
1566
|
}, deps).then(() => response);
|
|
1518
1567
|
}
|
|
1519
1568
|
if (opts.output === 'json') {
|
|
1520
|
-
out.print(
|
|
1569
|
+
out.print(responseWithDashboardUrl, data => renderCreateText(data));
|
|
1521
1570
|
}
|
|
1522
1571
|
else {
|
|
1523
1572
|
out.print(response, data => renderCreateText(data));
|
|
@@ -1525,6 +1574,9 @@ export async function runCreateFromPlan(opts, deps = {}) {
|
|
|
1525
1574
|
stderrFn(`Dashboard: ${planDashboardUrl}`);
|
|
1526
1575
|
}
|
|
1527
1576
|
}
|
|
1577
|
+
if (planDashboardSuppressed) {
|
|
1578
|
+
emitDashboardLinkSuppressedAdvisory(response.testId, stderrFn);
|
|
1579
|
+
}
|
|
1528
1580
|
return response;
|
|
1529
1581
|
}
|
|
1530
1582
|
/**
|
|
@@ -1904,24 +1956,65 @@ export async function runCreateBatch(opts, deps = {}) {
|
|
|
1904
1956
|
},
|
|
1905
1957
|
});
|
|
1906
1958
|
}
|
|
1907
|
-
// Fix 5: enrich results with per-item dashboardUrl
|
|
1959
|
+
// Fix 5: enrich results with per-item dashboardUrl.
|
|
1908
1960
|
// projectId comes from specs[specIndex].projectId; testId from the result row.
|
|
1909
1961
|
// Only emitted where both are known client-side — no extra network calls.
|
|
1910
1962
|
// R1: suppress under --dry-run — test ids are fake canned values and a
|
|
1911
1963
|
// live-looking URL would mislead the caller.
|
|
1964
|
+
// DEV-737: prefer a server-provided per-item dashboardUrl over the client
|
|
1965
|
+
// guess (`withDashboardUrl`/`resolveDashboardUrl`, defined near
|
|
1966
|
+
// `withRunDashboardUrl`); never fall back when the server explicitly
|
|
1967
|
+
// withheld one for a given item — that would print exactly the dead
|
|
1968
|
+
// V2-shaped link the server declined to emit.
|
|
1969
|
+
//
|
|
1970
|
+
// The per-item decision is captured into `testIdToDashboardState` — computed
|
|
1971
|
+
// ONCE here, regardless of `--output` mode — so the `--run` fan-out below
|
|
1972
|
+
// (`runBatchRun`) can reuse the SAME decision instead of recomputing a
|
|
1973
|
+
// client-side URL from testId→projectId, which would silently replace a
|
|
1974
|
+
// server-provided V3 link with the dead legacy V2 guess and lose
|
|
1975
|
+
// suppression state entirely. Computing it unconditionally (not gated on
|
|
1976
|
+
// `opts.output === 'json'`) also means the aggregate suppression advisory
|
|
1977
|
+
// below now correctly fires in text mode too — it previously only ever
|
|
1978
|
+
// fired in JSON mode because the per-item loop was skipped entirely in text
|
|
1979
|
+
// mode, silently under-warning a text-mode caller. That matches the
|
|
1980
|
+
// documented "advisory fires on stderr regardless of --output mode"
|
|
1981
|
+
// convention this repo already follows for the single-`test create` advisory.
|
|
1912
1982
|
const apiUrlForDashboard = resolveApiUrl(opts, deps);
|
|
1983
|
+
let anyDashboardSuppressed = false;
|
|
1984
|
+
const testIdToDashboardState = new Map();
|
|
1985
|
+
if (!opts.dryRun) {
|
|
1986
|
+
for (const r of response.results) {
|
|
1987
|
+
if (r.status !== 'created' || r.testId === undefined)
|
|
1988
|
+
continue;
|
|
1989
|
+
const testId = r.testId;
|
|
1990
|
+
const spec = specs[r.specIndex];
|
|
1991
|
+
const projectId = spec?.projectId;
|
|
1992
|
+
const { entity, suppressed } = withDashboardUrl(r, () => projectId ? resolvePortalUrl(apiUrlForDashboard, projectId, testId) : undefined);
|
|
1993
|
+
if (suppressed)
|
|
1994
|
+
anyDashboardSuppressed = true;
|
|
1995
|
+
testIdToDashboardState.set(testId, {
|
|
1996
|
+
dashboardUrl: entity.dashboardUrl ?? undefined,
|
|
1997
|
+
suppressed,
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
if (anyDashboardSuppressed) {
|
|
2002
|
+
const stderrFn = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
2003
|
+
stderrFn('[advisory] no dashboard link is available for one or more created tests right now; ' +
|
|
2004
|
+
'use `testsprite test get <test-id>` to look them up.');
|
|
2005
|
+
}
|
|
2006
|
+
// JSON-mode create output is enriched from the same map, so it stays
|
|
2007
|
+
// byte-identical to before this refactor.
|
|
1913
2008
|
const enrichedResponse = !opts.dryRun && opts.output === 'json'
|
|
1914
2009
|
? {
|
|
1915
2010
|
...response,
|
|
1916
2011
|
results: response.results.map(r => {
|
|
1917
2012
|
if (r.status !== 'created' || r.testId === undefined)
|
|
1918
2013
|
return r;
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1921
|
-
if (!projectId)
|
|
2014
|
+
const state = testIdToDashboardState.get(r.testId);
|
|
2015
|
+
if (!state)
|
|
1922
2016
|
return r;
|
|
1923
|
-
|
|
1924
|
-
return dashboardUrl !== undefined ? { ...r, dashboardUrl } : r;
|
|
2017
|
+
return { ...r, dashboardUrl: state.dashboardUrl };
|
|
1925
2018
|
}),
|
|
1926
2019
|
}
|
|
1927
2020
|
: response;
|
|
@@ -1936,17 +2029,7 @@ export async function runCreateBatch(opts, deps = {}) {
|
|
|
1936
2029
|
}
|
|
1937
2030
|
// --run: fan out a trigger for each created test, then emit results.
|
|
1938
2031
|
if (opts.run === true) {
|
|
1939
|
-
|
|
1940
|
-
// runBatchRun can enrich per-item run JSON with dashboardUrl.
|
|
1941
|
-
const runTestIdToProjectId = new Map();
|
|
1942
|
-
for (const r of response.results) {
|
|
1943
|
-
if (r.status === 'created' && r.testId !== undefined) {
|
|
1944
|
-
const projectId = specs[r.specIndex]?.projectId;
|
|
1945
|
-
if (projectId)
|
|
1946
|
-
runTestIdToProjectId.set(r.testId, projectId);
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
await runBatchRun(opts, response, client, out, deps, opts.dryRun ? undefined : runTestIdToProjectId, opts.dryRun ? undefined : apiUrlForDashboard);
|
|
2032
|
+
await runBatchRun(opts, response, client, out, deps, opts.dryRun ? undefined : testIdToDashboardState);
|
|
1950
2033
|
// runBatchRun handles its own exit-code logic via CLIError.
|
|
1951
2034
|
// Return the create response to satisfy the return type; callers that
|
|
1952
2035
|
// inspect the return value only do so when not using --run.
|
|
@@ -1975,12 +2058,17 @@ export async function runCreateBatch(opts, deps = {}) {
|
|
|
1975
2058
|
* that code only when ALL runs share the same code; otherwise 1.
|
|
1976
2059
|
*/
|
|
1977
2060
|
async function runBatchRun(opts, createResponse, client, out, deps,
|
|
1978
|
-
/**
|
|
1979
|
-
*
|
|
1980
|
-
*
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
2061
|
+
/**
|
|
2062
|
+
* R3b: per-testId dashboard-link decision, ALREADY resolved at create time
|
|
2063
|
+
* via `withDashboardUrl`/`resolveDashboardUrl` (the shared three-state
|
|
2064
|
+
* precedence helper — see its doc). Populated by the caller; absent
|
|
2065
|
+
* (undefined) means no enrichment (e.g. dry-run). Reusing this decision
|
|
2066
|
+
* — rather than recomputing a client-side URL from testId→projectId here
|
|
2067
|
+
* — is the fix: a fresh `resolvePortalUrl` call at this point would
|
|
2068
|
+
* silently replace a server-provided V3 link with the dead legacy V2
|
|
2069
|
+
* guess, and would have no way to know a link was explicitly suppressed.
|
|
2070
|
+
*/
|
|
2071
|
+
testIdToDashboardState) {
|
|
1984
2072
|
const stderrFn = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
1985
2073
|
const timeoutSeconds = opts.timeoutSeconds ?? DEFAULT_RUN_TIMEOUT_SECONDS;
|
|
1986
2074
|
const concurrencyLimit = opts.maxConcurrency ?? DEFAULT_BATCH_RUN_CONCURRENCY;
|
|
@@ -1992,6 +2080,20 @@ apiUrlForDashboard) {
|
|
|
1992
2080
|
// All specs failed at create time — already threw above; unreachable.
|
|
1993
2081
|
return;
|
|
1994
2082
|
}
|
|
2083
|
+
// Finding 2 (dogfood 2026-08-09): this fan-out calls `triggerRunWithMeta`
|
|
2084
|
+
// directly (below), bypassing `runTestRun` entirely — so `runTestRun`'s own
|
|
2085
|
+
// `--target-url` V3 advisory (`emitTargetUrlV3AdvisoryIfNeeded`) never fired
|
|
2086
|
+
// here, even though every triggered run in the batch ignores `--target-url`
|
|
2087
|
+
// exactly like a single V3-routed `test run` does. Reuses the same helper
|
|
2088
|
+
// and advisory text (no duplicated probe logic or copy) and fires exactly
|
|
2089
|
+
// ONCE for the whole batch, before the fan-out — not per item. Mirrors
|
|
2090
|
+
// `runTestRun`'s own gating (only pay the extra `/me` round trip when
|
|
2091
|
+
// `--target-url` was actually supplied) and its "fires under --dry-run too"
|
|
2092
|
+
// behavior (the dry-run client's canned `/me` sample demonstrates the same
|
|
2093
|
+
// advisory at zero real-network cost).
|
|
2094
|
+
if (opts.targetUrl !== undefined) {
|
|
2095
|
+
await emitTargetUrlV3AdvisoryIfNeeded(client, stderrFn);
|
|
2096
|
+
}
|
|
1995
2097
|
// Dry-run: print a descriptor envelope and return without real triggers.
|
|
1996
2098
|
if (opts.dryRun) {
|
|
1997
2099
|
const dryRunResults = testIds.map(testId => ({
|
|
@@ -2413,16 +2515,19 @@ apiUrlForDashboard) {
|
|
|
2413
2515
|
batchRunResults.sort((a, b) => testIds.indexOf(a.testId) - testIds.indexOf(b.testId));
|
|
2414
2516
|
// Emit output.
|
|
2415
2517
|
if (opts.output === 'json') {
|
|
2416
|
-
// R3b: enrich per-item run results with
|
|
2417
|
-
//
|
|
2418
|
-
//
|
|
2419
|
-
|
|
2518
|
+
// R3b: enrich per-item run results with the dashboard state ALREADY
|
|
2519
|
+
// resolved at create time (`testIdToDashboardState`, built by the
|
|
2520
|
+
// caller). Never recompute a client-side URL here — that would silently
|
|
2521
|
+
// replace a server-provided V3 link with the dead legacy V2 guess, and
|
|
2522
|
+
// would have no way to represent "the server explicitly suppressed
|
|
2523
|
+
// this". A suppressed item (dashboardUrl undefined, suppressed: true)
|
|
2524
|
+
// is left with no key at all, same as the create-time convention.
|
|
2525
|
+
const enrichedResults = !opts.dryRun && testIdToDashboardState !== undefined
|
|
2420
2526
|
? batchRunResults.map(r => {
|
|
2421
|
-
const
|
|
2422
|
-
if (!
|
|
2527
|
+
const state = testIdToDashboardState.get(r.testId);
|
|
2528
|
+
if (!state || state.dashboardUrl === undefined)
|
|
2423
2529
|
return r;
|
|
2424
|
-
|
|
2425
|
-
return dashboardUrl !== undefined ? { ...r, dashboardUrl } : r;
|
|
2530
|
+
return { ...r, dashboardUrl: state.dashboardUrl };
|
|
2426
2531
|
})
|
|
2427
2532
|
: batchRunResults;
|
|
2428
2533
|
out.print({ results: enrichedResults });
|
|
@@ -4068,6 +4173,73 @@ function printRunOrChain(out, payload, createContext, textRenderer) {
|
|
|
4068
4173
|
return `${createText}\n\n${runText}`;
|
|
4069
4174
|
});
|
|
4070
4175
|
}
|
|
4176
|
+
/**
|
|
4177
|
+
* Server-first precedence for a `dashboardUrl` field on any wire response
|
|
4178
|
+
* that can carry one (`RunResponse`, `CliCreateTestResponse`,
|
|
4179
|
+
* `CliBatchSpecResult`). Single source of truth for the rule so the create
|
|
4180
|
+
* paths (DEV-737) and the run-completion path (`withRunDashboardUrl` below)
|
|
4181
|
+
* can't drift apart.
|
|
4182
|
+
*
|
|
4183
|
+
* This is a PINNED three-state wire contract — a prior revision let a
|
|
4184
|
+
* present-but-falsy value and a truly-absent key both mean "no server
|
|
4185
|
+
* opinion," which was ambiguous with the real backend behavior of omitting
|
|
4186
|
+
* the key on a deliberate "no correct link" response, printing the dead
|
|
4187
|
+
* legacy link this feature exists to remove. The backend now always
|
|
4188
|
+
* includes the key (typed `string | null`, never omitted when it has an
|
|
4189
|
+
* opinion), so the three states below are mutually exclusive on the wire:
|
|
4190
|
+
*
|
|
4191
|
+
* - **Present + truthy** → the server built a correct link (it alone knows
|
|
4192
|
+
* which store answered and this environment's portal origin); use it
|
|
4193
|
+
* verbatim.
|
|
4194
|
+
* - **Present + falsy (`null`/`''`)** → the server explicitly has no
|
|
4195
|
+
* correct link — e.g. a V3-native entity with no DynamoDB mirror row for
|
|
4196
|
+
* the client's V2-shaped `/dashboard/tests/…` guess to land on. NEVER
|
|
4197
|
+
* fall back here: a client-side guess would be exactly the dead link the
|
|
4198
|
+
* server declined to emit. `suppressed: true` tells the caller a link
|
|
4199
|
+
* was actively withheld (vs. simply never computed) so it can point the
|
|
4200
|
+
* user elsewhere instead of printing nothing unexplained.
|
|
4201
|
+
* - **Absent** → an older backend that predates this field entirely. Such a
|
|
4202
|
+
* backend cannot have produced a V3-native/unmirrored entity either —
|
|
4203
|
+
* that capability and this field ship together — so the client fallback
|
|
4204
|
+
* is safe and reproduces exactly today's behavior.
|
|
4205
|
+
*/
|
|
4206
|
+
function resolveDashboardUrl(wire, computeFallback) {
|
|
4207
|
+
if ('dashboardUrl' in wire) {
|
|
4208
|
+
return wire.dashboardUrl
|
|
4209
|
+
? { dashboardUrl: wire.dashboardUrl, suppressed: false }
|
|
4210
|
+
: { dashboardUrl: undefined, suppressed: true };
|
|
4211
|
+
}
|
|
4212
|
+
return { dashboardUrl: computeFallback(), suppressed: false };
|
|
4213
|
+
}
|
|
4214
|
+
/**
|
|
4215
|
+
* Applies {@link resolveDashboardUrl} to a whole entity, returning a
|
|
4216
|
+
* NORMALIZED copy: a server-suppressed (`null`/`''`) value is rewritten to
|
|
4217
|
+
* `undefined` so `JSON.stringify` omits the key entirely instead of
|
|
4218
|
+
* serializing a literal `"dashboardUrl": null` — the same normalization
|
|
4219
|
+
* `withRunDashboardUrl` already did inline for `RunResponse`, generalized
|
|
4220
|
+
* here so the create paths (DEV-737) can share it byte-for-byte.
|
|
4221
|
+
*/
|
|
4222
|
+
function withDashboardUrl(wire, computeFallback) {
|
|
4223
|
+
const { dashboardUrl, suppressed } = resolveDashboardUrl(wire, computeFallback);
|
|
4224
|
+
if ('dashboardUrl' in wire)
|
|
4225
|
+
return { entity: { ...wire, dashboardUrl }, suppressed };
|
|
4226
|
+
return { entity: dashboardUrl !== undefined ? { ...wire, dashboardUrl } : wire, suppressed };
|
|
4227
|
+
}
|
|
4228
|
+
/**
|
|
4229
|
+
* DEV-737: advisory printed when the server explicitly withheld a dashboard
|
|
4230
|
+
* link (`resolveDashboardUrl`'s `suppressed: true`) rather than silently
|
|
4231
|
+
* omitting the field with no explanation. Fires on stderr regardless of
|
|
4232
|
+
* `--output` mode — the field's absence from a JSON envelope carries no
|
|
4233
|
+
* reason on its own, and `--output json` is routinely unattended, so the
|
|
4234
|
+
* hint is worth the line there too (same reasoning as the `project create
|
|
4235
|
+
* --type backend` no-URL advisory in `project.ts`). Printing nothing beats
|
|
4236
|
+
* printing a dead link, but telling the caller where to look instead beats
|
|
4237
|
+
* printing nothing unexplained.
|
|
4238
|
+
*/
|
|
4239
|
+
function emitDashboardLinkSuppressedAdvisory(testId, stderrFn) {
|
|
4240
|
+
stderrFn(`[advisory] no dashboard link is available for this test right now; use ` +
|
|
4241
|
+
`\`testsprite test get ${testId}\` to look it up.`);
|
|
4242
|
+
}
|
|
4071
4243
|
/**
|
|
4072
4244
|
* Attach the Portal deep link to a terminal RunResponse.
|
|
4073
4245
|
*
|
|
@@ -4089,18 +4261,11 @@ function printRunOrChain(out, payload, createContext, textRenderer) {
|
|
|
4089
4261
|
* backend chose not to emit.
|
|
4090
4262
|
*/
|
|
4091
4263
|
function withRunDashboardUrl(run, apiUrl) {
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
if ('dashboardUrl' in run) {
|
|
4098
|
-
return run.dashboardUrl ? run : { ...run, dashboardUrl: undefined };
|
|
4099
|
-
}
|
|
4100
|
-
if (!run.projectId || !run.testId)
|
|
4101
|
-
return run;
|
|
4102
|
-
const dashboardUrl = resolvePortalUrl(apiUrl, run.projectId, run.testId);
|
|
4103
|
-
return dashboardUrl !== undefined ? { ...run, dashboardUrl } : run;
|
|
4264
|
+
return withDashboardUrl(run, () => {
|
|
4265
|
+
if (!run.projectId || !run.testId)
|
|
4266
|
+
return undefined;
|
|
4267
|
+
return resolvePortalUrl(apiUrl, run.projectId, run.testId);
|
|
4268
|
+
}).entity;
|
|
4104
4269
|
}
|
|
4105
4270
|
/**
|
|
4106
4271
|
* Render a `RunResponse` to human-readable text. JSON mode callers get
|
|
@@ -4213,6 +4378,78 @@ function parseTimeoutFlag(raw, flagName) {
|
|
|
4213
4378
|
}
|
|
4214
4379
|
return n;
|
|
4215
4380
|
}
|
|
4381
|
+
/**
|
|
4382
|
+
* Short deadline for the best-effort `v3Enabled` lookup behind the
|
|
4383
|
+
* `--target-url` advisory (DEV-749). Mirrors `DUP_NAME_ADVISORY_TIMEOUT_MS`
|
|
4384
|
+
* — a stalled `/me` must never meaningfully delay a run trigger.
|
|
4385
|
+
*/
|
|
4386
|
+
const TARGET_URL_ADVISORY_TIMEOUT_MS = 5_000;
|
|
4387
|
+
/**
|
|
4388
|
+
* DEV-749 (client half): `--target-url` is silently dropped on the V3
|
|
4389
|
+
* execution path — the backend validates it (SSRF guard, defence in depth)
|
|
4390
|
+
* and then discards it, because V3 resolves the run's environment from
|
|
4391
|
+
* `test_environment` at execution time; there is no injection point for a
|
|
4392
|
+
* per-run override. This is a client-side advisory only — the real fix
|
|
4393
|
+
* (an actual per-run override on V3) needs a product decision and is out
|
|
4394
|
+
* of scope here.
|
|
4395
|
+
*
|
|
4396
|
+
* Gated on `v3Enabled`, the same authoritative per-user routing bit
|
|
4397
|
+
* `auth status`/`doctor` already render (`GET /me`, `src/lib/v3-advisory.ts`).
|
|
4398
|
+
* Best-effort: a single bounded lookup (mirrors `emitDupNameAdvisoryIfNeeded`'s
|
|
4399
|
+
* `AbortController` + 5 s deadline), swallows every error, and must never
|
|
4400
|
+
* block or fail the actual run trigger — a broken/slow `/me` degrades to
|
|
4401
|
+
* "no advisory printed", not a failed `test run`.
|
|
4402
|
+
*/
|
|
4403
|
+
/**
|
|
4404
|
+
* `X-CLI-Command` tag for this probe's `GET /me` — same advisory-header
|
|
4405
|
+
* mechanism `runInit` uses (`toAuthDeps`'s `commandTag: 'init'` in
|
|
4406
|
+
* `commands/init.ts`, sent via `AuthDeps.commandTag` in `auth.ts`), reused
|
|
4407
|
+
* directly here rather than invented fresh. The backend's CLI-audit
|
|
4408
|
+
* allowlist (`KNOWN_CLI_COMMANDS` + `resolveCliEvent`'s `/me` branch) maps this
|
|
4409
|
+
* exact string to `null` — no PostHog event at all, not `cli.session_started`
|
|
4410
|
+
* and not `cli.initialized` (init's tag would be a MORE specific, and equally
|
|
4411
|
+
* wrong, misattribution of a probe that is neither a session start nor an
|
|
4412
|
+
* onboarding run).
|
|
4413
|
+
*
|
|
4414
|
+
* Forward-compatible by construction: an unlisted `X-CLI-Command` value is
|
|
4415
|
+
* dropped by the backend before event selection (see
|
|
4416
|
+
* `capturePostHogEvent`/`KNOWN_CLI_COMMANDS` in the interceptor above), so
|
|
4417
|
+
* against a backend that predates this allowlist entry the header is a no-op
|
|
4418
|
+
* and behavior is exactly what it was before this fix — the CLI can ship
|
|
4419
|
+
* this independently of backend deploy order in either direction.
|
|
4420
|
+
*/
|
|
4421
|
+
const TARGET_URL_ADVISORY_CLI_COMMAND = 'run-target-url-probe';
|
|
4422
|
+
async function emitTargetUrlV3AdvisoryIfNeeded(client, stderrFn) {
|
|
4423
|
+
const ac = new AbortController();
|
|
4424
|
+
const timer = setTimeout(() => ac.abort(), TARGET_URL_ADVISORY_TIMEOUT_MS);
|
|
4425
|
+
try {
|
|
4426
|
+
const me = await client.get('/me', {
|
|
4427
|
+
signal: ac.signal,
|
|
4428
|
+
headers: { 'x-cli-command': TARGET_URL_ADVISORY_CLI_COMMAND },
|
|
4429
|
+
// Finding 1 (dogfood 2026-08-09): `HttpClient.sleepBeforeRetry` (src/lib/http.ts)
|
|
4430
|
+
// only observes the process-lifetime shutdown signal, never a per-request
|
|
4431
|
+
// `options.signal` — the abort controller above bounds the FETCH itself but
|
|
4432
|
+
// not a post-response retry sleep. A retryable 429 carrying a real
|
|
4433
|
+
// `Retry-After` (e.g. 60s, a live `inflight_cap` response) would put this
|
|
4434
|
+
// best-effort probe into a retry sleep this 5s deadline cannot interrupt,
|
|
4435
|
+
// stalling the real run trigger behind it. `retryOnRateLimit: false` makes
|
|
4436
|
+
// the HTTP layer throw on the first 429 instead of sleeping — the existing,
|
|
4437
|
+
// already-used-elsewhere knob (see the batch-run trigger site above) rather
|
|
4438
|
+
// than changing `sleepBeforeRetry` itself, which every other caller (e.g.
|
|
4439
|
+
// the polling path) relies on to keep sleeping through a caller signal.
|
|
4440
|
+
retryOnRateLimit: false,
|
|
4441
|
+
});
|
|
4442
|
+
if (me.v3Enabled === true) {
|
|
4443
|
+
emitTargetUrlV3Advisory(stderrFn);
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4446
|
+
catch {
|
|
4447
|
+
// Swallow — this is best-effort; must not block or fail the run trigger.
|
|
4448
|
+
}
|
|
4449
|
+
finally {
|
|
4450
|
+
clearTimeout(timer);
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4216
4453
|
/**
|
|
4217
4454
|
* `test run <test-id>` — M3.3 piece-3.
|
|
4218
4455
|
*
|
|
@@ -4226,6 +4463,15 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
4226
4463
|
if (opts.targetUrl !== undefined) {
|
|
4227
4464
|
assertNotLocal(opts.targetUrl);
|
|
4228
4465
|
}
|
|
4466
|
+
// DEV-749: only spend the extra `/me` round trip when --target-url was
|
|
4467
|
+
// actually supplied — the common case (no override) pays nothing. Fires
|
|
4468
|
+
// in both the dry-run and real paths below (the dry-run `/me` sample sets
|
|
4469
|
+
// `v3Enabled: true`, so `--dry-run --target-url` demonstrates the same
|
|
4470
|
+
// advisory a real V3-routed caller would see, at zero real-network cost).
|
|
4471
|
+
if (opts.targetUrl !== undefined) {
|
|
4472
|
+
const stderrFn = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
4473
|
+
await emitTargetUrlV3AdvisoryIfNeeded(makeClient(opts, deps), stderrFn);
|
|
4474
|
+
}
|
|
4229
4475
|
if (opts.dryRun) {
|
|
4230
4476
|
const client = makeClient(opts, deps);
|
|
4231
4477
|
const out = makeOutput(opts.output, deps);
|
|
@@ -4549,7 +4795,8 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
4549
4795
|
// the standalone `test run <id>` path neither is set, so probe the test type
|
|
4550
4796
|
// once (text mode only, best-effort) — DEV-282.
|
|
4551
4797
|
const isBackend = await resolveRunCardIsBackend(client, opts.testId, opts.output, beFallbackUsed || opts.type === 'backend');
|
|
4552
|
-
|
|
4798
|
+
const finalRunWithUrl = withRunDashboardUrl(finalRun, resolveApiUrl(opts, deps));
|
|
4799
|
+
printRunOrChain(out, finalRunWithUrl, opts.createContext, data => renderRunResponseText(data, { isBackend }));
|
|
4553
4800
|
// Surface the trigger requestId under --verbose/--debug or JSON mode so
|
|
4554
4801
|
// operators can trace the full lifecycle (gated since 2026-06-04 dogfood;
|
|
4555
4802
|
// JSON mode always emits to stderr — it never pollutes stdout).
|
|
@@ -4562,6 +4809,41 @@ export async function runTestRun(opts, deps = {}) {
|
|
|
4562
4809
|
? `Run finished with status: ${finalRun.status}. Backend failure artifacts are addressed by testId — use 'testsprite test failure get ${finalRun.testId}' to download the bundle.`
|
|
4563
4810
|
: `Run finished with status: ${finalRun.status}. Use 'testsprite test artifact get ${finalRun.runId}' to download the failure bundle.`);
|
|
4564
4811
|
}
|
|
4812
|
+
// CI-native output layer (issue #99): single-test parity with the --all batch.
|
|
4813
|
+
// Emitted before the exit-code gate throws below so the summary file and
|
|
4814
|
+
// annotations land even when the run exits non-zero (mirrors the batch path).
|
|
4815
|
+
// The summary file is a machine artifact written regardless of --output mode;
|
|
4816
|
+
// under --output json the run envelope above owns stdout, so ::error::
|
|
4817
|
+
// workflow commands are routed to stderr (the Actions runner parses both).
|
|
4818
|
+
// Best-effort: a sink write throwing (e.g. EPIPE) must never skip the
|
|
4819
|
+
// exit-code gate below or change the command's exit status.
|
|
4820
|
+
try {
|
|
4821
|
+
const env = deps.env ?? process.env;
|
|
4822
|
+
const ghEnabled = opts.ghOutput === true || env.GITHUB_ACTIONS === 'true';
|
|
4823
|
+
if (ghEnabled || opts.summaryFile !== undefined) {
|
|
4824
|
+
const ciSummary = summarizeSingleRun(finalRunWithUrl);
|
|
4825
|
+
if (opts.summaryFile !== undefined) {
|
|
4826
|
+
try {
|
|
4827
|
+
writeFileSync(opts.summaryFile, `${JSON.stringify(ciSummary, null, 2)}\n`, 'utf8');
|
|
4828
|
+
}
|
|
4829
|
+
catch {
|
|
4830
|
+
stderrFn(`[run] could not write --summary-file ${opts.summaryFile}; continuing`);
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
if (ghEnabled) {
|
|
4834
|
+
const stdoutFn = deps.stdout ?? ((line) => process.stdout.write(`${line}\n`));
|
|
4835
|
+
emitGithubOutputs(ciSummary, env, {
|
|
4836
|
+
stdout: stdoutFn,
|
|
4837
|
+
stderr: stderrFn,
|
|
4838
|
+
appendFile: (path, content) => appendFileSync(path, content, 'utf8'),
|
|
4839
|
+
annotations: opts.output === 'json' ? stderrFn : stdoutFn,
|
|
4840
|
+
}, { force: opts.ghOutput === true });
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
catch (ciErr) {
|
|
4845
|
+
stderrFn(`[run] CI output emission failed; continuing: ${ciErr.message}`);
|
|
4846
|
+
}
|
|
4565
4847
|
const exitCode = exitCodeForRunStatus(finalRun.status);
|
|
4566
4848
|
if (exitCode !== 0) {
|
|
4567
4849
|
// Throw a CLIError so index.ts exits with the right code without
|
|
@@ -6841,6 +7123,35 @@ export async function runTestRerun(opts, deps = {}) {
|
|
|
6841
7123
|
};
|
|
6842
7124
|
await writeBatchJUnitReportIfRequested(opts, rerunResults);
|
|
6843
7125
|
out.print(jsonPayload);
|
|
7126
|
+
// CI-native output layer (issue #99): batch-rerun parity with `run --all`.
|
|
7127
|
+
// Emitted before the exit-code gates below so the summary file / annotations
|
|
7128
|
+
// land even when the batch exits non-zero. Summary-file is a machine artifact
|
|
7129
|
+
// written regardless of --output mode; under --output json the envelope above
|
|
7130
|
+
// owns stdout, so ::error:: workflow commands go to stderr instead.
|
|
7131
|
+
{
|
|
7132
|
+
const env = deps.env ?? process.env;
|
|
7133
|
+
const ghEnabled = opts.ghOutput === true || env.GITHUB_ACTIONS === 'true';
|
|
7134
|
+
if (ghEnabled || opts.summaryFile !== undefined) {
|
|
7135
|
+
const ciSummary = summarizeAcceptedPayload(JSON.stringify(jsonPayload));
|
|
7136
|
+
if (opts.summaryFile !== undefined) {
|
|
7137
|
+
try {
|
|
7138
|
+
writeFileSync(opts.summaryFile, `${JSON.stringify(ciSummary, null, 2)}\n`, 'utf8');
|
|
7139
|
+
}
|
|
7140
|
+
catch {
|
|
7141
|
+
stderrFn(`[rerun] could not write --summary-file ${opts.summaryFile}; continuing`);
|
|
7142
|
+
}
|
|
7143
|
+
}
|
|
7144
|
+
if (ghEnabled) {
|
|
7145
|
+
const stdoutFn = deps.stdout ?? ((line) => process.stdout.write(`${line}\n`));
|
|
7146
|
+
emitGithubOutputs(ciSummary, env, {
|
|
7147
|
+
stdout: stdoutFn,
|
|
7148
|
+
stderr: stderrFn,
|
|
7149
|
+
appendFile: (path, content) => appendFileSync(path, content, 'utf8'),
|
|
7150
|
+
annotations: opts.output === 'json' ? stderrFn : stdoutFn,
|
|
7151
|
+
}, { force: opts.ghOutput === true });
|
|
7152
|
+
}
|
|
7153
|
+
}
|
|
7154
|
+
}
|
|
6844
7155
|
// Determine exit code: timeout (deferred or any timeout) → 7; any fail → 1; all pass → 0
|
|
6845
7156
|
if (deferred.length > 0 || timedOut > 0) {
|
|
6846
7157
|
const stillRunning = timedOut > 0 ? rerunResults.filter(r => r.status === 'timeout').map(r => r.runId) : [];
|
|
@@ -7463,8 +7774,8 @@ export function createTestCommand(deps = {}) {
|
|
|
7463
7774
|
.option('--report <format>', 'with --all --wait: write a JUnit XML sidecar report after polling (accepted: junit)')
|
|
7464
7775
|
.option('--report-file <path>', 'output path for --report (atomic write)')
|
|
7465
7776
|
.option('--report-suite-name <name>', 'optional JUnit <testsuite name=...> override (default: testsprite:<projectId>)')
|
|
7466
|
-
.option('--gh-output', 'with --
|
|
7467
|
-
.option('--summary-file <path>', 'with --
|
|
7777
|
+
.option('--gh-output', 'with --wait (single test or --all): emit GitHub-native output (::error:: annotations per non-passed run; job-summary table when $GITHUB_STEP_SUMMARY is set). Auto-enabled when GITHUB_ACTIONS=true')
|
|
7778
|
+
.option('--summary-file <path>', 'with --wait (single test or --all): also write the reduced machine summary JSON {total, passed, failed, timedOut, runs[]} to this file')
|
|
7468
7779
|
.addHelpText('after', '\nDependency-aware fresh run (M4):\n' +
|
|
7469
7780
|
' testsprite test run --all --project <id> run all project tests in wave order\n' +
|
|
7470
7781
|
' TESTSPRITE_PROJECT_ID=<id> testsprite test run --all use env default project\n' +
|
|
@@ -7500,15 +7811,16 @@ export function createTestCommand(deps = {}) {
|
|
|
7500
7811
|
wait: cmdOpts.wait === true,
|
|
7501
7812
|
batchPath: isAll,
|
|
7502
7813
|
});
|
|
7503
|
-
// --gh-output / --summary-file reduce
|
|
7504
|
-
//
|
|
7505
|
-
//
|
|
7506
|
-
//
|
|
7507
|
-
|
|
7508
|
-
|
|
7814
|
+
// --gh-output / --summary-file reduce a --wait run's terminal result into
|
|
7815
|
+
// the CI summary. They require --wait (without it the command returns after
|
|
7816
|
+
// enqueueing, before any terminal result exists) but apply to BOTH a single
|
|
7817
|
+
// <test-id> run and the --all batch. Without --wait they would silently
|
|
7818
|
+
// no-op — reject loudly (same rule as --filter and the JUnit report flags).
|
|
7819
|
+
if (cmdOpts.ghOutput === true && cmdOpts.wait !== true) {
|
|
7820
|
+
throw localValidationError('gh-output', '--gh-output requires --wait (it reduces the terminal run result). Add --wait.');
|
|
7509
7821
|
}
|
|
7510
|
-
if (cmdOpts.summaryFile !== undefined &&
|
|
7511
|
-
throw localValidationError('summary-file', '--summary-file
|
|
7822
|
+
if (cmdOpts.summaryFile !== undefined && cmdOpts.wait !== true) {
|
|
7823
|
+
throw localValidationError('summary-file', '--summary-file requires --wait (it reduces the terminal run result). Add --wait.');
|
|
7512
7824
|
}
|
|
7513
7825
|
if (isAll) {
|
|
7514
7826
|
// --all path: wave-ordered fresh batch run.
|
|
@@ -7550,6 +7862,8 @@ export function createTestCommand(deps = {}) {
|
|
|
7550
7862
|
// B2(c): tell runTestRun whether --timeout was explicitly provided.
|
|
7551
7863
|
timeoutIsDefault: cmdOpts.timeout === undefined,
|
|
7552
7864
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
7865
|
+
ghOutput: cmdOpts.ghOutput === true,
|
|
7866
|
+
summaryFile: cmdOpts.summaryFile,
|
|
7553
7867
|
}, deps);
|
|
7554
7868
|
});
|
|
7555
7869
|
test
|
|
@@ -7634,6 +7948,8 @@ export function createTestCommand(deps = {}) {
|
|
|
7634
7948
|
.option('--report <format>', 'with batch --wait: write a JUnit XML sidecar report after polling (accepted: junit)')
|
|
7635
7949
|
.option('--report-file <path>', 'output path for --report (atomic write)')
|
|
7636
7950
|
.option('--report-suite-name <name>', 'optional JUnit <testsuite name=...> override (default: testsprite:<projectId>)')
|
|
7951
|
+
.option('--gh-output', 'with batch --wait: emit GitHub-native output (::error:: annotations per non-passed run; job-summary table when $GITHUB_STEP_SUMMARY is set). Auto-enabled when GITHUB_ACTIONS=true')
|
|
7952
|
+
.option('--summary-file <path>', 'with batch --wait: also write the reduced machine summary JSON {total, passed, failed, timedOut, runs[]} to this file')
|
|
7637
7953
|
.addHelpText('after', '\nNotes:\n' +
|
|
7638
7954
|
' • rerun replays a saved run/script and is MORE LENIENT than a fresh `test run`\n' +
|
|
7639
7955
|
' (auto-heal can pass steps that have drifted) — for strict scoring/regression,\n' +
|
|
@@ -7665,6 +7981,15 @@ export function createTestCommand(deps = {}) {
|
|
|
7665
7981
|
wait: cmdOpts.wait === true,
|
|
7666
7982
|
batchPath: isBatch,
|
|
7667
7983
|
});
|
|
7984
|
+
// --gh-output / --summary-file reduce the batch-rerun --wait envelope, which
|
|
7985
|
+
// only exists on the batch (--all or 2+ ids) --wait path. Anywhere else they
|
|
7986
|
+
// would silently no-op — reject loudly (same rule as the JUnit report flags).
|
|
7987
|
+
if (cmdOpts.ghOutput === true && (!isBatch || cmdOpts.wait !== true)) {
|
|
7988
|
+
throw localValidationError('gh-output', '--gh-output requires a batch rerun with --wait (--all or 2+ test ids). Remove --gh-output, or add --all --wait.');
|
|
7989
|
+
}
|
|
7990
|
+
if (cmdOpts.summaryFile !== undefined && (!isBatch || cmdOpts.wait !== true)) {
|
|
7991
|
+
throw localValidationError('summary-file', '--summary-file requires a batch rerun with --wait (--all or 2+ test ids). Remove --summary-file, or add --all --wait.');
|
|
7992
|
+
}
|
|
7668
7993
|
await runTestRerun({
|
|
7669
7994
|
...resolveCommonOptions(command),
|
|
7670
7995
|
testIds,
|
|
@@ -7684,6 +8009,8 @@ export function createTestCommand(deps = {}) {
|
|
|
7684
8009
|
report,
|
|
7685
8010
|
reportFile: cmdOpts.reportFile,
|
|
7686
8011
|
reportSuiteName: cmdOpts.reportSuiteName,
|
|
8012
|
+
ghOutput: cmdOpts.ghOutput === true,
|
|
8013
|
+
summaryFile: cmdOpts.summaryFile,
|
|
7687
8014
|
}, deps);
|
|
7688
8015
|
});
|
|
7689
8016
|
// -------------------------------------------------------------------------
|