@testsprite/testsprite-cli 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -141
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +55 -65
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +44 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +297 -489
- package/dist/commands/completion.js +2 -1
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +702 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +130 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +116 -68
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +426 -53
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -224
- package/dist/commands/project.d.ts +15 -186
- package/dist/commands/project.js +93 -921
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +215 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +47 -97
- package/dist/commands/test.d.ts +315 -1824
- package/dist/commands/test.js +1962 -13733
- package/dist/commands/testlist.d.ts +128 -5
- package/dist/commands/testlist.js +269 -329
- package/dist/commands/tunnel.d.ts +2 -2
- package/dist/commands/tunnel.js +43 -41
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +51 -131
- package/dist/index.js +189 -108
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +10 -2
- package/dist/lib/client-factory.js +38 -26
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +31 -4
- package/dist/lib/conflict-reason.js +38 -4
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +71 -0
- package/dist/lib/conversation/api.js +150 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +19 -0
- package/dist/lib/conversation/context.js +70 -0
- package/dist/lib/conversation/environment.d.ts +15 -0
- package/dist/lib/conversation/environment.js +33 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +315 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +156 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +71 -0
- package/dist/lib/download.js +274 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +389 -751
- package/dist/lib/environment-tunnel.d.ts +16 -26
- package/dist/lib/environment-tunnel.js +161 -157
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +16 -22
- package/dist/lib/first-suite-hint.js +38 -47
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +352 -271
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +60 -4
- package/dist/lib/junit-report.js +209 -32
- package/dist/lib/local-target.d.ts +3 -3
- package/dist/lib/local-target.js +3 -3
- package/dist/lib/output.d.ts +0 -29
- package/dist/lib/output.js +10 -33
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +154 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +210 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +71 -0
- package/dist/lib/result/evidence.js +420 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +134 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +1 -1
- package/dist/lib/target-url.js +6 -16
- package/dist/lib/telemetry.d.ts +32 -12
- package/dist/lib/telemetry.js +39 -8
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +7 -1
- package/dist/lib/tunnel-session.js +22 -9
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -4
- package/skills/testsprite-ci.skill.md +48 -18
- package/skills/testsprite-onboard.skill.md +66 -151
- package/skills/testsprite-verify.codex.md +54 -56
- package/skills/testsprite-verify.skill.md +194 -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 -10
- package/dist/lib/deprecate.js +0 -13
- 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
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { InterruptError, RequestTimeoutError } from './errors.js';
|
|
2
|
+
import { formatFailureCounts, summarizeRunRows } from './gh-output.js';
|
|
3
|
+
import { ALL_RESULT_STATUSES, isResultRunning } from './result/types.js';
|
|
4
|
+
import { toWaitMembers } from './run-wait.js';
|
|
5
|
+
import { waitCommand } from './run-render.js';
|
|
6
|
+
import { terminalSafeLine } from './terminal-text.js';
|
|
7
|
+
import { waitMemberError } from './wait-exit.js';
|
|
8
|
+
/** Normalize the saved-list wire receipt before combining it with listed results. */
|
|
9
|
+
export function listResultReceipt(row) {
|
|
10
|
+
return {
|
|
11
|
+
testId: row.testId,
|
|
12
|
+
resultId: row.resultId,
|
|
13
|
+
runId: row.runId,
|
|
14
|
+
enqueuedAt: row.enqueuedAt,
|
|
15
|
+
status: 'dispatched',
|
|
16
|
+
...(typeof row.testTitle === 'string' ? { title: row.testTitle } : {}),
|
|
17
|
+
...(typeof row.dashboardUrl === 'string' ? { dashboardUrl: row.dashboardUrl } : {}),
|
|
18
|
+
...(typeof row.executionUrl === 'string' ? { executionUrl: row.executionUrl } : {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function runDiagnostic(outcome, statuses) {
|
|
22
|
+
const { runId } = outcome;
|
|
23
|
+
if (outcome.run?.cancelled && !outcome.joined)
|
|
24
|
+
return {
|
|
25
|
+
runId,
|
|
26
|
+
status: 'cancelled',
|
|
27
|
+
error: { code: 'RUN_CANCELLED', message: `Run ${runId} was cancelled.`, exitCode: 1 },
|
|
28
|
+
};
|
|
29
|
+
if (outcome.error && !statuses?.has('error'))
|
|
30
|
+
return { runId, status: 'error', error: waitMemberError(outcome.error) };
|
|
31
|
+
if (outcome.timedOut && !outcome.error && !statuses?.has('timeout'))
|
|
32
|
+
return {
|
|
33
|
+
runId,
|
|
34
|
+
status: 'timeout',
|
|
35
|
+
error: {
|
|
36
|
+
code: 'TIMEOUT',
|
|
37
|
+
message: `Run ${runId} did not finish before the deadline.`,
|
|
38
|
+
exitCode: 7,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
function resultErrorCode(status) {
|
|
44
|
+
switch (status) {
|
|
45
|
+
case 'failed':
|
|
46
|
+
return 'TEST_FAILED';
|
|
47
|
+
case 'blocked':
|
|
48
|
+
return 'TEST_BLOCKED';
|
|
49
|
+
case 'cancelled':
|
|
50
|
+
return 'TEST_CANCELLED';
|
|
51
|
+
default:
|
|
52
|
+
return 'RESULT_ERROR';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Project launches, saved lists and reattached waits share one native output contract. */
|
|
56
|
+
export function buildRunOutput(opts) {
|
|
57
|
+
const outcomes = opts.outcomes ?? new Map();
|
|
58
|
+
const runs = opts.receipts.map(receipt => {
|
|
59
|
+
const outcome = outcomes.get(receipt.runId);
|
|
60
|
+
const cancel = opts.cancellation?.(receipt.runId);
|
|
61
|
+
return {
|
|
62
|
+
...outcome?.run,
|
|
63
|
+
...receipt,
|
|
64
|
+
...(outcome?.run ? { status: outcome.run.status, cancelled: outcome.run.cancelled } : {}),
|
|
65
|
+
...(opts.wait && !outcome?.run ? { listed: false } : {}),
|
|
66
|
+
...(outcome?.timedOut ? { timedOut: true } : {}),
|
|
67
|
+
...(outcome?.error ? { error: waitMemberError(outcome.error) } : {}),
|
|
68
|
+
...(cancel ? { cancel } : {}),
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
const receipts = new Map(opts.dispatched?.map(row => [row.resultId, row]));
|
|
72
|
+
const observed = [];
|
|
73
|
+
for (const outcome of outcomes.values()) {
|
|
74
|
+
const lines = new Map(outcome.results.map(line => [line.resultId, line]));
|
|
75
|
+
const cancel = opts.cancellation?.(outcome.runId);
|
|
76
|
+
for (const member of toWaitMembers(outcome)) {
|
|
77
|
+
const line = lines.get(member.resultId);
|
|
78
|
+
const receipt = receipts.get(member.resultId);
|
|
79
|
+
const receiptError = receipt?.status === member.status ? receipt.error : undefined;
|
|
80
|
+
const detail = line?.error || (member.status === 'blocked' ? line?.blockedReason : null);
|
|
81
|
+
const error = member.error ??
|
|
82
|
+
(detail
|
|
83
|
+
? {
|
|
84
|
+
code: receiptError?.code ?? resultErrorCode(member.status),
|
|
85
|
+
message: detail,
|
|
86
|
+
exitCode: 1,
|
|
87
|
+
}
|
|
88
|
+
: receiptError);
|
|
89
|
+
observed.push({
|
|
90
|
+
...receipt,
|
|
91
|
+
...member,
|
|
92
|
+
...(line ? { title: line.title, createdAt: line.created } : {}),
|
|
93
|
+
error,
|
|
94
|
+
...(cancel ? { cancel } : {}),
|
|
95
|
+
});
|
|
96
|
+
receipts.delete(member.resultId);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const row of receipts.values()) {
|
|
100
|
+
const outcome = row.runId ? outcomes.get(row.runId) : undefined;
|
|
101
|
+
const cancel = row.runId ? opts.cancellation?.(row.runId) : undefined;
|
|
102
|
+
observed.push({
|
|
103
|
+
...row,
|
|
104
|
+
...(opts.wait && row.status === 'dispatched'
|
|
105
|
+
? { status: outcome?.timedOut ? 'timeout' : 'running' }
|
|
106
|
+
: {}),
|
|
107
|
+
...(cancel ? { cancel } : {}),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const results = observed.map(({ error, ...row }) => ({
|
|
111
|
+
...row,
|
|
112
|
+
...(error ? { error: error.message, errorCode: error.code } : {}),
|
|
113
|
+
}));
|
|
114
|
+
const statusesByRun = new Map();
|
|
115
|
+
for (const row of results) {
|
|
116
|
+
if (!row.runId)
|
|
117
|
+
continue;
|
|
118
|
+
const statuses = statusesByRun.get(row.runId) ?? new Set();
|
|
119
|
+
statuses.add(row.status);
|
|
120
|
+
statusesByRun.set(row.runId, statuses);
|
|
121
|
+
}
|
|
122
|
+
const diagnosticRows = [...outcomes.values()].flatMap(outcome => {
|
|
123
|
+
const row = runDiagnostic(outcome, statusesByRun.get(outcome.runId));
|
|
124
|
+
return row ? [{ ...row, testId: `(run ${row.runId})`, name: row.error.message }] : [];
|
|
125
|
+
});
|
|
126
|
+
const members = observed.map(row => ({
|
|
127
|
+
...row,
|
|
128
|
+
testId: row.testId ?? '(integration)',
|
|
129
|
+
name: row.title,
|
|
130
|
+
}));
|
|
131
|
+
const summary = summarizeRunRows(results, opts.buckets, {
|
|
132
|
+
notFoundNote: opts.notFoundNote,
|
|
133
|
+
foldSkippedBuckets: opts.foldSkippedBuckets,
|
|
134
|
+
});
|
|
135
|
+
if (diagnosticRows.length)
|
|
136
|
+
summary.runFailures = diagnosticRows.map(({ runId, status, error }) => ({
|
|
137
|
+
runId,
|
|
138
|
+
status,
|
|
139
|
+
message: error.message,
|
|
140
|
+
}));
|
|
141
|
+
const stopped = opts.failure instanceof InterruptError ||
|
|
142
|
+
opts.failure instanceof RequestTimeoutError ||
|
|
143
|
+
opts.requestTimedOut;
|
|
144
|
+
const incompleteWait = (run) => {
|
|
145
|
+
if (run.status === 'finished' || outcomes.get(run.runId)?.error?.code === 'NOT_FOUND')
|
|
146
|
+
return false;
|
|
147
|
+
const joinedIds = opts.joinedScopes?.get(run.runId);
|
|
148
|
+
if (!joinedIds)
|
|
149
|
+
return true;
|
|
150
|
+
const settled = new Set(outcomes
|
|
151
|
+
.get(run.runId)
|
|
152
|
+
?.results.filter(line => !isResultRunning(line.testStatus))
|
|
153
|
+
.map(line => line.resultId));
|
|
154
|
+
return joinedIds.some(id => !settled.has(id));
|
|
155
|
+
};
|
|
156
|
+
const unfinishedRuns = runs.filter(incompleteWait);
|
|
157
|
+
const partial = [...outcomes.values()].some(outcome => outcome.timedOut) ||
|
|
158
|
+
(stopped && (opts.incompleteDispatch || (opts.wait && unfinishedRuns.length > 0)));
|
|
159
|
+
return {
|
|
160
|
+
output: {
|
|
161
|
+
runs,
|
|
162
|
+
results,
|
|
163
|
+
...(opts.wait ? { summary: runCounts(summary) } : {}),
|
|
164
|
+
...(summary.runFailures ? { runFailures: summary.runFailures } : {}),
|
|
165
|
+
...(partial ? { partial: true } : {}),
|
|
166
|
+
},
|
|
167
|
+
summary,
|
|
168
|
+
members,
|
|
169
|
+
// JUnit needs a synthetic testcase only when no result already reports this failure.
|
|
170
|
+
diagnosticRows: diagnosticRows.filter(row => !statusesByRun.get(row.runId)?.has(row.status)),
|
|
171
|
+
unfinishedRuns,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export function runCounts({ results: _results, runFailures: _runFailures, executionReport: _executionReport, ...counts }) {
|
|
175
|
+
return counts;
|
|
176
|
+
}
|
|
177
|
+
/** The poll descriptor used by all run previews. Only supplied ids need escaping. */
|
|
178
|
+
export function runListingPath(runId) {
|
|
179
|
+
return `/api/cli/v1/results?run=${runId === undefined ? '<run-id>' : encodeURIComponent(runId)}&status=${ALL_RESULT_STATUSES.join(',')}`;
|
|
180
|
+
}
|
|
181
|
+
export function previewRun(requests, wait, thenPoll = false) {
|
|
182
|
+
const { output } = buildRunOutput({ receipts: [], wait });
|
|
183
|
+
return { ...output, dryRun: true, requests, ...(thenPoll ? { thenPoll: runListingPath() } : {}) };
|
|
184
|
+
}
|
|
185
|
+
function renderRunCounts(summary) {
|
|
186
|
+
return [
|
|
187
|
+
`${summary.passed}/${summary.total} passed`,
|
|
188
|
+
formatFailureCounts(summary),
|
|
189
|
+
`${summary.timedOut} timed out`,
|
|
190
|
+
...(summary.running ? [`${summary.running} still running`] : []),
|
|
191
|
+
...(summary.skipped ? [`${summary.skipped} not dispatched`] : []),
|
|
192
|
+
].join(', ');
|
|
193
|
+
}
|
|
194
|
+
export function renderRunResults(runs, results, summary, notes = []) {
|
|
195
|
+
const rows = new Map();
|
|
196
|
+
for (const result of results) {
|
|
197
|
+
const group = rows.get(result.runId) ?? [];
|
|
198
|
+
group.push(` ${terminalSafeLine(result.resultId)} ${terminalSafeLine(result.title?.trim() || result.testId || '-')} ${terminalSafeLine(result.status)}`);
|
|
199
|
+
rows.set(result.runId, group);
|
|
200
|
+
}
|
|
201
|
+
const wait = summary ? undefined : waitCommand(runs.filter(run => !run.joined));
|
|
202
|
+
const lines = runs.flatMap(run => {
|
|
203
|
+
const members = rows.get(run.runId) ?? [];
|
|
204
|
+
const count = run.total ?? members.length;
|
|
205
|
+
const header = [
|
|
206
|
+
`Run ${terminalSafeLine(run.runId)}${run.cancelled ? ' — cancelled' : ''}`,
|
|
207
|
+
...(run.targetUrl ? [terminalSafeLine(run.targetUrl)] : []),
|
|
208
|
+
...(!summary ? [`(${count} test${count === 1 ? '' : 's'})`] : []),
|
|
209
|
+
].join(' ');
|
|
210
|
+
return [
|
|
211
|
+
header,
|
|
212
|
+
...members,
|
|
213
|
+
// The run's page in the Portal, on a launch receipt and a waited card alike.
|
|
214
|
+
...(run.dashboardUrl ? [` Dashboard: ${terminalSafeLine(run.dashboardUrl)}`] : []),
|
|
215
|
+
];
|
|
216
|
+
});
|
|
217
|
+
lines.push(...(rows.get(undefined) ?? []));
|
|
218
|
+
for (const failure of summary?.runFailures ?? [])
|
|
219
|
+
lines.push(terminalSafeLine(failure.message));
|
|
220
|
+
lines.push(...notes);
|
|
221
|
+
if (summary)
|
|
222
|
+
lines.push(renderRunCounts(summary));
|
|
223
|
+
if (wait)
|
|
224
|
+
lines.push(wait);
|
|
225
|
+
return lines.length ? lines.join('\n') : 'No runs dispatched.';
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=run-output.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export interface RunRef {
|
|
2
|
+
runId?: string | null;
|
|
3
|
+
resultId?: string | null;
|
|
4
|
+
joined?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function resultCount(n: number): string;
|
|
7
|
+
/** A count of runs in prose: "1 run", "2 runs". */
|
|
8
|
+
export declare function runCount(n: number): string;
|
|
9
|
+
/** The launches these results belong to, each once, in first-seen order. */
|
|
10
|
+
export declare function launchIds(refs: ReadonlyArray<RunRef>): string[];
|
|
11
|
+
/**
|
|
12
|
+
* The one launch all of these results belong to. `undefined` when they span
|
|
13
|
+
* several launches, or when the backend named no launch for one of them: a
|
|
14
|
+
* launch id is never stated for results it may not cover. An entry that never
|
|
15
|
+
* got a result id (a test that was not dispatched) does not count.
|
|
16
|
+
*/
|
|
17
|
+
export declare function sharedLaunchId(refs: ReadonlyArray<RunRef>): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The command that waits for these results' launches, or `undefined` when no
|
|
20
|
+
* launch is known: `run wait` takes a launch id, so a result id is never
|
|
21
|
+
* offered in its place.
|
|
22
|
+
*/
|
|
23
|
+
export declare function waitCommand(refs: ReadonlyArray<RunRef>): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The read that shows what was cancelled in these results' launches, one
|
|
26
|
+
* `result list --run <run-id> --status cancelled` per launch: after a closing
|
|
27
|
+
* tunnel has cancelled them, `run cancel` would stop everything else still
|
|
28
|
+
* running in the launch.
|
|
29
|
+
*/
|
|
30
|
+
export declare function cancelledResultsCommand(refs: ReadonlyArray<RunRef>): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* What `run cancel` does to a launch: it takes the launch id, so it stops
|
|
33
|
+
* every test in that run, not one of them.
|
|
34
|
+
*/
|
|
35
|
+
export declare const CANCEL_STOPS_WHOLE_RUN = "stops every test in that run";
|
|
36
|
+
/**
|
|
37
|
+
* The command that cancels these results' launches; see {@link waitCommand}.
|
|
38
|
+
* A launch this invocation started is its own to cancel, so the command stands
|
|
39
|
+
* alone. For a launch it only joined, the command is followed by what
|
|
40
|
+
* cancelling it stops.
|
|
41
|
+
*/
|
|
42
|
+
export declare function cancelCommand(refs: ReadonlyArray<RunRef>): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* What is true of work a wait let go of: it keeps executing, and billing, on
|
|
45
|
+
* the server. One result is named by its launch (`Run <id>`), or as
|
|
46
|
+
* `Result <id>` when the backend named no launch. Several are counted as
|
|
47
|
+
* tests, since they may all belong to one run, and refs that name only a
|
|
48
|
+
* launch (a run whose results were never listed) as runs.
|
|
49
|
+
*/
|
|
50
|
+
export declare function stillRunningAndBillingSubject(refs: ReadonlyArray<RunRef>): string;
|
|
51
|
+
/**
|
|
52
|
+
* The two indented lines under a detach message: how to re-attach and how to
|
|
53
|
+
* cancel. Both commands take the launch, so they name each launch once; when
|
|
54
|
+
* the backend named no launch there is nothing to offer and no line is added.
|
|
55
|
+
*/
|
|
56
|
+
export declare function reattachLines(refs: ReadonlyArray<RunRef>): string;
|
|
57
|
+
/** The same two commands as one trailing sentence, or nothing when no launch is known. */
|
|
58
|
+
export declare function reattachSentence(refs: ReadonlyArray<RunRef>): string;
|
|
59
|
+
/**
|
|
60
|
+
* What a wait says when Ctrl-C ends it: only the local wait stopped, the work
|
|
61
|
+
* keeps executing and billing, and these are the commands to re-attach to it
|
|
62
|
+
* or to really stop it.
|
|
63
|
+
*/
|
|
64
|
+
export declare function interruptDetachMessage(interrupt: {
|
|
65
|
+
signal: string;
|
|
66
|
+
}, refs: ReadonlyArray<RunRef>): string;
|
|
67
|
+
/** One piece of work to look up later, by whatever ids are known (wire names). */
|
|
68
|
+
export interface LaterLookup {
|
|
69
|
+
testId?: string | null;
|
|
70
|
+
/** The result id. */
|
|
71
|
+
resultId?: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Look the result itself up rather than the test's results. Set for a
|
|
74
|
+
* result the CLI cancelled: result lists leave cancelled results out, so
|
|
75
|
+
* the test's list would show an older verdict as if it were this one.
|
|
76
|
+
*/
|
|
77
|
+
byResult?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/** How many lookups a hint lists before it counts the rest. */
|
|
80
|
+
export declare const CHECK_LATER_LIMIT = 10;
|
|
81
|
+
/**
|
|
82
|
+
* What a wait that gave up can still point at when no launch is known (so
|
|
83
|
+
* neither `run wait` nor `run cancel` can be offered): one line per piece of
|
|
84
|
+
* work, the first ten, then a count of the rest. A test is looked up by its
|
|
85
|
+
* results; with no test id, or for a result named with `byResult`, the result
|
|
86
|
+
* is looked up itself. No line carries a placeholder. Empty when nothing can
|
|
87
|
+
* be looked up.
|
|
88
|
+
*/
|
|
89
|
+
export declare function checkLaterHint(lookups: ReadonlyArray<LaterLookup>): string;
|
|
90
|
+
/**
|
|
91
|
+
* How prose names one result's work: `Run <launch id>` when the launch is
|
|
92
|
+
* known, otherwise `Result <result id>`. A result id is never called a run.
|
|
93
|
+
* With neither id it is just `The run`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function runLabel(ref: RunRef, letterCase?: 'upper' | 'lower'): string;
|
|
96
|
+
/**
|
|
97
|
+
* The id of one result's work as a `name: value` note: `resultId: <launch id>`
|
|
98
|
+
* when the launch is known, otherwise `resultId: <result id>`.
|
|
99
|
+
*/
|
|
100
|
+
export declare function runIdNote(ref: RunRef): string;
|
|
101
|
+
export declare const OLDER_CLI_RESULT_ID_HINT = "a result id printed by an older CLI is not one. Look a result up with: testsprite result get <result-id>";
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/** Native run/result references and human-readable command hints. */
|
|
2
|
+
import { terminalSafeLine } from './terminal-text.js';
|
|
3
|
+
const idOf = (value) => typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
4
|
+
const inLine = terminalSafeLine;
|
|
5
|
+
export function resultCount(n) {
|
|
6
|
+
return `${n} result${n === 1 ? '' : 's'}`;
|
|
7
|
+
}
|
|
8
|
+
/** A count of runs in prose: "1 run", "2 runs". */
|
|
9
|
+
export function runCount(n) {
|
|
10
|
+
return `${n} run${n === 1 ? '' : 's'}`;
|
|
11
|
+
}
|
|
12
|
+
/** The launches these results belong to, each once, in first-seen order. */
|
|
13
|
+
export function launchIds(refs) {
|
|
14
|
+
const ids = [];
|
|
15
|
+
for (const ref of refs) {
|
|
16
|
+
const launchId = idOf(ref.runId);
|
|
17
|
+
if (launchId !== undefined && !ids.includes(launchId))
|
|
18
|
+
ids.push(launchId);
|
|
19
|
+
}
|
|
20
|
+
return ids;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The one launch all of these results belong to. `undefined` when they span
|
|
24
|
+
* several launches, or when the backend named no launch for one of them: a
|
|
25
|
+
* launch id is never stated for results it may not cover. An entry that never
|
|
26
|
+
* got a result id (a test that was not dispatched) does not count.
|
|
27
|
+
*/
|
|
28
|
+
export function sharedLaunchId(refs) {
|
|
29
|
+
const dispatched = refs.filter(ref => idOf(ref.resultId) !== undefined);
|
|
30
|
+
const ids = launchIds(dispatched);
|
|
31
|
+
return ids.length === 1 && dispatched.every(ref => idOf(ref.runId) !== undefined)
|
|
32
|
+
? ids[0]
|
|
33
|
+
: undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The command that waits for these results' launches, or `undefined` when no
|
|
37
|
+
* launch is known: `run wait` takes a launch id, so a result id is never
|
|
38
|
+
* offered in its place.
|
|
39
|
+
*/
|
|
40
|
+
export function waitCommand(refs) {
|
|
41
|
+
const ids = launchIds(refs).map(inLine);
|
|
42
|
+
return ids.length > 0 ? `testsprite run wait ${ids.join(' ')}` : undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The read that shows what was cancelled in these results' launches, one
|
|
46
|
+
* `result list --run <run-id> --status cancelled` per launch: after a closing
|
|
47
|
+
* tunnel has cancelled them, `run cancel` would stop everything else still
|
|
48
|
+
* running in the launch.
|
|
49
|
+
*/
|
|
50
|
+
export function cancelledResultsCommand(refs) {
|
|
51
|
+
const ids = launchIds(refs).map(inLine);
|
|
52
|
+
return ids.length > 0
|
|
53
|
+
? ids.map(id => `testsprite result list --run ${id} --status cancelled`).join('; ')
|
|
54
|
+
: undefined;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* What `run cancel` does to a launch: it takes the launch id, so it stops
|
|
58
|
+
* every test in that run, not one of them.
|
|
59
|
+
*/
|
|
60
|
+
export const CANCEL_STOPS_WHOLE_RUN = 'stops every test in that run';
|
|
61
|
+
/** The same, said of several launches at once. */
|
|
62
|
+
const CANCEL_STOPS_WHOLE_RUNS = 'stops every test in those runs';
|
|
63
|
+
/**
|
|
64
|
+
* The command that cancels these results' launches; see {@link waitCommand}.
|
|
65
|
+
* A launch this invocation started is its own to cancel, so the command stands
|
|
66
|
+
* alone. For a launch it only joined, the command is followed by what
|
|
67
|
+
* cancelling it stops.
|
|
68
|
+
*/
|
|
69
|
+
export function cancelCommand(refs) {
|
|
70
|
+
const ids = launchIds(refs).map(inLine);
|
|
71
|
+
if (ids.length === 0)
|
|
72
|
+
return undefined;
|
|
73
|
+
const joined = launchIds(refs.filter(ref => ref.joined === true)).map(inLine);
|
|
74
|
+
const command = `testsprite run cancel ${ids.join(' ')}`;
|
|
75
|
+
if (joined.length === 0)
|
|
76
|
+
return command;
|
|
77
|
+
const scope = joined.length === 1 ? CANCEL_STOPS_WHOLE_RUN : CANCEL_STOPS_WHOLE_RUNS;
|
|
78
|
+
return (`${command} (cancelling ${joined.join(' or ')} ${scope}, ` +
|
|
79
|
+
'which this command joined and did not start)');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* What is true of work a wait let go of: it keeps executing, and billing, on
|
|
83
|
+
* the server. One result is named by its launch (`Run <id>`), or as
|
|
84
|
+
* `Result <id>` when the backend named no launch. Several are counted as
|
|
85
|
+
* tests, since they may all belong to one run, and refs that name only a
|
|
86
|
+
* launch (a run whose results were never listed) as runs.
|
|
87
|
+
*/
|
|
88
|
+
export function stillRunningAndBillingSubject(refs) {
|
|
89
|
+
if (refs.length === 1) {
|
|
90
|
+
return `${runLabel(refs[0])} is still executing on the server and will keep running (and billing) until it finishes.`;
|
|
91
|
+
}
|
|
92
|
+
const tests = refs.filter(ref => idOf(ref.resultId) !== undefined).length;
|
|
93
|
+
const runs = refs.length - tests;
|
|
94
|
+
const counted = [
|
|
95
|
+
...(tests > 0 ? [`${tests} test${tests === 1 ? '' : 's'}`] : []),
|
|
96
|
+
...(runs > 0 ? [runCount(runs)] : []),
|
|
97
|
+
].join(' and ');
|
|
98
|
+
return `${counted} are still executing on the server and will keep running (and billing) until they finish.`;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The two indented lines under a detach message: how to re-attach and how to
|
|
102
|
+
* cancel. Both commands take the launch, so they name each launch once; when
|
|
103
|
+
* the backend named no launch there is nothing to offer and no line is added.
|
|
104
|
+
*/
|
|
105
|
+
export function reattachLines(refs) {
|
|
106
|
+
const wait = waitCommand(refs);
|
|
107
|
+
const cancel = cancelCommand(refs);
|
|
108
|
+
return ((wait ? `\n Re-attach with: ${wait}` : '') + (cancel ? `\n Cancel with: ${cancel}` : ''));
|
|
109
|
+
}
|
|
110
|
+
/** The same two commands as one trailing sentence, or nothing when no launch is known. */
|
|
111
|
+
export function reattachSentence(refs) {
|
|
112
|
+
const wait = waitCommand(refs);
|
|
113
|
+
const cancel = cancelCommand(refs);
|
|
114
|
+
return wait && cancel ? ` Re-attach with: ${wait}, or cancel with: ${cancel}` : '';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* What a wait says when Ctrl-C ends it: only the local wait stopped, the work
|
|
118
|
+
* keeps executing and billing, and these are the commands to re-attach to it
|
|
119
|
+
* or to really stop it.
|
|
120
|
+
*/
|
|
121
|
+
export function interruptDetachMessage(interrupt, refs) {
|
|
122
|
+
return (`Interrupted (${interrupt.signal}). ${stillRunningAndBillingSubject(refs)}` +
|
|
123
|
+
reattachLines(refs));
|
|
124
|
+
}
|
|
125
|
+
/** How many lookups a hint lists before it counts the rest. */
|
|
126
|
+
export const CHECK_LATER_LIMIT = 10;
|
|
127
|
+
/**
|
|
128
|
+
* What a wait that gave up can still point at when no launch is known (so
|
|
129
|
+
* neither `run wait` nor `run cancel` can be offered): one line per piece of
|
|
130
|
+
* work, the first ten, then a count of the rest. A test is looked up by its
|
|
131
|
+
* results; with no test id, or for a result named with `byResult`, the result
|
|
132
|
+
* is looked up itself. No line carries a placeholder. Empty when nothing can
|
|
133
|
+
* be looked up.
|
|
134
|
+
*/
|
|
135
|
+
export function checkLaterHint(lookups) {
|
|
136
|
+
const commands = [];
|
|
137
|
+
for (const lookup of lookups) {
|
|
138
|
+
const testId = idOf(lookup.testId);
|
|
139
|
+
const resultId = idOf(lookup.resultId);
|
|
140
|
+
const command = testId !== undefined && lookup.byResult !== true
|
|
141
|
+
? `testsprite result list --test ${inLine(testId)}`
|
|
142
|
+
: resultId !== undefined
|
|
143
|
+
? `testsprite result get ${inLine(resultId)}`
|
|
144
|
+
: undefined;
|
|
145
|
+
if (command !== undefined && !commands.includes(command))
|
|
146
|
+
commands.push(command);
|
|
147
|
+
}
|
|
148
|
+
const lines = commands
|
|
149
|
+
.slice(0, CHECK_LATER_LIMIT)
|
|
150
|
+
.map(command => `Check the verdict later with: ${command}`);
|
|
151
|
+
if (commands.length > CHECK_LATER_LIMIT) {
|
|
152
|
+
lines.push(`… ${commands.length - CHECK_LATER_LIMIT} more`);
|
|
153
|
+
}
|
|
154
|
+
return lines.join('\n');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* How prose names one result's work: `Run <launch id>` when the launch is
|
|
158
|
+
* known, otherwise `Result <result id>`. A result id is never called a run.
|
|
159
|
+
* With neither id it is just `The run`.
|
|
160
|
+
*/
|
|
161
|
+
export function runLabel(ref, letterCase = 'upper') {
|
|
162
|
+
const launchId = idOf(ref.runId);
|
|
163
|
+
const resultId = idOf(ref.resultId);
|
|
164
|
+
const label = launchId !== undefined
|
|
165
|
+
? `Run ${inLine(launchId)}`
|
|
166
|
+
: resultId !== undefined
|
|
167
|
+
? `Result ${inLine(resultId)}`
|
|
168
|
+
: 'The run';
|
|
169
|
+
return letterCase === 'lower' ? label.charAt(0).toLowerCase() + label.slice(1) : label;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The id of one result's work as a `name: value` note: `resultId: <launch id>`
|
|
173
|
+
* when the launch is known, otherwise `resultId: <result id>`.
|
|
174
|
+
*/
|
|
175
|
+
export function runIdNote(ref) {
|
|
176
|
+
const launchId = idOf(ref.runId);
|
|
177
|
+
const resultId = idOf(ref.resultId);
|
|
178
|
+
return launchId !== undefined
|
|
179
|
+
? `runId: ${inLine(launchId)}`
|
|
180
|
+
: `resultId: ${resultId !== undefined ? inLine(resultId) : '(unknown)'}`;
|
|
181
|
+
}
|
|
182
|
+
export const OLDER_CLI_RESULT_ID_HINT = 'a result id printed by an older CLI is not one. Look a result up with: testsprite result get <result-id>';
|
|
183
|
+
//# sourceMappingURL=run-render.js.map
|