@cnc-tools/storm 0.13.0 → 0.14.1
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/dist/application.js +5 -1
- package/dist/bin/storm.js +6 -2
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-N7E6DAUE.js → chunk-27P2QSIM.js} +1 -1
- package/dist/chunks/{chunk-ZDJLKF2G.js → chunk-5ED3IDUJ.js} +7 -4
- package/dist/chunks/{chunk-6EQKA7LI.js → chunk-5TMHYH7G.js} +1 -1
- package/dist/chunks/{chunk-AX4EQZUS.js → chunk-BFLYGMG3.js} +12 -7
- package/dist/chunks/{chunk-LQKNI3EG.js → chunk-BRUIATTR.js} +6 -6
- package/dist/chunks/{chunk-DOFB2ACU.js → chunk-HOKDKP5A.js} +1 -1
- package/dist/chunks/{chunk-EGNP3S6C.js → chunk-IVRRGGCD.js} +60 -20
- package/dist/chunks/{chunk-RTILVSYQ.js → chunk-QBR5VHJ7.js} +1 -1
- package/dist/chunks/{chunk-YT5OROR7.js → chunk-RA4L2ACU.js} +12 -2
- package/dist/chunks/{chunk-YGS5VRQT.js → chunk-RKONDLPS.js} +8 -5
- package/dist/chunks/{chunk-IYM44FUX.js → chunk-UC6DULWY.js} +2 -2
- package/dist/chunks/{chunk-2NZXL6OH.js → chunk-XPCUINWS.js} +1 -1
- package/dist/chunks/{chunk-Q4TKRILH.js → chunk-YBPTMJUM.js} +98 -21
- package/dist/chunks/{chunk-5UMJNVKT.js → chunk-Z5OXOZD3.js} +125 -83
- package/dist/chunks/{chunk-X4WBJIOF.js → chunk-ZH5R7W4A.js} +1 -1
- package/dist/chunks/{live-app-QFHS54SX.js → live-app-FBVWUUMT.js} +7 -7
- package/dist/commands/exec/command.d.ts +2 -0
- package/dist/commands/exec/command.js +15 -41
- package/dist/commands/exec/define-run-command.d.ts +17 -10
- package/dist/commands/exec/define-run-command.js +48 -15
- package/dist/commands/exec/driver-plan.d.ts +24 -16
- package/dist/commands/exec/driver-plan.js +34 -15
- package/dist/commands/exec/driver-refusals.js +7 -6
- package/dist/commands/exec/exec-words.d.ts +1 -1
- package/dist/commands/exec/exec-words.js +8 -2
- package/dist/commands/exec/final-results.d.ts +39 -0
- package/dist/commands/exec/final-results.js +29 -0
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +13 -3
- package/dist/commands/exec/outcomes.js +21 -4
- package/dist/commands/exec/plan-run.d.ts +11 -3
- package/dist/commands/exec/plan-run.js +3 -2
- package/dist/commands/exec/run-command.d.ts +1 -1
- package/dist/commands/exec/run-command.js +27 -5
- package/dist/commands/exec/test-plan.d.ts +2 -1
- package/dist/commands/exec/test-plan.js +13 -4
- package/dist/commands/exec/tests-summary.d.ts +2 -2
- package/dist/commands/exec/worker-chart.d.ts +1 -1
- package/dist/commands/playwright/command.d.ts +10 -7
- package/dist/commands/playwright/command.js +14 -14
- package/dist/commands/playwright/metadata.js +2 -2
- package/dist/commands/runs/list/command.js +6 -6
- package/dist/commands/runs/logs/command.js +6 -6
- package/dist/commands/runs/show/command.d.ts +2 -2
- package/dist/commands/runs/show/command.js +11 -11
- package/dist/commands/runs/show/outcomes.d.ts +1 -1
- package/dist/commands/snapshots/build/command.js +12 -12
- package/dist/commands/snapshots/list/command.js +9 -9
- package/dist/commands/vitest/command.d.ts +12 -8
- package/dist/commands/vitest/command.js +14 -14
- package/dist/commands/vitest/metadata.js +2 -2
- package/dist/config/resolve.d.ts +1 -1
- package/dist/config/resolve.js +2 -1
- package/dist/config/schema.d.ts +8 -0
- package/dist/config/schema.js +5 -4
- package/dist/extensions/playwright/driver.js +17 -10
- package/dist/extensions/testserver/commands/pool/create/command.js +4 -4
- package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
- package/dist/extensions/testserver/definition.d.ts +1 -1
- package/dist/extensions/testserver/extension.d.ts +1 -1
- package/dist/extensions/testserver/options/rules.d.ts +3 -3
- package/dist/extensions/testserver/options/rules.js +5 -5
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/vercel-cli/arguments.d.ts +10 -4
- package/dist/extensions/testserver/vercel-cli/arguments.js +17 -6
- package/dist/extensions/testserver/vercel-cli/environment.d.ts +12 -1
- package/dist/extensions/testserver/vercel-cli/environment.js +35 -5
- package/dist/extensions/testserver/vercel-cli/index.d.ts +1 -0
- package/dist/extensions/testserver/vercel-cli/index.js +1 -0
- package/dist/extensions/testserver/vercel-cli/invoker.d.ts +28 -13
- package/dist/extensions/testserver/vercel-cli/invoker.js +81 -67
- package/dist/extensions/testserver/vercel-cli/live/process-gateway.js +4 -10
- package/dist/extensions/testserver/vercel-cli/report.js +5 -2
- package/dist/extensions/testserver/vercel-cli/session-id.d.ts +8 -0
- package/dist/extensions/testserver/vercel-cli/session-id.js +17 -0
- package/dist/extensions/testserver/vitest/config.d.ts +2 -2
- package/dist/extensions/testserver/vitest/config.js +2 -2
- package/dist/extensions/testserver/vitest/container-scope.d.ts +25 -16
- package/dist/extensions/testserver/vitest/container-scope.js +32 -13
- package/dist/extensions/testserver/vitest/diagnostics.d.ts +14 -12
- package/dist/extensions/testserver/vitest/diagnostics.js +29 -21
- package/dist/extensions/testserver/vitest/fixtures.d.ts +14 -1
- package/dist/extensions/testserver/vitest/fixtures.js +41 -12
- package/dist/extensions/testserver/vitest/types.d.ts +16 -0
- package/dist/extensions/vitest/driver.js +28 -14
- package/dist/extensions/vitest/plan/gateways.d.ts +28 -5
- package/dist/extensions/vitest/plan/gateways.js +2 -2
- package/dist/extensions/vitest/plan/list-output.d.ts +5 -0
- package/dist/extensions/vitest/plan/list-output.js +23 -9
- package/dist/extensions/vitest/plan/live/list-gateway.d.ts +3 -2
- package/dist/extensions/vitest/plan/live/list-gateway.js +77 -64
- package/dist/extensions/vitest/plan/plan-over.d.ts +19 -7
- package/dist/extensions/vitest/plan/plan-over.js +18 -7
- package/dist/extensions/vitest/plan/plan.d.ts +14 -5
- package/dist/extensions/vitest/plan/plan.js +23 -9
- package/dist/extensions.d.ts +2 -2
- package/dist/run-directory/plan.d.ts +3 -2
- package/dist/run-directory/plan.js +6 -3
- package/dist/run-directory/run-record.d.ts +4 -3
- package/dist/runner/recipe.d.ts +5 -1
- package/dist/runner/sandboxed-command.d.ts +5 -3
- package/dist/runner/sandboxed-command.js +10 -4
- package/dist/sdk/extension/driver.d.ts +32 -6
- package/dist/sdk/extension/driver.js +12 -2
- package/dist/sdk/extension/index.d.ts +1 -1
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +6 -5
- package/dist/vendor/testserver-sdk/container/api-request.d.ts +2 -3
- package/dist/vendor/testserver-sdk/container/api-request.js +2 -3
- package/dist/vendor/testserver-sdk/container/container.d.ts +12 -2
- package/dist/vendor/testserver-sdk/container/container.js +10 -7
- package/dist/vendor/testserver-sdk/container/recorder.d.ts +29 -7
- package/dist/vendor/testserver-sdk/container/recorder.js +26 -14
- package/dist/vendor/testserver-sdk/index.d.ts +1 -1
- package/dist/vendor/testserver-sdk/index.js +1 -1
- package/dist/vendor/testserver-sdk/proxy/exchange.d.ts +24 -5
- package/dist/vendor/testserver-sdk/proxy/exchange.js +43 -25
- package/dist/vendor/testserver-sdk/proxy/faulted-exchange.js +15 -10
- package/dist/vendor/testserver-sdk/proxy/faults.d.ts +6 -5
- package/dist/vendor/testserver-sdk/proxy/proxy.d.ts +10 -1
- package/dist/vendor/testserver-sdk/proxy/proxy.js +5 -3
- package/dist/vendor/testserver-sdk/proxy/records.d.ts +17 -17
- package/dist/vendor/testserver-sdk/proxy/records.js +18 -17
- package/dist/vendor/testserver-sdk/records/body.d.ts +7 -9
- package/dist/vendor/testserver-sdk/records/body.js +10 -15
- package/dist/vendor/testserver-sdk/records/headers.d.ts +79 -0
- package/dist/vendor/testserver-sdk/records/headers.js +162 -0
- package/dist/vendor/testserver-sdk/records/index.d.ts +2 -1
- package/dist/vendor/testserver-sdk/records/index.js +4 -2
- package/dist/vendor/testserver-sdk/records/records.d.ts +19 -10
- package/package.json +5 -4
- package/skills/overview.md +5 -5
- package/skills/testserver-builds.md +0 -82
|
@@ -1,72 +1,85 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import { readVitestList } from "../list-output.js";
|
|
2
|
+
import { readVitestFileList, readVitestList } from "../list-output.js";
|
|
3
3
|
/**
|
|
4
|
-
* The live list gateway. `listTests` spawns `vitest list <args> --json
|
|
5
|
-
* `vitest` from `PATH`, no shell, in `cwd`, with stdin
|
|
4
|
+
* The live list gateway. `listTests` spawns `vitest list <args> --json`, and `listFiles` `vitest list <args>
|
|
5
|
+
* --filesOnly --json` (`listArgv`), the request's `executable` or `vitest` from `PATH`, no shell, in `cwd`, with stdin
|
|
6
|
+
* ignored. It sends SIGTERM after `timeoutMs`
|
|
6
7
|
* (`AbortSignal.timeout`), or once the request's `signal` aborts, then waits for the process to exit and answers
|
|
7
8
|
* `timed-out` or `canceled`, `canceled` when the request's `signal` aborted. It waits for the exit, not for the pipes
|
|
8
9
|
* to close, since a process `vitest` left behind could hold them open. Any other `error` is a start failure, answered
|
|
9
10
|
* at once, since no process started.
|
|
10
11
|
*/
|
|
11
12
|
export const liveVitestListGateway = {
|
|
12
|
-
listTests(request) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
resolve(result);
|
|
20
|
-
};
|
|
21
|
-
const timeout = AbortSignal.timeout(request.timeoutMs);
|
|
22
|
-
const child = spawn(request.executable ?? "vitest", listArgv(request.args), {
|
|
23
|
-
...(request.cwd === undefined ? {} : { cwd: request.cwd }),
|
|
24
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
25
|
-
signal: request.signal === undefined ? timeout : AbortSignal.any([timeout, request.signal]),
|
|
26
|
-
});
|
|
27
|
-
// Why the listing was stopped, once the abort killed the process: answered when it has exited.
|
|
28
|
-
let stopped;
|
|
29
|
-
let stdout = "";
|
|
30
|
-
let stderr = "";
|
|
31
|
-
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
32
|
-
stdout += chunk;
|
|
33
|
-
});
|
|
34
|
-
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
35
|
-
stderr += chunk;
|
|
36
|
-
});
|
|
37
|
-
child.on("error", (error) => {
|
|
38
|
-
if (error.name !== "AbortError") {
|
|
39
|
-
settle({ ok: false, failure: { kind: "start-failed", message: error.message } });
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
stopped =
|
|
43
|
-
request.signal?.aborted === true ? { kind: "canceled" } : { kind: "timed-out", timeoutMs: request.timeoutMs };
|
|
44
|
-
if (child.exitCode !== null || child.signalCode !== null)
|
|
45
|
-
settle({ ok: false, failure: stopped });
|
|
46
|
-
});
|
|
47
|
-
child.on("exit", () => {
|
|
48
|
-
if (stopped !== undefined)
|
|
49
|
-
settle({ ok: false, failure: stopped });
|
|
50
|
-
});
|
|
51
|
-
child.on("close", (exitCode, signal) => {
|
|
52
|
-
if (stopped !== undefined) {
|
|
53
|
-
settle({ ok: false, failure: stopped });
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (exitCode !== 0) {
|
|
57
|
-
settle({ ok: false, failure: { kind: "exited", exitCode, signal, lastStderrLine: lastLine(stderr) } });
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
settle({ ok: true, tests: readVitestList(stdout) });
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
settle({ ok: false, failure: { kind: "unreadable-output", message: error.message } });
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
13
|
+
async listTests(request) {
|
|
14
|
+
const listed = await runList(request, ["--json"], readVitestList);
|
|
15
|
+
return listed.ok ? { ok: true, tests: listed.value } : listed;
|
|
16
|
+
},
|
|
17
|
+
async listFiles(request) {
|
|
18
|
+
const listed = await runList(request, ["--filesOnly", "--json"], readVitestFileList);
|
|
19
|
+
return listed.ok ? { ok: true, files: listed.value } : listed;
|
|
68
20
|
},
|
|
69
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Runs `vitest list <args> <flags>` for `request` and reads its stdout with `read`, which throws when the output isn't
|
|
24
|
+
* what it reads: `unreadable-output`.
|
|
25
|
+
*/
|
|
26
|
+
function runList(request, flags, read) {
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
let settled = false;
|
|
29
|
+
const settle = (result) => {
|
|
30
|
+
if (settled)
|
|
31
|
+
return;
|
|
32
|
+
settled = true;
|
|
33
|
+
resolve(result);
|
|
34
|
+
};
|
|
35
|
+
const timeout = AbortSignal.timeout(request.timeoutMs);
|
|
36
|
+
const child = spawn(request.executable ?? "vitest", listArgv(request.args, flags), {
|
|
37
|
+
...(request.cwd === undefined ? {} : { cwd: request.cwd }),
|
|
38
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
39
|
+
signal: request.signal === undefined ? timeout : AbortSignal.any([timeout, request.signal]),
|
|
40
|
+
});
|
|
41
|
+
// Why the listing was stopped, once the abort killed the process: answered when it has exited.
|
|
42
|
+
let stopped;
|
|
43
|
+
let stdout = "";
|
|
44
|
+
let stderr = "";
|
|
45
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
46
|
+
stdout += chunk;
|
|
47
|
+
});
|
|
48
|
+
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
49
|
+
stderr += chunk;
|
|
50
|
+
});
|
|
51
|
+
child.on("error", (error) => {
|
|
52
|
+
if (error.name !== "AbortError") {
|
|
53
|
+
settle({ ok: false, failure: { kind: "start-failed", message: error.message } });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
stopped =
|
|
57
|
+
request.signal?.aborted === true ? { kind: "canceled" } : { kind: "timed-out", timeoutMs: request.timeoutMs };
|
|
58
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
59
|
+
settle({ ok: false, failure: stopped });
|
|
60
|
+
});
|
|
61
|
+
child.on("exit", () => {
|
|
62
|
+
if (stopped !== undefined)
|
|
63
|
+
settle({ ok: false, failure: stopped });
|
|
64
|
+
});
|
|
65
|
+
child.on("close", (exitCode, signal) => {
|
|
66
|
+
if (stopped !== undefined) {
|
|
67
|
+
settle({ ok: false, failure: stopped });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (exitCode !== 0) {
|
|
71
|
+
settle({ ok: false, failure: { kind: "exited", exitCode, signal, lastStderrLine: lastLine(stderr) } });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
settle({ ok: true, value: read(stdout) });
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
settle({ ok: false, failure: { kind: "unreadable-output", message: error.message } });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
70
83
|
/**
|
|
71
84
|
* The last line of `text` that is neither blank nor a stack frame (`at …`), trimmed, so an error's stack leaves its
|
|
72
85
|
* message; empty when there is none.
|
|
@@ -78,11 +91,11 @@ function lastLine(text) {
|
|
|
78
91
|
.findLast((line) => line !== "" && !/^at\s/.test(line)) ?? "");
|
|
79
92
|
}
|
|
80
93
|
/**
|
|
81
|
-
* `vitest list`'s arguments: `args`, with `--json` after them but before a `--`
|
|
82
|
-
* optional path, so `vitest list --json test/a.test.ts` would write the list
|
|
83
|
-
* arguments, it takes none, and the list goes to stdout.
|
|
94
|
+
* `vitest list`'s arguments: `args`, with `flags` (`--json`, or `--filesOnly --json`) after them but before a `--`
|
|
95
|
+
* among them. vitest's `--json` takes an optional path, so `vitest list --json test/a.test.ts` would write the list
|
|
96
|
+
* over `test/a.test.ts`; after the arguments, it takes none, and the list goes to stdout.
|
|
84
97
|
*/
|
|
85
|
-
function listArgv(args) {
|
|
98
|
+
function listArgv(args, flags) {
|
|
86
99
|
const end = args.indexOf("--");
|
|
87
|
-
return end === -1 ? ["list", ...args,
|
|
100
|
+
return end === -1 ? ["list", ...args, ...flags] : ["list", ...args.slice(0, end), ...flags, ...args.slice(end)];
|
|
88
101
|
}
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import type { ListedTest, VitestListFailure, VitestListGateway } from "./gateways.ts";
|
|
2
2
|
/** How long `vitest list` may run by default. */
|
|
3
3
|
export declare const LIST_TIMEOUT_MS = 60000;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* How many test files a Vitest run would run, and how many tests in them when they were counted (`countTests`); no
|
|
6
|
+
* `tests` when only the files were.
|
|
7
|
+
*/
|
|
5
8
|
export interface TestPlan {
|
|
6
|
-
readonly tests
|
|
9
|
+
readonly tests?: number;
|
|
7
10
|
readonly files: number;
|
|
8
11
|
}
|
|
9
12
|
export interface ListVitestTestsOptions {
|
|
10
|
-
/** Passed to `vitest list
|
|
13
|
+
/** Passed to `vitest list`, as `vitest run` takes them, such as `["--project", "e2e"]`. */
|
|
11
14
|
readonly args: readonly string[];
|
|
12
15
|
/** Where vitest runs; default the current directory. */
|
|
13
16
|
readonly cwd?: string;
|
|
14
17
|
/** The `vitest` to start, such as the path of a `node_modules/.bin/vitest`; default `vitest` from `PATH`. */
|
|
15
18
|
readonly executable?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to count each test too, with `vitest list <args> --json`, which imports every test file to collect its
|
|
21
|
+
* tests and applies a `-t`. By default it counts only the files, with `vitest list <args> --filesOnly --json`, which
|
|
22
|
+
* imports no test file and applies no `-t`.
|
|
23
|
+
*/
|
|
24
|
+
readonly countTests?: boolean;
|
|
16
25
|
/** How long `vitest list` may take; default `LIST_TIMEOUT_MS`, 60s. */
|
|
17
26
|
readonly timeoutMs?: number;
|
|
18
27
|
/** Stops `vitest list` when it aborts: the plan's failure is then `canceled`. */
|
|
19
28
|
readonly signal?: AbortSignal;
|
|
20
29
|
}
|
|
21
|
-
/** A Vitest run's test plan, or why its tests couldn't be listed. */
|
|
30
|
+
/** A Vitest run's test plan, or why its tests or files couldn't be listed. */
|
|
22
31
|
export type VitestPlanResult = {
|
|
23
32
|
readonly ok: true;
|
|
24
33
|
readonly plan: TestPlan;
|
|
@@ -27,12 +36,15 @@ export type VitestPlanResult = {
|
|
|
27
36
|
readonly failure: VitestListFailure;
|
|
28
37
|
};
|
|
29
38
|
/**
|
|
30
|
-
* Lists the
|
|
31
|
-
* `vitest` from `PATH`),
|
|
39
|
+
* Lists the test files `vitest run <args>` would run over `gateway`, with `vitest list <args> --filesOnly --json`
|
|
40
|
+
* (`executable`, else `vitest` from `PATH`), or its tests with `vitest list <args> --json` when `countTests` is set,
|
|
41
|
+
* and counts them; or says why it couldn't: `vitest` failed to start, didn't finish within
|
|
32
42
|
* `timeoutMs`, exited other than 0 (with the last line of its stderr that isn't a stack frame), printed something other
|
|
33
|
-
* than a list of tests, or was stopped by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive
|
|
43
|
+
* than a list of tests or files, or was stopped by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive
|
|
34
44
|
* number.
|
|
35
45
|
*/
|
|
36
46
|
export declare function planVitestRunOver(options: ListVitestTestsOptions, gateway: VitestListGateway): Promise<VitestPlanResult>;
|
|
37
47
|
/** The plan of the tests listed: how many, and in how many distinct files. */
|
|
38
48
|
export declare function planOf(tests: readonly ListedTest[]): TestPlan;
|
|
49
|
+
/** The plan of the files listed: how many distinct files, and no number of tests. */
|
|
50
|
+
export declare function planOfFiles(files: readonly string[]): TestPlan;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
// Planning a Vitest run over a given list gateway: counting the
|
|
1
|
+
// Planning a Vitest run over a given list gateway: counting the test files `vitest run <args>` would run, and its tests
|
|
2
|
+
// when asked. storm's Vitest
|
|
2
3
|
// driver (`../driver.ts`) plans with it over its Context's gateway, and tests plan with it over the fake. The published
|
|
3
4
|
// `plan.ts` plans with it over the live gateway, and this file is not a published export, so a consumer of
|
|
4
5
|
// `@vercel/storm/vitest/plan` sees no gateway. It imports no vitest and nothing of storm outside this folder.
|
|
5
6
|
/** How long `vitest list` may run by default. */
|
|
6
7
|
export const LIST_TIMEOUT_MS = 60_000;
|
|
7
8
|
/**
|
|
8
|
-
* Lists the
|
|
9
|
-
* `vitest` from `PATH`),
|
|
9
|
+
* Lists the test files `vitest run <args>` would run over `gateway`, with `vitest list <args> --filesOnly --json`
|
|
10
|
+
* (`executable`, else `vitest` from `PATH`), or its tests with `vitest list <args> --json` when `countTests` is set,
|
|
11
|
+
* and counts them; or says why it couldn't: `vitest` failed to start, didn't finish within
|
|
10
12
|
* `timeoutMs`, exited other than 0 (with the last line of its stderr that isn't a stack frame), printed something other
|
|
11
|
-
* than a list of tests, or was stopped by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive
|
|
13
|
+
* than a list of tests or files, or was stopped by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive
|
|
12
14
|
* number.
|
|
13
15
|
*/
|
|
14
16
|
export async function planVitestRunOver(options, gateway) {
|
|
@@ -16,16 +18,25 @@ export async function planVitestRunOver(options, gateway) {
|
|
|
16
18
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
17
19
|
throw new TypeError(`planVitestRun: timeoutMs is ${String(timeoutMs)}, not a positive number`);
|
|
18
20
|
}
|
|
19
|
-
const
|
|
21
|
+
const request = {
|
|
20
22
|
args: options.args,
|
|
21
23
|
...(options.cwd === undefined ? {} : { cwd: options.cwd }),
|
|
22
24
|
...(options.executable === undefined ? {} : { executable: options.executable }),
|
|
23
25
|
timeoutMs,
|
|
24
26
|
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
+
};
|
|
28
|
+
if (options.countTests === true) {
|
|
29
|
+
const listed = await gateway.listTests(request);
|
|
30
|
+
return listed.ok ? { ok: true, plan: planOf(listed.tests) } : { ok: false, failure: listed.failure };
|
|
31
|
+
}
|
|
32
|
+
const listed = await gateway.listFiles(request);
|
|
33
|
+
return listed.ok ? { ok: true, plan: planOfFiles(listed.files) } : { ok: false, failure: listed.failure };
|
|
27
34
|
}
|
|
28
35
|
/** The plan of the tests listed: how many, and in how many distinct files. */
|
|
29
36
|
export function planOf(tests) {
|
|
30
37
|
return { tests: tests.length, files: new Set(tests.map((test) => test.file)).size };
|
|
31
38
|
}
|
|
39
|
+
/** The plan of the files listed: how many distinct files, and no number of tests. */
|
|
40
|
+
export function planOfFiles(files) {
|
|
41
|
+
return { files: new Set(files).size };
|
|
42
|
+
}
|
|
@@ -3,10 +3,11 @@ import { type ListVitestTestsOptions, type TestPlan, type VitestPlanResult } fro
|
|
|
3
3
|
export type { ListedTest, VitestListFailure } from "./gateways.ts";
|
|
4
4
|
export { LIST_TIMEOUT_MS, type ListVitestTestsOptions, type TestPlan, type VitestPlanResult } from "./plan-over.ts";
|
|
5
5
|
/**
|
|
6
|
-
* Lists the
|
|
7
|
-
* `PATH`),
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Lists the test files `vitest run <args>` would run, with `vitest list <args> --filesOnly --json` (`executable`, else
|
|
7
|
+
* `vitest` from `PATH`), or its tests with `vitest list <args> --json` when `countTests` is set, and counts them; or
|
|
8
|
+
* says why it couldn't: `vitest` failed to start, didn't finish within `timeoutMs`, exited other than 0 (with the last
|
|
9
|
+
* line of its stderr that isn't a stack frame), printed something other than a list of tests or files, or was stopped
|
|
10
|
+
* by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive number.
|
|
10
11
|
*/
|
|
11
12
|
export declare function planVitestRun(options: ListVitestTestsOptions): Promise<VitestPlanResult>;
|
|
12
13
|
/**
|
|
@@ -18,7 +19,15 @@ export declare function listVitestTests(options: ListVitestTestsOptions): Promis
|
|
|
18
19
|
export declare function vitestRunArgv(executable: string, args: readonly string[]): readonly string[];
|
|
19
20
|
/** The plan `vitest list --json` printed: its tests, and their distinct files. Throws when it isn't a list of tests. */
|
|
20
21
|
export declare function parseVitestList(stdout: string): TestPlan;
|
|
21
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The plan `vitest list --filesOnly --json` printed: its distinct files, and no number of tests. Throws when it isn't a
|
|
24
|
+
* list of files.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseVitestFileList(stdout: string): TestPlan;
|
|
27
|
+
/**
|
|
28
|
+
* A plan as a phrase, such as `65 tests in 19 files` or `1 test in 1 file`, or `tests in 19 files` for a plan that
|
|
29
|
+
* counted only the files.
|
|
30
|
+
*/
|
|
22
31
|
export declare function formatPlan(plan: TestPlan): string;
|
|
23
32
|
/** Why the tests couldn't be listed, as a sentence. */
|
|
24
33
|
export declare function describeVitestListFailure(failure: VitestListFailure): string;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
// Planning a Vitest run before anything is acquired or started, exported as `@vercel/storm/vitest/plan`: counting the
|
|
2
|
-
//
|
|
2
|
+
// test files `vitest run <args>` would run, or its tests, and the `vitest run` argv. A launcher script that counts the tests itself plans
|
|
3
3
|
// with it. storm's Vitest driver (`../driver.ts`) plans over its own Context instead, with `plan-over.ts`, which this
|
|
4
4
|
// file plans with over the live list gateway. It imports no vitest and nothing of storm outside this folder: the
|
|
5
5
|
// launcher and a launcher script run outside a Vitest run.
|
|
6
|
-
import { readVitestList } from "./list-output.js";
|
|
6
|
+
import { readVitestFileList, readVitestList } from "./list-output.js";
|
|
7
7
|
import { liveVitestListGateway } from "./live/list-gateway.js";
|
|
8
|
-
import { planOf, planVitestRunOver, } from "./plan-over.js";
|
|
8
|
+
import { planOf, planOfFiles, planVitestRunOver, } from "./plan-over.js";
|
|
9
9
|
export { LIST_TIMEOUT_MS } from "./plan-over.js";
|
|
10
10
|
/**
|
|
11
|
-
* Lists the
|
|
12
|
-
* `PATH`),
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Lists the test files `vitest run <args>` would run, with `vitest list <args> --filesOnly --json` (`executable`, else
|
|
12
|
+
* `vitest` from `PATH`), or its tests with `vitest list <args> --json` when `countTests` is set, and counts them; or
|
|
13
|
+
* says why it couldn't: `vitest` failed to start, didn't finish within `timeoutMs`, exited other than 0 (with the last
|
|
14
|
+
* line of its stderr that isn't a stack frame), printed something other than a list of tests or files, or was stopped
|
|
15
|
+
* by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive number.
|
|
15
16
|
*/
|
|
16
17
|
export async function planVitestRun(options) {
|
|
17
18
|
return await planVitestRunOver(options, liveVitestListGateway);
|
|
@@ -34,9 +35,22 @@ export function vitestRunArgv(executable, args) {
|
|
|
34
35
|
export function parseVitestList(stdout) {
|
|
35
36
|
return planOf(readVitestList(stdout));
|
|
36
37
|
}
|
|
37
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* The plan `vitest list --filesOnly --json` printed: its distinct files, and no number of tests. Throws when it isn't a
|
|
40
|
+
* list of files.
|
|
41
|
+
*/
|
|
42
|
+
export function parseVitestFileList(stdout) {
|
|
43
|
+
return planOfFiles(readVitestFileList(stdout));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A plan as a phrase, such as `65 tests in 19 files` or `1 test in 1 file`, or `tests in 19 files` for a plan that
|
|
47
|
+
* counted only the files.
|
|
48
|
+
*/
|
|
38
49
|
export function formatPlan(plan) {
|
|
39
|
-
|
|
50
|
+
const files = `${plan.files} ${plan.files === 1 ? "file" : "files"}`;
|
|
51
|
+
return plan.tests === undefined
|
|
52
|
+
? `tests in ${files}`
|
|
53
|
+
: `${plan.tests} ${plan.tests === 1 ? "test" : "tests"} in ${files}`;
|
|
40
54
|
}
|
|
41
55
|
/** Why the tests couldn't be listed, as a sentence. */
|
|
42
56
|
export function describeVitestListFailure(failure) {
|
package/dist/extensions.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const EXTENSIONS: readonly [import("./sdk/extension/commands.ts")
|
|
|
26
26
|
readonly default: ({ testPlan }: import("./sdk/extension/resource-definition.ts").PlannedRun) => number;
|
|
27
27
|
readonly flag: {
|
|
28
28
|
readonly valueLabel: "N";
|
|
29
|
-
readonly description: "How many Testserver sandboxes the command gets, 1 to 32, overriding resources.testserverPool.sandboxes in storm.config.ts; default 1, or
|
|
29
|
+
readonly description: "How many Testserver sandboxes the command gets, 1 to 32, overriding resources.testserverPool.sandboxes in storm.config.ts; default 1, or one per 4 test files when storm vitest or storm playwright counts them (testPlan in storm.config.ts), at most 8. Gives the run the Testserver pool.";
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
readonly build: {
|
|
@@ -91,7 +91,7 @@ export declare const RESOURCES: readonly [import("./sdk/extension/resource-defin
|
|
|
91
91
|
readonly default: ({ testPlan }: import("./sdk/extension/resource-definition.ts").PlannedRun) => number;
|
|
92
92
|
readonly flag: {
|
|
93
93
|
readonly valueLabel: "N";
|
|
94
|
-
readonly description: "How many Testserver sandboxes the command gets, 1 to 32, overriding resources.testserverPool.sandboxes in storm.config.ts; default 1, or
|
|
94
|
+
readonly description: "How many Testserver sandboxes the command gets, 1 to 32, overriding resources.testserverPool.sandboxes in storm.config.ts; default 1, or one per 4 test files when storm vitest or storm playwright counts them (testPlan in storm.config.ts), at most 8. Gives the run the Testserver pool.";
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
97
|
readonly build: {
|
|
@@ -15,7 +15,7 @@ declare const planOptionSchema: z.ZodObject<{
|
|
|
15
15
|
export type PlanOption = Readonly<z.output<typeof planOptionSchema>>;
|
|
16
16
|
/** A run's test plan, as `vitest`'s and `playwright`'s `ran` outcomes, `run.json` and `runs show` hold it. */
|
|
17
17
|
export declare const planSchema: z.ZodObject<{
|
|
18
|
-
tests: z.ZodNumber
|
|
18
|
+
tests: z.ZodOptional<z.ZodNumber>;
|
|
19
19
|
files: z.ZodNumber;
|
|
20
20
|
options: z.ZodArray<z.ZodObject<{
|
|
21
21
|
path: z.ZodString;
|
|
@@ -28,7 +28,8 @@ export declare const planSchema: z.ZodObject<{
|
|
|
28
28
|
}, z.core.$strip>>;
|
|
29
29
|
}, z.core.$strip>;
|
|
30
30
|
/**
|
|
31
|
-
* A run's test plan: how many
|
|
31
|
+
* A run's test plan: how many test files `vitest list` or `playwright test --list` counted, how many tests in them
|
|
32
|
+
* when it counted those too, and each
|
|
32
33
|
* resource option whose default is a function of the planned run, with its value and where that came from.
|
|
33
34
|
*/
|
|
34
35
|
export type TestPlanFacts = Readonly<z.output<typeof planSchema>>;
|
|
@@ -12,9 +12,12 @@ const planOptionSchema = z.object({
|
|
|
12
12
|
});
|
|
13
13
|
/** A run's test plan, as `vitest`'s and `playwright`'s `ran` outcomes, `run.json` and `runs show` hold it. */
|
|
14
14
|
export const planSchema = z.object({
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* How many tests `vitest list <args> --json` or `playwright test <args> --list` counted; absent when the run counted
|
|
17
|
+
* only the test files, as `storm vitest` does without `--count-tests`.
|
|
18
|
+
*/
|
|
19
|
+
tests: z.number().int().nonnegative().optional(),
|
|
20
|
+
/** How many distinct test files the run counted. */
|
|
18
21
|
files: z.number().int().nonnegative(),
|
|
19
22
|
/**
|
|
20
23
|
* Each resource option whose default is a function of the test plan, with its value and where that came from; empty
|
|
@@ -104,8 +104,9 @@ declare const gitSchema: z.ZodObject<{
|
|
|
104
104
|
*/
|
|
105
105
|
export type RunRecordGit = Readonly<z.output<typeof gitSchema>>;
|
|
106
106
|
/**
|
|
107
|
-
* A `storm vitest` run's test plan: how many
|
|
108
|
-
* whose default is a function of the planned run, with its value and
|
|
107
|
+
* A `storm vitest` or `storm playwright` run's test plan: how many test files it counted, how many tests in them when
|
|
108
|
+
* it counted those too, and each resource option whose default is a function of the planned run, with its value and
|
|
109
|
+
* where that came from (`plan.ts`).
|
|
109
110
|
*/
|
|
110
111
|
export type RunRecordPlan = TestPlanFacts;
|
|
111
112
|
declare const runRecordSchema: z.ZodObject<{
|
|
@@ -115,7 +116,7 @@ declare const runRecordSchema: z.ZodObject<{
|
|
|
115
116
|
configFile: z.ZodNullable<z.ZodString>;
|
|
116
117
|
argv: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
117
118
|
plan: z.ZodExactOptional<z.ZodObject<{
|
|
118
|
-
tests: z.ZodNumber
|
|
119
|
+
tests: z.ZodOptional<z.ZodNumber>;
|
|
119
120
|
files: z.ZodNumber;
|
|
120
121
|
options: z.ZodArray<z.ZodObject<{
|
|
121
122
|
path: z.ZodString;
|
package/dist/runner/recipe.d.ts
CHANGED
|
@@ -52,7 +52,11 @@ export interface RunnerRecipe<Run = never> {
|
|
|
52
52
|
readonly cwd?: string;
|
|
53
53
|
/** The runner sandbox's vCPUs, or a function of the run that returns them. */
|
|
54
54
|
readonly vcpus: number | ((run: Run) => number);
|
|
55
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Extra environment variables for the command. It can't set `STORM_RUN`. When it sets neither `FORCE_COLOR` nor
|
|
57
|
+
* `NO_COLOR`, storm sets `FORCE_COLOR=1` when the local terminal shows color, else `NO_COLOR=1`; when it sets
|
|
58
|
+
* either, storm sets neither, so `{ FORCE_COLOR: "1" }` gets color and no `NO_COLOR`.
|
|
59
|
+
*/
|
|
56
60
|
readonly env?: Readonly<Record<string, string>>;
|
|
57
61
|
/**
|
|
58
62
|
* The runner secrets: names of environment variables storm reads on this machine as the run starts, before it mints,
|
|
@@ -16,9 +16,11 @@ export declare function sandboxedCommand(request: {
|
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* What the command's environment adds to the runner sandbox's own: `PATH` with the sandbox `cwd`'s and the
|
|
19
|
-
* repository's `node_modules/.bin` before the login shell's, no update checks,
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* repository's `node_modules/.bin` before the login shell's, no update checks, the recipe's `env`, and `STORM_RUN`
|
|
20
|
+
* last, so nothing overrides it. When the recipe's `env` sets neither `FORCE_COLOR` nor `NO_COLOR`, it also gets
|
|
21
|
+
* `FORCE_COLOR=1` when the local terminal shows color, else `NO_COLOR=1`, as a run with no runner does
|
|
22
|
+
* (`colorEnvironment` in `core/payload.ts`); a recipe that sets either gets neither from storm. Nothing comes from
|
|
23
|
+
* the local environment.
|
|
22
24
|
*/
|
|
23
25
|
export declare function sandboxEnvironment(request: {
|
|
24
26
|
readonly cwd: string;
|
|
@@ -16,9 +16,11 @@ export function sandboxedCommand(request) {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* What the command's environment adds to the runner sandbox's own: `PATH` with the sandbox `cwd`'s and the
|
|
19
|
-
* repository's `node_modules/.bin` before the login shell's, no update checks,
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* repository's `node_modules/.bin` before the login shell's, no update checks, the recipe's `env`, and `STORM_RUN`
|
|
20
|
+
* last, so nothing overrides it. When the recipe's `env` sets neither `FORCE_COLOR` nor `NO_COLOR`, it also gets
|
|
21
|
+
* `FORCE_COLOR=1` when the local terminal shows color, else `NO_COLOR=1`, as a run with no runner does
|
|
22
|
+
* (`colorEnvironment` in `core/payload.ts`); a recipe that sets either gets neither from storm. Nothing comes from
|
|
23
|
+
* the local environment.
|
|
22
24
|
*/
|
|
23
25
|
export function sandboxEnvironment(request) {
|
|
24
26
|
const bins = [
|
|
@@ -27,7 +29,11 @@ export function sandboxEnvironment(request) {
|
|
|
27
29
|
return {
|
|
28
30
|
PATH: [...bins, request.loginPath].filter((part) => part !== "").join(":"),
|
|
29
31
|
NO_UPDATE_NOTIFIER: "1",
|
|
30
|
-
...(request.
|
|
32
|
+
...(request.env["FORCE_COLOR"] !== undefined || request.env["NO_COLOR"] !== undefined
|
|
33
|
+
? {}
|
|
34
|
+
: request.color
|
|
35
|
+
? { FORCE_COLOR: "1" }
|
|
36
|
+
: { NO_COLOR: "1" }),
|
|
31
37
|
...request.env,
|
|
32
38
|
[RUN_PAYLOAD_VARIABLE]: request.runPayload,
|
|
33
39
|
};
|
|
@@ -16,13 +16,27 @@ export interface DriverHelp {
|
|
|
16
16
|
readonly description: string;
|
|
17
17
|
}[];
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* A driver whose plan step counts only the test files by default: `--count-tests`'s help, in words that name the
|
|
21
|
+
* driver's program, which say what counting each test costs and what counting only the files gives up.
|
|
22
|
+
*/
|
|
23
|
+
export interface DriverTestCount {
|
|
24
|
+
readonly description: string;
|
|
25
|
+
}
|
|
26
|
+
/** What a run says to do next, in words that name the driver's program. */
|
|
20
27
|
export interface DriverHints {
|
|
21
28
|
/**
|
|
22
29
|
* What to do about a run whose tests reported no final result, such as how to list storm's reporter in the program's
|
|
23
30
|
* config. The summary's tests line says it after `no final test results: `.
|
|
24
31
|
*/
|
|
25
32
|
readonly noFinalResults: string;
|
|
33
|
+
/**
|
|
34
|
+
* The steps that make the program report each test's final result to storm, one sentence or more apiece, which
|
|
35
|
+
* the `no_final_test_results` warning lists as its next steps: a run whose program exited 0 and reported none warns it. Each
|
|
36
|
+
* step names the file to change and the exact code to put there, so an agent can follow it without reading storm's
|
|
37
|
+
* docs. At most two: text output shows only an error's first two next steps.
|
|
38
|
+
*/
|
|
39
|
+
readonly addReporter: readonly string[];
|
|
26
40
|
}
|
|
27
41
|
/** What a driver's plan step works from. */
|
|
28
42
|
export interface DriverPlanRequest {
|
|
@@ -32,6 +46,11 @@ export interface DriverPlanRequest {
|
|
|
32
46
|
readonly cwd: string;
|
|
33
47
|
/** The program's binary to start there: the path of the one the launcher found. */
|
|
34
48
|
readonly bin: string;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the plan step counts each test, not only the test files: true when the run took `--count-tests`, and
|
|
51
|
+
* always true for a driver with no `countTests`, whose plan step always counts each test.
|
|
52
|
+
*/
|
|
53
|
+
readonly countTests: boolean;
|
|
35
54
|
/** Aborts once the invocation is signaled: the plan step stops what it started and answers `canceled`. */
|
|
36
55
|
readonly signal: AbortSignal;
|
|
37
56
|
}
|
|
@@ -43,15 +62,15 @@ export declare const DRIVER_PLAN_FAILURE_KINDS: readonly ["start-failed", "timed
|
|
|
43
62
|
*/
|
|
44
63
|
export type DriverPlanFailureKind = (typeof DRIVER_PLAN_FAILURE_KINDS)[number];
|
|
45
64
|
/**
|
|
46
|
-
* What a plan step answers: the test plan, the
|
|
47
|
-
* couldn't say, already worded. `kind` is one of the ways it fails, or `canceled` when the request's signal stopped it,
|
|
65
|
+
* What a plan step answers: the test plan, the test files the program would run and, when it counted them, the tests in
|
|
66
|
+
* them (`tests`, absent when it counted only the files), or why it couldn't say, already worded. `kind` is one of the ways it fails, or `canceled` when the request's signal stopped it,
|
|
48
67
|
* which cancels the run. `message` says what went wrong in the driver's words, with the timeout, the exit code or the
|
|
49
68
|
* signal that ended the program in it; `driver_plan_failed` carries it, and the launcher reads none for `canceled`.
|
|
50
69
|
*/
|
|
51
70
|
export type DriverPlanAnswer = {
|
|
52
71
|
readonly ok: true;
|
|
53
72
|
readonly plan: {
|
|
54
|
-
readonly tests
|
|
73
|
+
readonly tests?: number;
|
|
55
74
|
readonly files: number;
|
|
56
75
|
};
|
|
57
76
|
} | {
|
|
@@ -69,7 +88,7 @@ export interface DriverPlanned {
|
|
|
69
88
|
* `--json-schema` shows.
|
|
70
89
|
*/
|
|
71
90
|
export interface DriverRefusalWords {
|
|
72
|
-
/** `no_matching_tests`: the plan step ran and counted no test. */
|
|
91
|
+
/** `no_matching_tests`: the plan step ran and counted no test, or no test file when it counted only the files. */
|
|
73
92
|
readonly noMatchingTests: {
|
|
74
93
|
readonly description: string;
|
|
75
94
|
/** What went wrong. */
|
|
@@ -100,7 +119,12 @@ export interface DriverRefusalWords {
|
|
|
100
119
|
* - `launch`: the argv that starts the program with `args`, such as `[bin, "run", ...args]`. `bin` is the path of the
|
|
101
120
|
* binary the launcher found, or the program's bare name where the runner's `PATH` finds it.
|
|
102
121
|
* - `plan`: its plan step, over its Context: asks the program what it would run with the request's arguments, without
|
|
103
|
-
* running it, and words its failure. The launcher calls it once, before anything is minted, acquired or started
|
|
122
|
+
* running it, and words its failure. The launcher calls it once, before anything is minted, acquired or started, and
|
|
123
|
+
* only for a run that counts: one whose config file sets `testPlan`, or that took `--count-tests`.
|
|
124
|
+
* - `countTests`: present for a driver whose plan step counts only the test files unless the run asks it to count each
|
|
125
|
+
* test, which is faster for a program that must load each test file to list its tests. Its command then takes
|
|
126
|
+
* `--count-tests`, which sets the plan request's `countTests`, and `description` is that flag's help, in the
|
|
127
|
+
* driver's words. Without it, the plan step always counts each test, and the command takes no such flag.
|
|
104
128
|
* - `help`: its part of its command's leaf help.
|
|
105
129
|
* - `hints`: what its run's summary says to do next.
|
|
106
130
|
* - `refusals`: what its two refusals say, beside the message its plan step answers.
|
|
@@ -113,6 +137,7 @@ export interface DriverSpec<Name extends string, Context> {
|
|
|
113
137
|
readonly context: () => Context;
|
|
114
138
|
readonly launch: (bin: string, args: readonly string[]) => readonly string[];
|
|
115
139
|
readonly plan: (context: NoInfer<Context>) => (request: DriverPlanRequest) => Promise<DriverPlanAnswer>;
|
|
140
|
+
readonly countTests?: DriverTestCount;
|
|
116
141
|
readonly help: DriverHelp;
|
|
117
142
|
readonly hints: DriverHints;
|
|
118
143
|
readonly refusals: DriverRefusalWords;
|
|
@@ -130,6 +155,7 @@ export interface Driver<Name extends string = string, Context = unknown> {
|
|
|
130
155
|
readonly context: () => Context;
|
|
131
156
|
readonly launch: (bin: string, args: readonly string[]) => readonly string[];
|
|
132
157
|
readonly plan: (context: unknown) => (request: DriverPlanRequest) => Promise<DriverPlanAnswer>;
|
|
158
|
+
readonly countTests?: DriverTestCount;
|
|
133
159
|
readonly help: DriverHelp;
|
|
134
160
|
readonly hints: DriverHints;
|
|
135
161
|
readonly refusals: DriverRefusalWords;
|
|
@@ -14,8 +14,18 @@ export const DRIVER_PLAN_FAILURE_KINDS = ["start-failed", "timed-out", "exited",
|
|
|
14
14
|
* from there. The launcher makes its run command from it.
|
|
15
15
|
*/
|
|
16
16
|
export function defineDriver(spec) {
|
|
17
|
-
const { name, program, context, launch, plan, help, hints, refusals } = spec;
|
|
18
|
-
const driver = {
|
|
17
|
+
const { name, program, context, launch, plan, countTests, help, hints, refusals } = spec;
|
|
18
|
+
const driver = {
|
|
19
|
+
name,
|
|
20
|
+
program,
|
|
21
|
+
context,
|
|
22
|
+
launch,
|
|
23
|
+
plan,
|
|
24
|
+
...(countTests === undefined ? {} : { countTests }),
|
|
25
|
+
help,
|
|
26
|
+
hints,
|
|
27
|
+
refusals,
|
|
28
|
+
};
|
|
19
29
|
// The one cast: the launcher's view of the driver's plan step, whose parameter is the driver's Context and which the
|
|
20
30
|
// launcher calls with `unknown`. Only the Context's routing is left for it to rest on: the launcher hands a Context
|
|
21
31
|
// only to the plan step of the driver that built it, by the driver's name (`planDriverCommand`,
|
|
@@ -5,7 +5,7 @@ export type { CredentialFailure, CredentialOrigin, CredentialOutcome, Credential
|
|
|
5
5
|
export { tokenRequestFailureFacts, tokenRequestFailureShape } from "./token-request-facts.ts";
|
|
6
6
|
export type { Clock, Timer } from "./time.ts";
|
|
7
7
|
export { defineResource, type ResourceSpec } from "./resource.ts";
|
|
8
|
-
export { argsText, defineDriver, type Driver, DRIVER_PLAN_FAILURE_KINDS, type DriverHelp, type DriverHints, type DriverPlanAnswer, type DriverPlanFailureKind, type DriverPlanned, type DriverPlanRequest, type DriverRefusalWords, type DriverSpec, } from "./driver.ts";
|
|
8
|
+
export { argsText, defineDriver, type Driver, DRIVER_PLAN_FAILURE_KINDS, type DriverHelp, type DriverHints, type DriverPlanAnswer, type DriverPlanFailureKind, type DriverPlanned, type DriverPlanRequest, type DriverRefusalWords, type DriverSpec, type DriverTestCount, } from "./driver.ts";
|
|
9
9
|
export type { Acquired, AcquireForRunAnswer, AcquireForRunInput, BeforeRunAnswer, BeforeRunInput, LifecycleTypes, MintFailed, NextStep, NoSecrets, Refusal, RefusalContent, ReleaseAfterRunAnswer, ReleaseAfterRunInput, Released, Report, ResourceLifecycle, ResourceUse, ResultAnswer, } from "./lifecycle.ts";
|
|
10
10
|
export type { LauncherContext, StateDirectory } from "./launcher-context.ts";
|
|
11
11
|
export type { LaneDraw, Paint, ResourceNotice } from "./presentation.ts";
|