@cnc-tools/storm 0.5.0 → 0.7.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/dist/build-info.js +1 -1
- package/dist/combine-errors.js +2 -2
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/{run → exec}/cleanup.d.ts +1 -1
- package/dist/commands/{run → exec}/cleanup.js +1 -1
- package/dist/commands/{run/outcomes.d.ts → exec/command.d.ts} +103 -112
- package/dist/commands/exec/command.js +23 -0
- package/dist/commands/{run → exec}/job-summary.d.ts +5 -1
- package/dist/commands/{run → exec}/job-summary.js +5 -2
- package/dist/commands/{run → exec}/live-view.js +29 -13
- package/dist/commands/exec/metadata.d.ts +69 -0
- package/dist/commands/exec/metadata.js +55 -0
- package/dist/commands/{run → exec}/mint-failed.js +4 -4
- package/dist/commands/exec/outcomes.d.ts +664 -0
- package/dist/commands/exec/outcomes.js +347 -0
- package/dist/commands/{run → exec}/progress.d.ts +14 -2
- package/dist/commands/{run → exec}/progress.js +54 -9
- package/dist/commands/exec/run-command.d.ts +227 -0
- package/dist/commands/exec/run-command.js +696 -0
- package/dist/commands/exec/run-metadata.d.ts +59 -0
- package/dist/commands/exec/run-metadata.js +61 -0
- package/dist/commands/{run → exec}/run-record.d.ts +110 -5
- package/dist/commands/{run → exec}/run-record.js +57 -1
- package/dist/commands/exec/testserver-flags.d.ts +48 -0
- package/dist/commands/exec/testserver-flags.js +80 -0
- package/dist/commands/{run → exec}/view.js +36 -4
- package/dist/commands/runs/facts.d.ts +25 -0
- package/dist/commands/runs/facts.js +38 -5
- package/dist/commands/runs/list/command.d.ts +25 -0
- package/dist/commands/runs/list/outcomes.d.ts +25 -0
- package/dist/commands/runs/logs/metadata.js +1 -1
- package/dist/commands/runs/logs/outcomes.js +4 -1
- package/dist/commands/runs/past-run.d.ts +2 -2
- package/dist/commands/runs/past-run.js +2 -2
- package/dist/commands/runs/show/command.d.ts +25 -0
- package/dist/commands/runs/show/metadata.js +2 -2
- package/dist/commands/runs/show/outcomes.d.ts +25 -0
- package/dist/commands/runs/show/outcomes.js +37 -5
- package/dist/commands/vitest/command.d.ts +325 -0
- package/dist/commands/vitest/command.js +138 -0
- package/dist/commands/vitest/metadata.d.ts +69 -0
- package/dist/commands/vitest/metadata.js +35 -0
- package/dist/commands/vitest/outcomes.d.ts +298 -0
- package/dist/commands/vitest/outcomes.js +77 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/config/resolve.d.ts +3 -3
- package/dist/config/resolve.js +3 -3
- package/dist/config/resource-config.d.ts +2 -2
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/set.d.ts +15 -4
- package/dist/config/set.js +28 -12
- package/dist/config-file/define.d.ts +8 -6
- package/dist/context.d.ts +6 -3
- package/dist/context.js +4 -2
- package/dist/core/command-provider.d.ts +1 -1
- package/dist/core/events.d.ts +9 -7
- package/dist/core/presentation.js +1 -1
- package/dist/core/presentations.js +1 -1
- package/dist/core/run-state.d.ts +30 -6
- package/dist/core/run-state.js +19 -4
- package/dist/core/run.d.ts +17 -4
- package/dist/core/run.js +61 -25
- package/dist/resources/testserver/command.d.ts +1 -1
- package/dist/resources/testserver/command.js +1 -1
- package/dist/resources/testserver/config.d.ts +1 -1
- package/dist/resources/testserver/config.js +3 -2
- package/dist/resources/testserver/credential-facts.js +1 -1
- package/dist/resources/testserver/resource.d.ts +2 -2
- package/dist/resources/testserver/sandbox/create.d.ts +2 -2
- package/dist/resources/testserver/sandbox/create.js +2 -2
- package/dist/resources.d.ts +9 -6
- package/dist/resources.js +3 -3
- package/dist/runner/events.d.ts +64 -1
- package/dist/runner/gateways.d.ts +17 -6
- package/dist/runner/index.d.ts +5 -4
- package/dist/runner/index.js +4 -3
- package/dist/runner/live/snapshot-records.js +18 -4
- package/dist/runner/prepare.d.ts +23 -4
- package/dist/runner/prepare.js +13 -3
- package/dist/runner/ready.d.ts +7 -3
- package/dist/runner/ready.js +11 -5
- package/dist/runner/scope.d.ts +17 -1
- package/dist/runner/scope.js +4 -0
- package/dist/runner/snapshot-build.d.ts +3 -1
- package/dist/runner/snapshot-build.js +12 -2
- package/dist/runner/snapshot-cache.d.ts +46 -8
- package/dist/runner/snapshot-cache.js +60 -11
- package/dist/runner/snapshot-key.d.ts +12 -1
- package/dist/runner/snapshot-key.js +17 -1
- package/dist/runner/snapshot-save.d.ts +53 -0
- package/dist/runner/snapshot-save.js +148 -0
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/payload/payload.d.ts +2 -2
- package/dist/sdk/payload/payload.js +2 -2
- package/dist/story/align.d.ts +1 -1
- package/dist/story/align.js +1 -1
- package/dist/story/definition.d.ts +22 -15
- package/dist/story/definition.js +2 -2
- package/dist/story/errors.js +1 -1
- package/dist/story/gateways.d.ts +45 -25
- package/dist/story/gateways.js +2 -2
- package/dist/story/host.d.ts +11 -8
- package/dist/story/host.js +37 -37
- package/dist/story/index.d.ts +1 -1
- package/dist/story/index.js +4 -4
- package/dist/story/json.d.ts +1 -1
- package/dist/story/json.js +2 -2
- package/dist/story/live/recording-gateway.d.ts +2 -0
- package/dist/story/live/{artifact-gateway.js → recording-gateway.js} +33 -12
- package/dist/story/mode.d.ts +2 -2
- package/dist/story/mode.js +1 -1
- package/dist/story/orphans.d.ts +23 -5
- package/dist/story/orphans.js +44 -8
- package/dist/story/recording.d.ts +62 -0
- package/dist/story/{artifact.js → recording.js} +31 -27
- package/dist/story/report.d.ts +21 -9
- package/dist/story/report.js +37 -25
- package/dist/story/settle.d.ts +23 -21
- package/dist/story/settle.js +17 -16
- package/dist/story/{run.d.ts → start.d.ts} +18 -17
- package/dist/story/{run.js → start.js} +66 -43
- package/dist/vercel-cli/driver.d.ts +1 -1
- package/dist/vercel-cli/entry.d.ts +1 -1
- package/dist/vercel-cli/entry.js +1 -1
- package/dist/vercel-cli/verbose.d.ts +2 -2
- package/dist/vercel-cli/verbose.js +2 -2
- package/dist/vitest/config.d.ts +5 -5
- package/dist/vitest/config.js +5 -5
- package/dist/vitest/find-vitest.d.ts +7 -0
- package/dist/vitest/find-vitest.js +28 -0
- package/dist/vitest/fixtures.d.ts +2 -2
- package/dist/vitest/fixtures.js +3 -3
- package/dist/vitest/gateways.d.ts +37 -6
- package/dist/vitest/gateways.js +3 -2
- package/dist/vitest/live/list-gateway.d.ts +7 -3
- package/dist/vitest/live/list-gateway.js +55 -8
- package/dist/vitest/plan.d.ts +41 -8
- package/dist/vitest/plan.js +47 -16
- package/dist/vitest/sandbox.d.ts +1 -1
- package/dist/vitest/sandbox.js +1 -1
- package/dist/vitest/test-events.d.ts +2 -2
- package/dist/vitest/test-events.js +3 -3
- package/dist/vitest/test-results.d.ts +1 -1
- package/dist/vitest/test-results.js +1 -1
- package/dist/vitest/types.d.ts +1 -1
- package/package.json +2 -2
- package/skills/overview.md +5 -4
- package/skills/read-run-output.md +1 -1
- package/dist/commands/run/command.d.ts +0 -327
- package/dist/commands/run/command.js +0 -620
- package/dist/commands/run/metadata.d.ts +0 -47
- package/dist/commands/run/metadata.js +0 -83
- package/dist/commands/run/outcomes.js +0 -332
- package/dist/story/artifact.d.ts +0 -60
- package/dist/story/live/artifact-gateway.d.ts +0 -2
- /package/dist/commands/{run → exec}/live-view.d.ts +0 -0
- /package/dist/commands/{run → exec}/mint-failed.d.ts +0 -0
- /package/dist/commands/{run → exec}/redaction.d.ts +0 -0
- /package/dist/commands/{run → exec}/redaction.js +0 -0
- /package/dist/commands/{run → exec}/run-collector.d.ts +0 -0
- /package/dist/commands/{run → exec}/run-collector.js +0 -0
- /package/dist/commands/{run → exec}/tests-summary.d.ts +0 -0
- /package/dist/commands/{run → exec}/tests-summary.js +0 -0
- /package/dist/commands/{run → exec}/text.d.ts +0 -0
- /package/dist/commands/{run → exec}/text.js +0 -0
- /package/dist/commands/{run → exec}/view.d.ts +0 -0
- /package/dist/commands/{run → exec}/waterfall.d.ts +0 -0
- /package/dist/commands/{run → exec}/waterfall.js +0 -0
- /package/dist/commands/{run → exec}/worker-chart.d.ts +0 -0
- /package/dist/commands/{run → exec}/worker-chart.js +0 -0
|
@@ -4,8 +4,8 @@ import { readRunPayload, RUN_PAYLOAD_VARIABLE, RunPayloadError } from "../sdk/in
|
|
|
4
4
|
import { describeInvocation } from "./report.js";
|
|
5
5
|
/**
|
|
6
6
|
* The listener `vercelCli` uses when the caller passes no `onInvocationEnd`: one that prints each invocation with
|
|
7
|
-
* `describeInvocation` to `print`, when `env`'s run payload says the run is verbose (
|
|
8
|
-
* `undefined` outside
|
|
7
|
+
* `describeInvocation` to `print`, when `env`'s run payload says the run is verbose (its `--verbose`), or
|
|
8
|
+
* `undefined` outside a storm run, in a run that isn't verbose, or when the run payload can't be read.
|
|
9
9
|
*/
|
|
10
10
|
export function defaultInvocationListener(env, print) {
|
|
11
11
|
const raw = env[RUN_PAYLOAD_VARIABLE];
|
package/dist/vitest/config.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface TestserverWorkersOptions {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* The `maxWorkers` for a testserver vitest project: `workersPerSandbox` times the number of Testserver sandboxes in
|
|
28
|
-
* the run payload. With `STORM_RUN` unset or empty, outside
|
|
28
|
+
* the run payload. With `STORM_RUN` unset or empty, outside a storm run, it counts one Testserver sandbox,
|
|
29
29
|
* so the config still loads. Throws a `RunPayloadError` when `STORM_RUN` holds no valid run payload, and an
|
|
30
30
|
* `Error` when `workersPerSandbox` is not a positive integer.
|
|
31
31
|
*/
|
|
@@ -36,15 +36,15 @@ export interface StormReporterOptions {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* A vitest reporter for a testserver project's config: it appends each test's final result, retries settled, to the
|
|
39
|
-
* run payload's `testEvents` file, which
|
|
39
|
+
* run payload's `testEvents` file, which the run counts the tests from. It prints nothing, so list it beside
|
|
40
40
|
* the reporter a person reads, `reporters: ["default", stormReporter()]`; a `--reporter` given to vitest on the
|
|
41
|
-
* command line replaces both. Outside
|
|
41
|
+
* command line replaces both. Outside a storm run, or when the run payload names no test events file, it
|
|
42
42
|
* reports nothing, and once an append fails it drops every later result: it never fails a test.
|
|
43
43
|
*/
|
|
44
44
|
export declare function stormReporter(options?: StormReporterOptions): StormReporter;
|
|
45
45
|
/**
|
|
46
|
-
* The reporters for a testserver project's config under
|
|
47
|
-
* and its slow or failed tests as each file finishes, or under
|
|
46
|
+
* The reporters for a testserver project's config under a storm run: vitest's `default`, which names each file
|
|
47
|
+
* and its slow or failed tests as each file finishes, or under a run's `--verbose` its `verbose`, which names
|
|
48
48
|
* each test as it finishes; and `stormReporter()`. With `STORM_RUN` unset or empty it picks `default`.
|
|
49
49
|
* Throws a `RunPayloadError` when `STORM_RUN` holds no valid run payload.
|
|
50
50
|
*/
|
package/dist/vitest/config.js
CHANGED
|
@@ -23,7 +23,7 @@ export const testserverConnectionRetry = {
|
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* The `maxWorkers` for a testserver vitest project: `workersPerSandbox` times the number of Testserver sandboxes in
|
|
26
|
-
* the run payload. With `STORM_RUN` unset or empty, outside
|
|
26
|
+
* the run payload. With `STORM_RUN` unset or empty, outside a storm run, it counts one Testserver sandbox,
|
|
27
27
|
* so the config still loads. Throws a `RunPayloadError` when `STORM_RUN` holds no valid run payload, and an
|
|
28
28
|
* `Error` when `workersPerSandbox` is not a positive integer.
|
|
29
29
|
*/
|
|
@@ -39,17 +39,17 @@ export function testserverWorkers(options = {}) {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* A vitest reporter for a testserver project's config: it appends each test's final result, retries settled, to the
|
|
42
|
-
* run payload's `testEvents` file, which
|
|
42
|
+
* run payload's `testEvents` file, which the run counts the tests from. It prints nothing, so list it beside
|
|
43
43
|
* the reporter a person reads, `reporters: ["default", stormReporter()]`; a `--reporter` given to vitest on the
|
|
44
|
-
* command line replaces both. Outside
|
|
44
|
+
* command line replaces both. Outside a storm run, or when the run payload names no test events file, it
|
|
45
45
|
* reports nothing, and once an append fails it drops every later result: it never fails a test.
|
|
46
46
|
*/
|
|
47
47
|
export function stormReporter(options = {}) {
|
|
48
48
|
return testResultReporter(options.env ?? process.env);
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* The reporters for a testserver project's config under
|
|
52
|
-
* and its slow or failed tests as each file finishes, or under
|
|
51
|
+
* The reporters for a testserver project's config under a storm run: vitest's `default`, which names each file
|
|
52
|
+
* and its slow or failed tests as each file finishes, or under a run's `--verbose` its `verbose`, which names
|
|
53
53
|
* each test as it finishes; and `stormReporter()`. With `STORM_RUN` unset or empty it picks `default`.
|
|
54
54
|
* Throws a `RunPayloadError` when `STORM_RUN` holds no valid run payload.
|
|
55
55
|
*/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Where a package's `vitest` sits under a directory. */
|
|
2
|
+
export declare const VITEST_BIN: string;
|
|
3
|
+
/**
|
|
4
|
+
* The directories whose `node_modules/.bin` may hold `vitest`, nearest first: `from`, then each directory above it, up
|
|
5
|
+
* to and including `root`. When `from` isn't `root` or inside it, up to the filesystem's root.
|
|
6
|
+
*/
|
|
7
|
+
export declare function vitestSearchDirectories(from: string, root: string): readonly string[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Where to look for `vitest` in `node_modules/.bin`. Pure, so the live list gateway and its fake look in the same
|
|
2
|
+
// directories.
|
|
3
|
+
import { dirname, join, relative, isAbsolute } from "node:path";
|
|
4
|
+
/** Where a package's `vitest` sits under a directory. */
|
|
5
|
+
export const VITEST_BIN = join("node_modules", ".bin", "vitest");
|
|
6
|
+
/**
|
|
7
|
+
* The directories whose `node_modules/.bin` may hold `vitest`, nearest first: `from`, then each directory above it, up
|
|
8
|
+
* to and including `root`. When `from` isn't `root` or inside it, up to the filesystem's root.
|
|
9
|
+
*/
|
|
10
|
+
export function vitestSearchDirectories(from, root) {
|
|
11
|
+
const inside = from === root || isInside(root, from);
|
|
12
|
+
const directories = [];
|
|
13
|
+
let directory = from;
|
|
14
|
+
for (;;) {
|
|
15
|
+
directories.push(directory);
|
|
16
|
+
if (inside && directory === root)
|
|
17
|
+
return directories;
|
|
18
|
+
const parent = dirname(directory);
|
|
19
|
+
if (parent === directory)
|
|
20
|
+
return directories;
|
|
21
|
+
directory = parent;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Whether `path` is inside `directory`, below it. */
|
|
25
|
+
function isInside(directory, path) {
|
|
26
|
+
const between = relative(directory, path);
|
|
27
|
+
return between !== "" && !between.startsWith("..") && !isAbsolute(between);
|
|
28
|
+
}
|
|
@@ -21,11 +21,11 @@ declare module "vitest" {
|
|
|
21
21
|
* (`@cnc-tools/storm/vitest/config`), in vitest's main process. `stormEvents`, `stormFileEvents` and
|
|
22
22
|
* `stormTestEvents` are the adapter's own, which tests don't use.
|
|
23
23
|
*
|
|
24
|
-
* - `verbose` (per worker): whether the run is verbose, under
|
|
24
|
+
* - `verbose` (per worker): whether the run is verbose, under a run's `--verbose`, from the run payload. Then
|
|
25
25
|
* `container` prints each container start and `proxy` each request as it is recorded, for passing tests too, and
|
|
26
26
|
* a test's own fixture can print what it does, as the Vercel CLI driver's invocations.
|
|
27
27
|
* - `testserverUrl` (per worker): this worker's Testserver sandbox, `sandboxes[(VITEST_POOL_ID - 1) % N]` from the
|
|
28
|
-
* run payload's `resources.testserverPool`. Outside
|
|
28
|
+
* run payload's `resources.testserverPool`. Outside a storm run, or with a `VITEST_POOL_ID` that isn't a
|
|
29
29
|
* positive integer, it throws, so the test fails rather than skips.
|
|
30
30
|
* - `stormFile` (per file): the adapter's own state for the file, which tests don't use: its `container`, the
|
|
31
31
|
* holder of the file's container, and its `acquisitions`, the container and proxy starts still in flight. Creating
|
package/dist/vitest/fixtures.js
CHANGED
|
@@ -7,7 +7,7 @@ import { sandboxForWorker } from "./sandbox.js";
|
|
|
7
7
|
import { countTests, reportedStart, testEventReporter, testEventState } from "./test-events.js";
|
|
8
8
|
/**
|
|
9
9
|
* The Testserver URL of this worker's Testserver sandbox, `sandboxes[(VITEST_POOL_ID - 1) % N]` of the run
|
|
10
|
-
* payload's `resources.testserverPool`. Throws outside
|
|
10
|
+
* payload's `resources.testserverPool`. Throws outside a storm run, and outside a vitest worker.
|
|
11
11
|
*/
|
|
12
12
|
function workerTestserverUrl() {
|
|
13
13
|
return sandboxForWorker(readRunPayload(), process.env["VITEST_POOL_ID"]);
|
|
@@ -126,11 +126,11 @@ const fixtures = vitestTest
|
|
|
126
126
|
* (`@cnc-tools/storm/vitest/config`), in vitest's main process. `stormEvents`, `stormFileEvents` and
|
|
127
127
|
* `stormTestEvents` are the adapter's own, which tests don't use.
|
|
128
128
|
*
|
|
129
|
-
* - `verbose` (per worker): whether the run is verbose, under
|
|
129
|
+
* - `verbose` (per worker): whether the run is verbose, under a run's `--verbose`, from the run payload. Then
|
|
130
130
|
* `container` prints each container start and `proxy` each request as it is recorded, for passing tests too, and
|
|
131
131
|
* a test's own fixture can print what it does, as the Vercel CLI driver's invocations.
|
|
132
132
|
* - `testserverUrl` (per worker): this worker's Testserver sandbox, `sandboxes[(VITEST_POOL_ID - 1) % N]` from the
|
|
133
|
-
* run payload's `resources.testserverPool`. Outside
|
|
133
|
+
* run payload's `resources.testserverPool`. Outside a storm run, or with a `VITEST_POOL_ID` that isn't a
|
|
134
134
|
* positive integer, it throws, so the test fails rather than skips.
|
|
135
135
|
* - `stormFile` (per file): the adapter's own state for the file, which tests don't use: its `container`, the
|
|
136
136
|
* holder of the file's container, and its `acquisitions`, the container and proxy starts still in flight. Creating
|
|
@@ -5,19 +5,44 @@ export interface ListedTest {
|
|
|
5
5
|
/** The absolute path of its file. */
|
|
6
6
|
readonly file: string;
|
|
7
7
|
}
|
|
8
|
-
/** What to list: `vitest list
|
|
8
|
+
/** What to list: `vitest list` with `args`, such as a project and file filters, and `--json`. */
|
|
9
9
|
export interface VitestListRequest {
|
|
10
|
-
/** Passed
|
|
10
|
+
/** Passed to `vitest list`, as `vitest run` takes them. */
|
|
11
11
|
readonly args: readonly string[];
|
|
12
12
|
/** Where vitest runs; default the current directory. */
|
|
13
13
|
readonly cwd?: string;
|
|
14
|
+
/** The `vitest` to start, such as the absolute path `findVitest` found; default `vitest` from `PATH`. */
|
|
15
|
+
readonly executable?: string;
|
|
14
16
|
/** How long the listing may take before it is killed. */
|
|
15
17
|
readonly timeoutMs: number;
|
|
18
|
+
/** Stops the listing when it aborts, before it starts or while it runs: the listing is `canceled`. */
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
16
20
|
}
|
|
21
|
+
/** Where to look for `vitest`: in `node_modules/.bin` of `from` and of each directory above it, up to `root`. */
|
|
22
|
+
export interface FindVitestRequest {
|
|
23
|
+
/** The directory vitest runs in, an absolute path. */
|
|
24
|
+
readonly from: string;
|
|
25
|
+
/**
|
|
26
|
+
* The last directory to look in, an absolute path: the repository's root, or the filesystem's root outside a
|
|
27
|
+
* repository. When `from` isn't inside it, the search goes on up to the filesystem's root.
|
|
28
|
+
*/
|
|
29
|
+
readonly root: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The `vitest` found nearest `from`, as an absolute path to its `node_modules/.bin/vitest`; or, when no directory has
|
|
33
|
+
* one, every directory looked in, nearest first (`vitestSearchDirectories`).
|
|
34
|
+
*/
|
|
35
|
+
export type FindVitestResult = {
|
|
36
|
+
readonly ok: true;
|
|
37
|
+
readonly path: string;
|
|
38
|
+
} | {
|
|
39
|
+
readonly ok: false;
|
|
40
|
+
readonly searched: readonly string[];
|
|
41
|
+
};
|
|
17
42
|
/**
|
|
18
|
-
* Why the tests couldn't be listed: `vitest` couldn't be started (not on `PATH
|
|
19
|
-
* within `timeoutMs`, it exited other than 0 (with the last line of its stderr that isn't blank or a
|
|
20
|
-
* when there is none),
|
|
43
|
+
* Why the tests couldn't be listed: `vitest` couldn't be started (not on `PATH` or not found, or no such `cwd`), it
|
|
44
|
+
* didn't finish within `timeoutMs`, it exited other than 0 (with the last line of its stderr that isn't blank or a
|
|
45
|
+
* stack frame, empty when there is none), its output wasn't a list of tests, or the request's `signal` stopped it.
|
|
21
46
|
*/
|
|
22
47
|
export type VitestListFailure = {
|
|
23
48
|
readonly kind: "start-failed";
|
|
@@ -33,6 +58,8 @@ export type VitestListFailure = {
|
|
|
33
58
|
} | {
|
|
34
59
|
readonly kind: "unreadable-output";
|
|
35
60
|
readonly message: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: "canceled";
|
|
36
63
|
};
|
|
37
64
|
export type VitestListResult = {
|
|
38
65
|
readonly ok: true;
|
|
@@ -41,7 +68,11 @@ export type VitestListResult = {
|
|
|
41
68
|
readonly ok: false;
|
|
42
69
|
readonly failure: VitestListFailure;
|
|
43
70
|
};
|
|
44
|
-
/** Lists the tests a `vitest run` with the same arguments would run, without running them. */
|
|
45
71
|
export interface VitestListGateway {
|
|
72
|
+
/** Lists the tests a `vitest run` with the same arguments would run, without running them. */
|
|
46
73
|
listTests(request: VitestListRequest): Promise<VitestListResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Finds the `vitest` a package's scripts would run: the nearest `node_modules/.bin/vitest` from `from` up to `root`.
|
|
76
|
+
*/
|
|
77
|
+
findVitest(request: FindVitestRequest): Promise<FindVitestResult>;
|
|
47
78
|
}
|
package/dist/vitest/gateways.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
// The Vitest adapter's gateway: listing the tests a `vitest run` would
|
|
2
|
-
// The live gateway is `live/list-gateway.ts`; the fake is
|
|
1
|
+
// The Vitest adapter's gateway: finding `vitest` in `node_modules/.bin`, and listing the tests a `vitest run` would
|
|
2
|
+
// run, before any Testserver sandbox is leased. The live gateway is `live/list-gateway.ts`; the fake is
|
|
3
|
+
// `test/fakes/vitest/list-gateway.ts`.
|
|
3
4
|
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { VitestListGateway } from "../gateways.ts";
|
|
2
2
|
/**
|
|
3
|
-
* The live list gateway
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* The live list gateway. `listTests` spawns `vitest list <args> --json` (`listArgv`), the request's `executable` or
|
|
4
|
+
* `vitest` from `PATH`, no shell, in `cwd`, with stdin ignored. It sends SIGTERM after `timeoutMs`
|
|
5
|
+
* (`AbortSignal.timeout`), or once the request's `signal` aborts, then waits for the process to exit and answers
|
|
6
|
+
* `timed-out` or `canceled`, `canceled` when the request's `signal` aborted. It waits for the exit, not for the pipes
|
|
7
|
+
* to close, since a process `vitest` left behind could hold them open. Any other `error` is a start failure, answered
|
|
8
|
+
* at once, since no process started. `findVitest` answers the first `node_modules/.bin/vitest` this process may
|
|
9
|
+
* execute, in `vitestSearchDirectories` order.
|
|
6
10
|
*/
|
|
7
11
|
export declare const liveVitestListGateway: VitestListGateway;
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { access } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { VITEST_BIN, vitestSearchDirectories } from "../find-vitest.js";
|
|
2
6
|
import { readVitestList } from "../list-output.js";
|
|
3
7
|
/**
|
|
4
|
-
* The live list gateway
|
|
5
|
-
*
|
|
6
|
-
*
|
|
8
|
+
* The live list gateway. `listTests` spawns `vitest list <args> --json` (`listArgv`), the request's `executable` or
|
|
9
|
+
* `vitest` from `PATH`, no shell, in `cwd`, with stdin ignored. It sends SIGTERM after `timeoutMs`
|
|
10
|
+
* (`AbortSignal.timeout`), or once the request's `signal` aborts, then waits for the process to exit and answers
|
|
11
|
+
* `timed-out` or `canceled`, `canceled` when the request's `signal` aborted. It waits for the exit, not for the pipes
|
|
12
|
+
* to close, since a process `vitest` left behind could hold them open. Any other `error` is a start failure, answered
|
|
13
|
+
* at once, since no process started. `findVitest` answers the first `node_modules/.bin/vitest` this process may
|
|
14
|
+
* execute, in `vitestSearchDirectories` order.
|
|
7
15
|
*/
|
|
8
16
|
export const liveVitestListGateway = {
|
|
17
|
+
async findVitest({ from, root }) {
|
|
18
|
+
const searched = vitestSearchDirectories(from, root);
|
|
19
|
+
for (const directory of searched) {
|
|
20
|
+
const path = join(directory, VITEST_BIN);
|
|
21
|
+
try {
|
|
22
|
+
await access(path, constants.X_OK);
|
|
23
|
+
return { ok: true, path };
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Not there, or not executable: look further up.
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return { ok: false, searched };
|
|
30
|
+
},
|
|
9
31
|
listTests(request) {
|
|
10
32
|
return new Promise((resolve) => {
|
|
11
33
|
let settled = false;
|
|
@@ -15,11 +37,14 @@ export const liveVitestListGateway = {
|
|
|
15
37
|
settled = true;
|
|
16
38
|
resolve(result);
|
|
17
39
|
};
|
|
18
|
-
const
|
|
40
|
+
const timeout = AbortSignal.timeout(request.timeoutMs);
|
|
41
|
+
const child = spawn(request.executable ?? "vitest", listArgv(request.args), {
|
|
19
42
|
...(request.cwd === undefined ? {} : { cwd: request.cwd }),
|
|
20
43
|
stdio: ["ignore", "pipe", "pipe"],
|
|
21
|
-
signal: AbortSignal.timeout
|
|
44
|
+
signal: request.signal === undefined ? timeout : AbortSignal.any([timeout, request.signal]),
|
|
22
45
|
});
|
|
46
|
+
// Why the listing was stopped, once the abort killed the process: answered when it has exited.
|
|
47
|
+
let stopped;
|
|
23
48
|
let stdout = "";
|
|
24
49
|
let stderr = "";
|
|
25
50
|
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
@@ -29,11 +54,24 @@ export const liveVitestListGateway = {
|
|
|
29
54
|
stderr += chunk;
|
|
30
55
|
});
|
|
31
56
|
child.on("error", (error) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
if (error.name !== "AbortError") {
|
|
58
|
+
settle({ ok: false, failure: { kind: "start-failed", message: error.message } });
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
stopped =
|
|
62
|
+
request.signal?.aborted === true ? { kind: "canceled" } : { kind: "timed-out", timeoutMs: request.timeoutMs };
|
|
63
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
64
|
+
settle({ ok: false, failure: stopped });
|
|
65
|
+
});
|
|
66
|
+
child.on("exit", () => {
|
|
67
|
+
if (stopped !== undefined)
|
|
68
|
+
settle({ ok: false, failure: stopped });
|
|
35
69
|
});
|
|
36
70
|
child.on("close", (exitCode, signal) => {
|
|
71
|
+
if (stopped !== undefined) {
|
|
72
|
+
settle({ ok: false, failure: stopped });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
37
75
|
if (exitCode !== 0) {
|
|
38
76
|
settle({ ok: false, failure: { kind: "exited", exitCode, signal, lastStderrLine: lastLine(stderr) } });
|
|
39
77
|
return;
|
|
@@ -58,3 +96,12 @@ function lastLine(text) {
|
|
|
58
96
|
.map((line) => line.trim())
|
|
59
97
|
.findLast((line) => line !== "" && !/^at\s/.test(line)) ?? "");
|
|
60
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* `vitest list`'s arguments: `args`, with `--json` after them but before a `--` among them. vitest's `--json` takes an
|
|
101
|
+
* optional path, so `vitest list --json test/a.test.ts` would write the list over `test/a.test.ts`; after the
|
|
102
|
+
* arguments, it takes none, and the list goes to stdout.
|
|
103
|
+
*/
|
|
104
|
+
function listArgv(args) {
|
|
105
|
+
const end = args.indexOf("--");
|
|
106
|
+
return end === -1 ? ["list", ...args, "--json"] : ["list", ...args.slice(0, end), "--json", ...args.slice(end)];
|
|
107
|
+
}
|
package/dist/vitest/plan.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type { VitestListGateway } from "./gateways.ts";
|
|
1
|
+
import type { VitestListFailure, VitestListGateway } from "./gateways.ts";
|
|
2
|
+
export { VITEST_BIN, vitestSearchDirectories } from "./find-vitest.ts";
|
|
3
|
+
export type { FindVitestRequest, FindVitestResult, ListedTest, VitestListFailure, VitestListGateway, VitestListRequest, VitestListResult, } from "./gateways.ts";
|
|
4
|
+
export { liveVitestListGateway } from "./live/list-gateway.ts";
|
|
5
|
+
export { WORKERS_PER_SANDBOX } from "./config.ts";
|
|
2
6
|
/** How long `listVitestTests` lets `vitest list` run by default. */
|
|
3
7
|
export declare const LIST_TIMEOUT_MS = 60000;
|
|
4
8
|
/** How many tests a Vitest run would run, and in how many files. */
|
|
@@ -7,27 +11,56 @@ export interface TestPlan {
|
|
|
7
11
|
readonly files: number;
|
|
8
12
|
}
|
|
9
13
|
export interface ListVitestTestsOptions {
|
|
10
|
-
/** Passed
|
|
14
|
+
/** Passed to `vitest list --json`, as `vitest run` takes them, such as `["--project", "testserver"]`. */
|
|
11
15
|
readonly args: readonly string[];
|
|
12
16
|
/** Where vitest runs; default the current directory. */
|
|
13
17
|
readonly cwd?: string;
|
|
18
|
+
/** The `vitest` to start, such as the path `findVitest` found; default `vitest` from `PATH`. */
|
|
19
|
+
readonly executable?: string;
|
|
14
20
|
/** How long `vitest list` may take; default `LIST_TIMEOUT_MS`, 60s. */
|
|
15
21
|
readonly timeoutMs?: number;
|
|
22
|
+
/** Stops `vitest list` when it aborts: the plan's failure is then `canceled`. */
|
|
23
|
+
readonly signal?: AbortSignal;
|
|
16
24
|
}
|
|
25
|
+
/** A Vitest run's test plan, or why its tests couldn't be listed. */
|
|
26
|
+
export type VitestPlanResult = {
|
|
27
|
+
readonly ok: true;
|
|
28
|
+
readonly plan: TestPlan;
|
|
29
|
+
} | {
|
|
30
|
+
readonly ok: false;
|
|
31
|
+
readonly failure: VitestListFailure;
|
|
32
|
+
};
|
|
17
33
|
/**
|
|
18
|
-
* Lists the tests `vitest run <args>` would run, with `vitest list
|
|
19
|
-
*
|
|
20
|
-
* than 0 (with the last line of its stderr that isn't a stack frame),
|
|
34
|
+
* Lists the tests `vitest run <args>` would run, with `vitest list <args> --json` (`executable`, else `vitest` from
|
|
35
|
+
* `PATH`), and counts them; or says why it couldn't: `vitest` failed to start, didn't finish within `timeoutMs`, exited
|
|
36
|
+
* other than 0 (with the last line of its stderr that isn't a stack frame), printed something other than a list of
|
|
37
|
+
* tests, or was stopped by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive number.
|
|
38
|
+
*/
|
|
39
|
+
export declare function planVitestRun(options: ListVitestTestsOptions, gateway?: VitestListGateway): Promise<VitestPlanResult>;
|
|
40
|
+
/**
|
|
41
|
+
* `planVitestRun`'s plan, rejecting with an `Error` that says why the tests couldn't be listed
|
|
42
|
+
* (`describeVitestListFailure`).
|
|
21
43
|
*/
|
|
22
44
|
export declare function listVitestTests(options: ListVitestTestsOptions, gateway?: VitestListGateway): Promise<TestPlan>;
|
|
45
|
+
/** The argv that runs `args` with `executable`, a `vitest`: `<executable> run <args...>`. */
|
|
46
|
+
export declare function vitestRunArgv(executable: string, args: readonly string[]): readonly string[];
|
|
23
47
|
/** The plan `vitest list --json` printed: its tests, and their distinct files. Throws when it isn't a list of tests. */
|
|
24
48
|
export declare function parseVitestList(stdout: string): TestPlan;
|
|
25
49
|
/** A plan as a phrase, such as `65 tests in 19 files` or `1 test in 1 file`. */
|
|
26
50
|
export declare function formatPlan(plan: TestPlan): string;
|
|
51
|
+
/** The most Testserver sandboxes `autoSandboxes` sizes a run for: past it, a run passes `--testserver-sandboxes`. */
|
|
52
|
+
export declare const AUTO_SANDBOXES_MAX = 8;
|
|
53
|
+
/**
|
|
54
|
+
* The Testserver sandboxes `storm vitest` asks for when neither `--testserver-sandboxes` nor the config file says:
|
|
55
|
+
* one per `WORKERS_PER_SANDBOX` (4) files, at least 1 and at most `AUTO_SANDBOXES_MAX` (8) (`sandboxesFor`).
|
|
56
|
+
*/
|
|
57
|
+
export declare function autoSandboxes(files: number): number;
|
|
27
58
|
/**
|
|
28
|
-
* The Testserver sandboxes to ask `storm
|
|
29
|
-
*
|
|
30
|
-
*
|
|
59
|
+
* The Testserver sandboxes to ask `storm exec --testserver-sandboxes <n>` for: one per `workersPerSandbox` files
|
|
60
|
+
* (default `WORKERS_PER_SANDBOX`, 4, as `testserverWorkers` sizes `maxWorkers`), at least 1 and at most `max`. A file's
|
|
61
|
+
* tests run in one worker, so more sandboxes than that would sit idle. Throws a `TypeError` unless `files` is a
|
|
31
62
|
* non-negative integer and `max` and `workersPerSandbox` are positive integers.
|
|
32
63
|
*/
|
|
33
64
|
export declare function sandboxesFor(files: number, max: number, workersPerSandbox?: number): number;
|
|
65
|
+
/** Why the tests couldn't be listed, as a sentence. */
|
|
66
|
+
export declare function describeVitestListFailure(failure: VitestListFailure): string;
|
package/dist/vitest/plan.js
CHANGED
|
@@ -1,30 +1,49 @@
|
|
|
1
|
-
//
|
|
2
|
-
// `
|
|
3
|
-
//
|
|
4
|
-
// adapter
|
|
1
|
+
// Planning a Vitest run before any Testserver sandbox is leased, exported as `@cnc-tools/storm/vitest/plan`: finding
|
|
2
|
+
// `vitest` in `node_modules/.bin`, counting the tests `vitest run <args>` would run, sizing the Testserver sandboxes
|
|
3
|
+
// for them, and the `vitest run` argv. It is the adapter's one entry point for the CLI: `storm vitest` imports it
|
|
4
|
+
// and nothing else of the adapter. Like `config.ts`, it imports neither `./fixtures.ts` nor vitest: the CLI and a
|
|
5
|
+
// launcher script run outside a Vitest run, where the adapter's `test` throws.
|
|
5
6
|
import { WORKERS_PER_SANDBOX } from "./config.js";
|
|
6
7
|
import { readVitestList } from "./list-output.js";
|
|
7
8
|
import { liveVitestListGateway } from "./live/list-gateway.js";
|
|
9
|
+
export { VITEST_BIN, vitestSearchDirectories } from "./find-vitest.js";
|
|
10
|
+
export { liveVitestListGateway } from "./live/list-gateway.js";
|
|
11
|
+
export { WORKERS_PER_SANDBOX } from "./config.js";
|
|
8
12
|
/** How long `listVitestTests` lets `vitest list` run by default. */
|
|
9
13
|
export const LIST_TIMEOUT_MS = 60_000;
|
|
10
14
|
/**
|
|
11
|
-
* Lists the tests `vitest run <args>` would run, with `vitest list
|
|
12
|
-
*
|
|
13
|
-
* than 0 (with the last line of its stderr that isn't a stack frame),
|
|
15
|
+
* Lists the tests `vitest run <args>` would run, with `vitest list <args> --json` (`executable`, else `vitest` from
|
|
16
|
+
* `PATH`), and counts them; or says why it couldn't: `vitest` failed to start, didn't finish within `timeoutMs`, exited
|
|
17
|
+
* other than 0 (with the last line of its stderr that isn't a stack frame), printed something other than a list of
|
|
18
|
+
* tests, or was stopped by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive number.
|
|
14
19
|
*/
|
|
15
|
-
export async function
|
|
20
|
+
export async function planVitestRun(options, gateway = liveVitestListGateway) {
|
|
16
21
|
const timeoutMs = options.timeoutMs ?? LIST_TIMEOUT_MS;
|
|
17
22
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
18
|
-
throw new TypeError(`
|
|
23
|
+
throw new TypeError(`planVitestRun: timeoutMs is ${String(timeoutMs)}, not a positive number`);
|
|
19
24
|
}
|
|
20
25
|
const listed = await gateway.listTests({
|
|
21
26
|
args: options.args,
|
|
22
27
|
...(options.cwd === undefined ? {} : { cwd: options.cwd }),
|
|
28
|
+
...(options.executable === undefined ? {} : { executable: options.executable }),
|
|
23
29
|
timeoutMs,
|
|
30
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
24
31
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
return listed.ok ? { ok: true, plan: planOf(listed.tests) } : { ok: false, failure: listed.failure };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `planVitestRun`'s plan, rejecting with an `Error` that says why the tests couldn't be listed
|
|
36
|
+
* (`describeVitestListFailure`).
|
|
37
|
+
*/
|
|
38
|
+
export async function listVitestTests(options, gateway = liveVitestListGateway) {
|
|
39
|
+
const planned = await planVitestRun(options, gateway);
|
|
40
|
+
if (!planned.ok)
|
|
41
|
+
throw new Error(describeVitestListFailure(planned.failure));
|
|
42
|
+
return planned.plan;
|
|
43
|
+
}
|
|
44
|
+
/** The argv that runs `args` with `executable`, a `vitest`: `<executable> run <args...>`. */
|
|
45
|
+
export function vitestRunArgv(executable, args) {
|
|
46
|
+
return [executable, "run", ...args];
|
|
28
47
|
}
|
|
29
48
|
/** The plan `vitest list --json` printed: its tests, and their distinct files. Throws when it isn't a list of tests. */
|
|
30
49
|
export function parseVitestList(stdout) {
|
|
@@ -34,10 +53,19 @@ export function parseVitestList(stdout) {
|
|
|
34
53
|
export function formatPlan(plan) {
|
|
35
54
|
return `${plan.tests} ${plan.tests === 1 ? "test" : "tests"} in ${plan.files} ${plan.files === 1 ? "file" : "files"}`;
|
|
36
55
|
}
|
|
56
|
+
/** The most Testserver sandboxes `autoSandboxes` sizes a run for: past it, a run passes `--testserver-sandboxes`. */
|
|
57
|
+
export const AUTO_SANDBOXES_MAX = 8;
|
|
58
|
+
/**
|
|
59
|
+
* The Testserver sandboxes `storm vitest` asks for when neither `--testserver-sandboxes` nor the config file says:
|
|
60
|
+
* one per `WORKERS_PER_SANDBOX` (4) files, at least 1 and at most `AUTO_SANDBOXES_MAX` (8) (`sandboxesFor`).
|
|
61
|
+
*/
|
|
62
|
+
export function autoSandboxes(files) {
|
|
63
|
+
return sandboxesFor(files, AUTO_SANDBOXES_MAX);
|
|
64
|
+
}
|
|
37
65
|
/**
|
|
38
|
-
* The Testserver sandboxes to ask `storm
|
|
39
|
-
*
|
|
40
|
-
*
|
|
66
|
+
* The Testserver sandboxes to ask `storm exec --testserver-sandboxes <n>` for: one per `workersPerSandbox` files
|
|
67
|
+
* (default `WORKERS_PER_SANDBOX`, 4, as `testserverWorkers` sizes `maxWorkers`), at least 1 and at most `max`. A file's
|
|
68
|
+
* tests run in one worker, so more sandboxes than that would sit idle. Throws a `TypeError` unless `files` is a
|
|
41
69
|
* non-negative integer and `max` and `workersPerSandbox` are positive integers.
|
|
42
70
|
*/
|
|
43
71
|
export function sandboxesFor(files, max, workersPerSandbox = WORKERS_PER_SANDBOX) {
|
|
@@ -57,7 +85,8 @@ export function sandboxesFor(files, max, workersPerSandbox = WORKERS_PER_SANDBOX
|
|
|
57
85
|
function planOf(tests) {
|
|
58
86
|
return { tests: tests.length, files: new Set(tests.map((test) => test.file)).size };
|
|
59
87
|
}
|
|
60
|
-
|
|
88
|
+
/** Why the tests couldn't be listed, as a sentence. */
|
|
89
|
+
export function describeVitestListFailure(failure) {
|
|
61
90
|
switch (failure.kind) {
|
|
62
91
|
case "start-failed":
|
|
63
92
|
return `\`vitest list\` failed to start: ${failure.message}`;
|
|
@@ -69,5 +98,7 @@ function describeListFailure(failure) {
|
|
|
69
98
|
}
|
|
70
99
|
case "unreadable-output":
|
|
71
100
|
return failure.message;
|
|
101
|
+
case "canceled":
|
|
102
|
+
return "`vitest list` was canceled";
|
|
72
103
|
}
|
|
73
104
|
}
|
package/dist/vitest/sandbox.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RunPayload } from "../sdk/index.ts";
|
|
2
2
|
/** What a test that needs a Testserver sandbox fails with in a run that holds none. */
|
|
3
|
-
export declare const NO_TESTSERVER_MESSAGE = "this run has no Testserver; add resources.testserverPool to storm.config.ts or pass --
|
|
3
|
+
export declare const NO_TESTSERVER_MESSAGE = "this run has no Testserver; add resources.testserverPool to storm.config.ts or pass --testserver-sandboxes <n>";
|
|
4
4
|
/**
|
|
5
5
|
* The Testserver URL of the Testserver sandbox the vitest worker numbered `poolId` uses:
|
|
6
6
|
* `sandboxes[(poolId - 1) % N]` of the run payload's `resources.testserverPool`. `poolId` is the worker's
|
package/dist/vitest/sandbox.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Which Testserver sandbox a vitest worker uses, and how many Testserver sandboxes a run counts for sizing workers.
|
|
2
2
|
// Pure: no vitest import, so `config.ts`, which a `vitest.config.ts` loads, can use it.
|
|
3
3
|
/** What a test that needs a Testserver sandbox fails with in a run that holds none. */
|
|
4
|
-
export const NO_TESTSERVER_MESSAGE = "this run has no Testserver; add resources.testserverPool to storm.config.ts or pass --
|
|
4
|
+
export const NO_TESTSERVER_MESSAGE = "this run has no Testserver; add resources.testserverPool to storm.config.ts or pass --testserver-sandboxes <n>";
|
|
5
5
|
/**
|
|
6
6
|
* The Testserver URL of the Testserver sandbox the vitest worker numbered `poolId` uses:
|
|
7
7
|
* `sandboxes[(poolId - 1) % N]` of the run payload's `resources.testserverPool`. `poolId` is the worker's
|
|
@@ -7,12 +7,12 @@ export type TestEventReporter = (event: ReportedTestEvent) => void;
|
|
|
7
7
|
export declare const silentTestEvents: TestEventReporter;
|
|
8
8
|
/**
|
|
9
9
|
* The reporter for this worker: appends each event, with the worker's `VITEST_POOL_ID` and the time, to the run
|
|
10
|
-
* payload's `testEvents` file. Outside
|
|
10
|
+
* payload's `testEvents` file. Outside a storm run, when the run payload names no such file, or outside a vitest
|
|
11
11
|
* worker, it reports nothing; and once an append fails it drops every later event: reporting never fails a test.
|
|
12
12
|
*/
|
|
13
13
|
export declare function testEventReporter(env?: Readonly<Record<string, string | undefined>>, append?: (path: string, text: string) => void, now?: () => number): TestEventReporter;
|
|
14
14
|
/**
|
|
15
|
-
* The test events file the run payload in `env` names; undefined outside
|
|
15
|
+
* The test events file the run payload in `env` names; undefined outside a storm run, when the run payload
|
|
16
16
|
* names none, or when it can't be read.
|
|
17
17
|
*/
|
|
18
18
|
export declare function testEventsFile(env: Readonly<Record<string, string | undefined>>): string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The test events a vitest worker appends to the run payload's `testEvents` file, so
|
|
1
|
+
// The test events a vitest worker appends to the run payload's `testEvents` file, so the run can show which
|
|
2
2
|
// worker runs which file, how long each container start and test attempt takes, and how busy the workers are. A
|
|
3
3
|
// test's final result comes from vitest's main process instead (`test-results.ts`). Pure but for the append, which a
|
|
4
4
|
// reporter does with one write a line: a short `O_APPEND` write lands whole beside other workers'.
|
|
@@ -8,7 +8,7 @@ import { readRunPayload, RUN_PAYLOAD_VARIABLE, testEventLine, } from "../sdk/ind
|
|
|
8
8
|
export const silentTestEvents = () => { };
|
|
9
9
|
/**
|
|
10
10
|
* The reporter for this worker: appends each event, with the worker's `VITEST_POOL_ID` and the time, to the run
|
|
11
|
-
* payload's `testEvents` file. Outside
|
|
11
|
+
* payload's `testEvents` file. Outside a storm run, when the run payload names no such file, or outside a vitest
|
|
12
12
|
* worker, it reports nothing; and once an append fails it drops every later event: reporting never fails a test.
|
|
13
13
|
*/
|
|
14
14
|
export function testEventReporter(env = process.env, append = (path, text) => appendFileSync(path, text), now = Date.now) {
|
|
@@ -31,7 +31,7 @@ export function testEventReporter(env = process.env, append = (path, text) => ap
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* The test events file the run payload in `env` names; undefined outside
|
|
34
|
+
* The test events file the run payload in `env` names; undefined outside a storm run, when the run payload
|
|
35
35
|
* names none, or when it can't be read.
|
|
36
36
|
*/
|
|
37
37
|
export function testEventsFile(env) {
|
|
@@ -71,7 +71,7 @@ export interface StormReporter {
|
|
|
71
71
|
* the run ends. Errors are vitest's, the first `MAX_ERRORS`, each `message` and `diff` cut to `ERROR_TEXT_CHARS` and
|
|
72
72
|
* `stack` to `STACK_LINES` lines.
|
|
73
73
|
*
|
|
74
|
-
* Outside
|
|
74
|
+
* Outside a storm run, or when the run payload names no test events file, it reports and keeps nothing; a test
|
|
75
75
|
* whose result can't be read is dropped; and once an append fails it drops every later result: reporting never fails
|
|
76
76
|
* a test.
|
|
77
77
|
*/
|
|
@@ -32,7 +32,7 @@ export const STACK_LINES = 30;
|
|
|
32
32
|
* the run ends. Errors are vitest's, the first `MAX_ERRORS`, each `message` and `diff` cut to `ERROR_TEXT_CHARS` and
|
|
33
33
|
* `stack` to `STACK_LINES` lines.
|
|
34
34
|
*
|
|
35
|
-
* Outside
|
|
35
|
+
* Outside a storm run, or when the run payload names no test events file, it reports and keeps nothing; a test
|
|
36
36
|
* whose result can't be read is dropped; and once an append fails it drops every later result: reporting never fails
|
|
37
37
|
* a test.
|
|
38
38
|
*/
|
package/dist/vitest/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ContainerScope } from "./container-scope.ts";
|
|
|
5
5
|
export interface StormWorkerFixtures {
|
|
6
6
|
/** This worker's Testserver sandbox, `sandboxes[(VITEST_POOL_ID - 1) % N]` of the run payload's Testserver pool. */
|
|
7
7
|
testserverUrl: string;
|
|
8
|
-
/** Whether the run is verbose (
|
|
8
|
+
/** Whether the run is verbose (its `--verbose`). */
|
|
9
9
|
verbose: boolean;
|
|
10
10
|
}
|
|
11
11
|
/** The adapter's fixtures set up for each test. */
|