@jskit-ai/jskit-catalog 0.2.131 → 0.2.132
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/catalog/packages.json +14 -14
- package/package.json +1 -1
- package/scripts/testing/command.mjs +180 -50
- package/scripts/testing/file-stop.mjs +24 -10
- package/scripts/testing/run-files.mjs +58 -0
- package/scripts/testing/time-report.mjs +28 -18
package/catalog/packages.json
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"release": {
|
|
7
7
|
"packages": {
|
|
8
8
|
"@jskit-ai/agent": "0.1.6",
|
|
9
|
-
"@jskit-ai/agent-docs": "0.1.
|
|
9
|
+
"@jskit-ai/agent-docs": "0.1.380",
|
|
10
10
|
"@jskit-ai/agent-runtime": "0.1.57",
|
|
11
11
|
"@jskit-ai/architecture-inspector": "0.1.37",
|
|
12
|
-
"@jskit-ai/assistant-core": "0.2.
|
|
13
|
-
"@jskit-ai/assistant-runtime": "0.2.
|
|
14
|
-
"@jskit-ai/assistant-voice": "0.2.
|
|
15
|
-
"@jskit-ai/assistant-voice-sherpa": "0.1.
|
|
12
|
+
"@jskit-ai/assistant-core": "0.2.106",
|
|
13
|
+
"@jskit-ai/assistant-runtime": "0.2.114",
|
|
14
|
+
"@jskit-ai/assistant-voice": "0.2.114",
|
|
15
|
+
"@jskit-ai/assistant-voice-sherpa": "0.1.161",
|
|
16
16
|
"@jskit-ai/auth-core": "0.2.43",
|
|
17
17
|
"@jskit-ai/auth-pass": "0.1.12",
|
|
18
18
|
"@jskit-ai/auth-provider-local-core": "0.2.52",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@jskit-ai/database-runtime-postgres": "0.1.292",
|
|
34
34
|
"@jskit-ai/http-runtime": "0.2.39",
|
|
35
35
|
"@jskit-ai/http-web": "0.2.72",
|
|
36
|
-
"@jskit-ai/jskit-catalog": "0.2.
|
|
36
|
+
"@jskit-ai/jskit-catalog": "0.2.132",
|
|
37
37
|
"@jskit-ai/kernel": "0.2.38",
|
|
38
38
|
"@jskit-ai/material-web": "0.1.17",
|
|
39
39
|
"@jskit-ai/mobile-capacitor": "0.2.63",
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
},
|
|
186
186
|
{
|
|
187
187
|
"packageId": "@jskit-ai/assistant-core",
|
|
188
|
-
"version": "0.2.
|
|
188
|
+
"version": "0.2.106",
|
|
189
189
|
"description": "Reusable assistant client/server/shared primitives without surface-specific routes or settings ownership.",
|
|
190
190
|
"jskit": {
|
|
191
191
|
"kind": "runtime",
|
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
},
|
|
370
370
|
{
|
|
371
371
|
"packageId": "@jskit-ai/assistant-runtime",
|
|
372
|
-
"version": "0.2.
|
|
372
|
+
"version": "0.2.114",
|
|
373
373
|
"description": "Capability-based assistant runtime with per-surface chat, transcripts, settings, and action tools.",
|
|
374
374
|
"jskit": {
|
|
375
375
|
"kind": "runtime",
|
|
@@ -475,7 +475,7 @@
|
|
|
475
475
|
},
|
|
476
476
|
"packageJson": {
|
|
477
477
|
"dependencies": {
|
|
478
|
-
"@jskit-ai/assistant-core": "0.2.
|
|
478
|
+
"@jskit-ai/assistant-core": "0.2.106",
|
|
479
479
|
"@jskit-ai/resource-core": "0.1.229",
|
|
480
480
|
"json-rest-schema": "^1.0.20"
|
|
481
481
|
},
|
|
@@ -495,7 +495,7 @@
|
|
|
495
495
|
},
|
|
496
496
|
{
|
|
497
497
|
"packageId": "@jskit-ai/assistant-voice",
|
|
498
|
-
"version": "0.2.
|
|
498
|
+
"version": "0.2.114",
|
|
499
499
|
"description": "Duplex voice conversations with application-owned targets and authorization, and the speech service engine with its client.",
|
|
500
500
|
"jskit": {
|
|
501
501
|
"kind": "runtime",
|
|
@@ -541,7 +541,7 @@
|
|
|
541
541
|
},
|
|
542
542
|
"packageJson": {
|
|
543
543
|
"dependencies": {
|
|
544
|
-
"@jskit-ai/assistant-core": "0.2.
|
|
544
|
+
"@jskit-ai/assistant-core": "0.2.106",
|
|
545
545
|
"ws": "^8.20.1"
|
|
546
546
|
},
|
|
547
547
|
"peerDependencies": {
|
|
@@ -553,7 +553,7 @@
|
|
|
553
553
|
},
|
|
554
554
|
{
|
|
555
555
|
"packageId": "@jskit-ai/assistant-voice-sherpa",
|
|
556
|
-
"version": "0.1.
|
|
556
|
+
"version": "0.1.161",
|
|
557
557
|
"description": "Optional native Sherpa speech engine and explicit model preparation for assistant voice.",
|
|
558
558
|
"jskit": {
|
|
559
559
|
"kind": "runtime",
|
|
@@ -591,7 +591,7 @@
|
|
|
591
591
|
},
|
|
592
592
|
"packageJson": {
|
|
593
593
|
"dependencies": {
|
|
594
|
-
"@jskit-ai/assistant-voice": "0.2.
|
|
594
|
+
"@jskit-ai/assistant-voice": "0.2.114",
|
|
595
595
|
"sherpa-onnx-node": "1.13.6"
|
|
596
596
|
}
|
|
597
597
|
}
|
|
@@ -4337,7 +4337,7 @@
|
|
|
4337
4337
|
"@jskit-ai/shell-web"
|
|
4338
4338
|
],
|
|
4339
4339
|
"packageId": "@jskit-ai/assistant-runtime",
|
|
4340
|
-
"packageVersion": "0.2.
|
|
4340
|
+
"packageVersion": "0.2.114",
|
|
4341
4341
|
"documentPath": "patterns/assistant-surface/PATTERN.md",
|
|
4342
4342
|
"examplePath": "patterns/assistant-surface/example",
|
|
4343
4343
|
"files": [
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import os from "node:os";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { Readable } from "node:stream";
|
|
7
|
-
import { pathToFileURL } from "node:url";
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
8
|
import { toPosixPath } from "../files.mjs";
|
|
9
9
|
import { BUDGET_VARIABLE, testConcurrency } from "./budget.mjs";
|
|
10
10
|
import { DATABASES_OPTION, testDatabaseRunFor } from "./databases.mjs";
|
|
@@ -22,17 +22,21 @@ import {
|
|
|
22
22
|
} from "./time-report.mjs";
|
|
23
23
|
|
|
24
24
|
// `jskit test [node options] [files or globs]`: node --test, running test files in parallel within the machine's test
|
|
25
|
-
// budget (budget.mjs)
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
25
|
+
// budget (budget.mjs), the files whose last run took longest first and a file with no recorded time before them all, so
|
|
26
|
+
// a long file never starts last and runs on alone. Each run's process is run-files.mjs, node:test's run() of the files
|
|
27
|
+
// in that order, since node --test sorts the files it is given by name; it takes node --test's options as node --test
|
|
28
|
+
// does, and its other node options reach every test file's process as from node --test. A file that truly must run
|
|
29
|
+
// alone says why on its first line, `// jskit-test: alone - <reason>`, and runs after the others, one such file at a
|
|
30
|
+
// time. That second run writes a reporter's file destination beside the first run's (`<name>.alone<ext>`) instead of
|
|
31
|
+
// over it. With --test-shard=<index>/<total> each run takes only its shard's files, picked by name as node --test picks
|
|
32
|
+
// a shard's files, so a shard is the same files on every machine, whatever times each recorded.
|
|
29
33
|
// Given no files, it takes node's default files less the helpers and fixtures under a support/ or fixtures/ folder or
|
|
30
34
|
// src/test/, names them to node --test, and fails instead of leaving out a file under tests/ named as a test that
|
|
31
35
|
// node's default misses, or when it finds no test file at all, before preparing any test database; the run's report
|
|
32
36
|
// fails a file it takes that declares no tests.
|
|
33
37
|
// Every run also reports to time-report.mjs, which times the command's files against coarse bounds, and preloads
|
|
34
38
|
// file-stop.mjs, which stops a file still running at a generous multiple of its time, or at the linger bound
|
|
35
|
-
// after its last test, naming what its process still has open. Marked files get the same. With --databases, a run whose
|
|
39
|
+
// after its last test and after hooks, naming what its process still has open. Marked files get the same. With --databases, a run whose
|
|
36
40
|
// test databases let fewer files run at once than the budget asked for (no usable TEST_DB_NAME, or copies the database
|
|
37
41
|
// user may not create) says so, and why, at its start and its end, and fails once its tests have run: a machine that
|
|
38
42
|
// should run files in parallel never silently runs them one at a time. A budget set to what the databases allow
|
|
@@ -73,6 +77,51 @@ const REPORTER = "--test-reporter";
|
|
|
73
77
|
const DESTINATION = "--test-reporter-destination";
|
|
74
78
|
const TIME_REPORTER = new URL("./time-report.mjs", import.meta.url).href;
|
|
75
79
|
const FILE_STOP = new URL("./file-stop.mjs", import.meta.url).href;
|
|
80
|
+
const RUN_FILES = fileURLToPath(new URL("./run-files.mjs", import.meta.url));
|
|
81
|
+
// node's own options, node --test's and the others a test command passes, that take a value, which may follow as the
|
|
82
|
+
// next argument (`--test-reporter spec`): that argument is the value, never a file.
|
|
83
|
+
const VALUE_OPTIONS = new Set([
|
|
84
|
+
"--test-concurrency", "--test-coverage-branches", "--test-coverage-exclude", "--test-coverage-functions",
|
|
85
|
+
"--test-coverage-include", "--test-coverage-lines", "--test-global-setup", "--test-isolation", "--experimental-test-isolation",
|
|
86
|
+
"--test-name-pattern", "--test-random-seed", "--test-reporter", "--test-reporter-destination", "--test-rerun-failures",
|
|
87
|
+
SHARD, "--test-skip-pattern", "--test-timeout", "--experimental-test-tag-filter", "--conditions", "-C",
|
|
88
|
+
"--disable-warning", "--env-file", "--env-file-if-exists", "--experimental-loader", "--import", "--input-type", "--loader",
|
|
89
|
+
"--require", "-r"
|
|
90
|
+
]);
|
|
91
|
+
// node's test runner options (Node 22 to 26), and --watch, which runs it in watch mode.
|
|
92
|
+
const TEST_OPTION = /^--(?:experimental-test|test|watch)(?:-|$)/u;
|
|
93
|
+
// What node --test's own process reads of them (parseCommandLine() in node's internal/test_runner/utils.js), as the
|
|
94
|
+
// run() option each is. They go to run() alone, never among the runner's own node options: run() gives each file's
|
|
95
|
+
// process those it reads (the name, skip and tag patterns, only, timeout, force exit, rerun failures, randomize and
|
|
96
|
+
// seed), as node --test does, and node:test in the runner would apply a name pattern or `only` to its own entry for each
|
|
97
|
+
// file, named as the file, and leave every file out; --watch would watch the runner itself.
|
|
98
|
+
const RUN_OPTIONS = Object.freeze({
|
|
99
|
+
"--test": { flag: true },
|
|
100
|
+
"--test-concurrency": { key: "concurrency", number: true },
|
|
101
|
+
"--test-timeout": { key: "timeout", number: true },
|
|
102
|
+
"--test-name-pattern": { key: "testNamePatterns", list: true },
|
|
103
|
+
"--test-skip-pattern": { key: "testSkipPatterns", list: true },
|
|
104
|
+
"--test-only": { key: "only", flag: true },
|
|
105
|
+
"--test-force-exit": { key: "forceExit", flag: true },
|
|
106
|
+
"--test-global-setup": { key: "globalSetupPath" },
|
|
107
|
+
"--test-isolation": { key: "isolation" },
|
|
108
|
+
"--experimental-test-isolation": { key: "isolation" },
|
|
109
|
+
"--test-coverage-include": { key: "coverageIncludeGlobs", list: true },
|
|
110
|
+
"--test-coverage-exclude": { key: "coverageExcludeGlobs", list: true },
|
|
111
|
+
"--test-coverage-branches": { key: "branchCoverage", number: true },
|
|
112
|
+
"--test-coverage-functions": { key: "functionCoverage", number: true },
|
|
113
|
+
"--test-coverage-lines": { key: "lineCoverage", number: true },
|
|
114
|
+
"--test-rerun-failures": { key: "rerunFailuresFilePath" },
|
|
115
|
+
[REPORTER]: { key: "reporters", list: true },
|
|
116
|
+
[DESTINATION]: { key: "destinations", list: true },
|
|
117
|
+
"--experimental-test-coverage": { key: "coverage", flag: true },
|
|
118
|
+
"--test-randomize": { key: "randomize", flag: true },
|
|
119
|
+
"--test-random-seed": { key: "randomSeed", number: true },
|
|
120
|
+
"--experimental-test-tag-filter": { key: "testTagFilters", list: true },
|
|
121
|
+
"--watch": { key: "watch", flag: true }
|
|
122
|
+
});
|
|
123
|
+
// The test options each file's process reads itself, which reach it from the runner's own options.
|
|
124
|
+
const FILE_OPTIONS = new Set(["--test-update-snapshots", "--experimental-test-module-mocks", "--experimental-test-snapshots"]);
|
|
76
125
|
// Every test file's process compiles the same modules; Node's compile cache keeps them for the next process and run.
|
|
77
126
|
// A cache the environment names, or NODE_DISABLE_COMPILE_CACHE=1, wins.
|
|
78
127
|
const COMPILE_CACHE = path.join("node_modules", ".cache", "jskit-node-compile-cache");
|
|
@@ -131,19 +180,12 @@ function markedDestination(destination, kind) {
|
|
|
131
180
|
return path.join(dir, `${name}.${kind}${ext}`);
|
|
132
181
|
}
|
|
133
182
|
|
|
134
|
-
/**
|
|
135
|
-
* A run of marked files' options: the parallel run's, with each file destination moved beside it and without the
|
|
136
|
-
* shard, which `markedShard` has already applied to those files.
|
|
137
|
-
* @param {string[]} options
|
|
138
|
-
* @param {"alone" | "network"} kind
|
|
139
|
-
*/
|
|
183
|
+
/** A run of marked files' options: the parallel run's, with each file destination moved beside it. */
|
|
140
184
|
function markedRunOptions(options, kind) {
|
|
141
185
|
const result = [];
|
|
142
186
|
for (let index = 0; index < options.length; index += 1) {
|
|
143
187
|
const option = options[index];
|
|
144
|
-
if (option ===
|
|
145
|
-
else if (option.startsWith(`${SHARD}=`)) continue;
|
|
146
|
-
else if (option === DESTINATION && index + 1 < options.length) {
|
|
188
|
+
if (option === DESTINATION && index + 1 < options.length) {
|
|
147
189
|
result.push(option, markedDestination(options[index + 1], kind));
|
|
148
190
|
index += 1;
|
|
149
191
|
} else if (option.startsWith(`${DESTINATION}=`)) result.push(`${DESTINATION}=${markedDestination(option.slice(DESTINATION.length + 1), kind)}`);
|
|
@@ -153,20 +195,68 @@ function markedRunOptions(options, kind) {
|
|
|
153
195
|
}
|
|
154
196
|
|
|
155
197
|
/**
|
|
156
|
-
* The
|
|
157
|
-
*
|
|
198
|
+
* The arguments after `jskit test` as node's options, each with its value, and the files and globs. An option takes the
|
|
199
|
+
* next argument as its value when it is one of VALUE_OPTIONS, or an option jskit does not know and that argument
|
|
200
|
+
* matches no file; any other argument names files.
|
|
201
|
+
*/
|
|
202
|
+
function splitArguments(args, cwd) {
|
|
203
|
+
const options = [];
|
|
204
|
+
const candidates = [];
|
|
205
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
206
|
+
const argument = args[index];
|
|
207
|
+
if (!argument.startsWith("-")) {
|
|
208
|
+
candidates.push(argument);
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
options.push(argument);
|
|
212
|
+
const next = args[index + 1];
|
|
213
|
+
if (argument.includes("=") || next === undefined || next.startsWith("-")) continue;
|
|
214
|
+
if (VALUE_OPTIONS.has(argument) || (!TEST_OPTION.test(argument) && findTestFiles([next], cwd).length < 1)) {
|
|
215
|
+
options.push(next);
|
|
216
|
+
index += 1;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return { options, candidates };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The shard `--test-shard=<index>/<total>` names, or null, and the options without it: jskit test picks a shard's files
|
|
224
|
+
* itself, by name as node --test picks them, so a shard takes the same files on every machine, whatever times each one
|
|
225
|
+
* recorded.
|
|
158
226
|
*/
|
|
159
|
-
function
|
|
227
|
+
function takeShard(options) {
|
|
160
228
|
const at = options.findIndex((option) => option === SHARD || option.startsWith(`${SHARD}=`));
|
|
161
|
-
if (at < 0) return
|
|
162
|
-
const
|
|
163
|
-
|
|
229
|
+
if (at < 0) return { shard: null, options };
|
|
230
|
+
const spaced = options[at] === SHARD;
|
|
231
|
+
const value = spaced ? options[at + 1] : options[at].slice(SHARD.length + 1);
|
|
232
|
+
const [index, total] = String(value).split("/").map(Number);
|
|
233
|
+
if (!(Number.isInteger(total) && total >= 1 && Number.isInteger(index) && index >= 1 && index <= total)) {
|
|
234
|
+
throw new Error(`jskit test: ${SHARD} is <index>/<total>, whole numbers with the index from 1 to the total, not ${value}.`);
|
|
235
|
+
}
|
|
236
|
+
return { shard: { index, total }, options: options.filter((_, position) => position !== at && !(spaced && position === at + 1)) };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// The longest recorded time first, a file with none (Infinity) before them all; equal times keep their order.
|
|
240
|
+
const longestFirst = (first, second) => (first.ms === second.ms ? 0 : first.ms < second.ms ? 1 : -1);
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* A run's files of its shard, picked by name as node --test picks them, in the order the run starts them: the longest
|
|
244
|
+
* time recorded in the last run first (file-times.json, recordTestTimes()), a file with none before them all, as it may
|
|
245
|
+
* be the longest; equal times by name.
|
|
246
|
+
* @param {string[]} files by name
|
|
247
|
+
* @param {Record<string, number>} recorded
|
|
248
|
+
* @param {{ index: number, total: number } | null} shard
|
|
249
|
+
*/
|
|
250
|
+
function startOrder(files, recorded, shard) {
|
|
251
|
+
return files.filter((_, position) => !shard || position % shard.total === shard.index - 1)
|
|
252
|
+
.map((file) => ({ file, ms: recorded[file] ?? Infinity })).sort(longestFirst).map(({ file }) => file);
|
|
164
253
|
}
|
|
165
254
|
|
|
166
255
|
/**
|
|
167
256
|
* The node --test runs for these arguments: one in parallel within the budget, then the files that must reach an
|
|
168
|
-
* outside service, in parallel too, then the files that must run alone
|
|
169
|
-
* processes get the network guard: all but
|
|
257
|
+
* outside service, in parallel too, then the files that must run alone, each run's files last, in the order it starts
|
|
258
|
+
* them (`runFiles`, startOrder()). `guarded` says, for each run, whether its processes get the network guard: all but
|
|
259
|
+
* the run of network files.
|
|
170
260
|
* @param {string[]} args the arguments after `jskit test`
|
|
171
261
|
* @param {{ cwd?: string, concurrency?: number }} [options]
|
|
172
262
|
*/
|
|
@@ -174,11 +264,10 @@ function planTestRuns(args, { cwd = process.cwd(), concurrency = testConcurrency
|
|
|
174
264
|
if (args.some((argument) => /^--test-concurrency(?:=|$)/u.test(argument))) {
|
|
175
265
|
throw new Error("jskit test takes the test concurrency from the machine's budget; remove --test-concurrency.");
|
|
176
266
|
}
|
|
177
|
-
const
|
|
178
|
-
// An argument that matches no file is
|
|
179
|
-
//
|
|
180
|
-
const
|
|
181
|
-
const named = [...new Set([...matched.values()].flat())].sort();
|
|
267
|
+
const split = splitArguments(args, cwd);
|
|
268
|
+
// An argument that matches no file is a typo, which the run leaves out, as node --test does; with none that matches,
|
|
269
|
+
// the run is the default files (defaultTestFiles).
|
|
270
|
+
const named = [...new Set(split.candidates.flatMap((candidate) => findTestFiles([candidate], cwd)))].sort();
|
|
182
271
|
const files = named.length > 0 ? named : defaultTestFiles(cwd);
|
|
183
272
|
const missed = named.length > 0 ? [] : missedTestFiles(files, cwd);
|
|
184
273
|
if (missed.length > 0) {
|
|
@@ -188,25 +277,16 @@ function planTestRuns(args, { cwd = process.cwd(), concurrency = testConcurrency
|
|
|
188
277
|
}
|
|
189
278
|
const { alone, network, problems } = readMarkedFiles(files, cwd);
|
|
190
279
|
if (problems.length > 0) throw new Error(`jskit test:\n- ${problems.join("\n- ")}`);
|
|
280
|
+
const { shard, options } = takeShard(split.options);
|
|
281
|
+
const recorded = readRecordedTimes(cwd);
|
|
191
282
|
const parallel = ["--test", `--test-concurrency=${concurrency}`];
|
|
192
|
-
if (alone.length < 1 && network.length < 1) {
|
|
193
|
-
// Given no files, node --test is given this run's, since its own default takes the helpers this one leaves out.
|
|
194
|
-
const runs = named.length > 0 ? [[...parallel, ...args]] : files.length > 0 ? [[...parallel, ...args, ...files]] : [];
|
|
195
|
-
return { concurrency, files: files.length, paths: files, alone, network, runs, guarded: runs.map(() => true) };
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const options = args.filter((argument) => !(matched.get(argument)?.length > 0));
|
|
199
283
|
const marked = new Set([...alone, ...network].map((entry) => entry.file));
|
|
200
284
|
const others = files.filter((file) => !marked.has(file));
|
|
201
|
-
const shardNetwork = markedShard(network.map((entry) => entry.file), options);
|
|
202
|
-
const shardAlone = markedShard(alone.map((entry) => entry.file), options);
|
|
203
285
|
const runs = [
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
: [])
|
|
209
|
-
];
|
|
286
|
+
{ prefix: parallel, options, files: startOrder(others, recorded, shard), guarded: true },
|
|
287
|
+
{ prefix: parallel, options: markedRunOptions(options, "network"), files: startOrder(network.map(({ file }) => file), recorded, shard), guarded: false },
|
|
288
|
+
{ prefix: ["--test", "--test-concurrency=1"], options: markedRunOptions(options, "alone"), files: startOrder(alone.map(({ file }) => file), recorded, shard), guarded: true }
|
|
289
|
+
].filter((run) => run.files.length > 0);
|
|
210
290
|
return {
|
|
211
291
|
concurrency,
|
|
212
292
|
// The most files running at once: the guarded ones, then the network ones, each run in parallel.
|
|
@@ -214,11 +294,58 @@ function planTestRuns(args, { cwd = process.cwd(), concurrency = testConcurrency
|
|
|
214
294
|
paths: files,
|
|
215
295
|
alone,
|
|
216
296
|
network,
|
|
217
|
-
runs: runs.map((
|
|
218
|
-
|
|
297
|
+
runs: runs.map((run) => [...run.prefix, ...run.options, ...run.files]),
|
|
298
|
+
runFiles: runs.map((run) => run.files),
|
|
299
|
+
guarded: runs.map((run) => run.guarded)
|
|
219
300
|
};
|
|
220
301
|
}
|
|
221
302
|
|
|
303
|
+
/**
|
|
304
|
+
* How run-files.mjs runs a run: its node options, the run's options that are not node --test's, and the settings of its
|
|
305
|
+
* run() (node --test's options as run() takes them, and its reporters paired with their destinations as node pairs
|
|
306
|
+
* them, by position, spec on stdout when none is given and stdout for a lone reporter). A test option node knows that
|
|
307
|
+
* jskit test does not is refused, never dropped.
|
|
308
|
+
* @param {string[]} options a run's options, without its files
|
|
309
|
+
* @returns {{ nodeOptions: string[], settings: Record<string, unknown> }}
|
|
310
|
+
*/
|
|
311
|
+
function runnerInvocation(options) {
|
|
312
|
+
const nodeOptions = [];
|
|
313
|
+
const settings = {};
|
|
314
|
+
for (let index = 0; index < options.length; index += 1) {
|
|
315
|
+
const option = options[index];
|
|
316
|
+
const equals = option.startsWith("--") ? option.indexOf("=") : -1;
|
|
317
|
+
const name = equals > 0 ? option.slice(0, equals) : option;
|
|
318
|
+
const known = RUN_OPTIONS[name];
|
|
319
|
+
if (!known) {
|
|
320
|
+
if (TEST_OPTION.test(name) && !FILE_OPTIONS.has(name)) {
|
|
321
|
+
throw new Error(`jskit test does not take node's ${name}; run node --test for it.`);
|
|
322
|
+
}
|
|
323
|
+
nodeOptions.push(option);
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
let text = true;
|
|
327
|
+
if (!known.flag) {
|
|
328
|
+
text = equals > 0 ? option.slice(equals + 1) : options[index + 1];
|
|
329
|
+
if (equals < 0) index += 1;
|
|
330
|
+
}
|
|
331
|
+
if (text === undefined) throw new Error(`jskit test: ${name} takes a value.`);
|
|
332
|
+
if (!known.key) continue;
|
|
333
|
+
const value = known.number ? Number(text) : text;
|
|
334
|
+
if (known.list) (settings[known.key] ??= []).push(value);
|
|
335
|
+
else settings[known.key] = value;
|
|
336
|
+
}
|
|
337
|
+
const { reporters = [], destinations = [] } = settings;
|
|
338
|
+
delete settings.destinations;
|
|
339
|
+
if (reporters.length === 0 && destinations.length === 0) reporters.push("spec");
|
|
340
|
+
if (reporters.length === 1 && destinations.length === 0) destinations.push("stdout");
|
|
341
|
+
if (reporters.length !== destinations.length) {
|
|
342
|
+
throw new Error(`jskit test: ${reporters.length} ${REPORTER} and ${destinations.length} ${DESTINATION}: node pairs them ` +
|
|
343
|
+
"by position, so give each reporter its destination.");
|
|
344
|
+
}
|
|
345
|
+
settings.reporters = reporters.map((reporter, index) => ({ name: reporter, destination: destinations[index] }));
|
|
346
|
+
return { nodeOptions, settings };
|
|
347
|
+
}
|
|
348
|
+
|
|
222
349
|
/**
|
|
223
350
|
* The run with the time reporter added before its own options (node takes the arguments after a file as files), writing
|
|
224
351
|
* to `destination`. Node pairs reporters and destinations by position, and gives a run with no reporter `spec` on
|
|
@@ -331,7 +458,13 @@ async function runTests(args) {
|
|
|
331
458
|
? networkGuardEnvironment(process.env, "jskit test")
|
|
332
459
|
: { NODE_OPTIONS: withoutNetworkGuard(process.env.NODE_OPTIONS) })
|
|
333
460
|
};
|
|
334
|
-
|
|
461
|
+
// run-files.mjs runs the files in their start order, with the run's node options as its own.
|
|
462
|
+
const files = plan.runFiles[index];
|
|
463
|
+
const timed = withTimeReporter(run, collected[index]);
|
|
464
|
+
const { nodeOptions, settings } = runnerInvocation(timed.slice(0, timed.length - files.length));
|
|
465
|
+
const settingsFile = path.join(timesDirectory, `run-${index}.settings.json`);
|
|
466
|
+
writeFileSync(settingsFile, JSON.stringify({ ...settings, files }));
|
|
467
|
+
const { code, signal } = await runNode([...preload, ...nodeOptions, RUN_FILES, settingsFile], env);
|
|
335
468
|
if (exitCode === 0) exitCode = code;
|
|
336
469
|
// An interrupted run ends the whole command.
|
|
337
470
|
interrupted = Boolean(signal);
|
|
@@ -364,9 +497,6 @@ async function runTests(args) {
|
|
|
364
497
|
/** A pooled file's name in the pool's output: its group's name, then its path in the group's directory. */
|
|
365
498
|
const pooledName = ({ group, file }) => `${group.name}: ${file}`;
|
|
366
499
|
|
|
367
|
-
// The longest recorded time first, a file with none (Infinity) before them all; equal times keep their order.
|
|
368
|
-
const longestFirst = (first, second) => (first.ms === second.ms ? 0 : first.ms < second.ms ? 1 : -1);
|
|
369
|
-
|
|
370
500
|
/**
|
|
371
501
|
* The files of a pool's groups (runTestPool), each with its group, why it runs alone or reaches the network (or
|
|
372
502
|
* undefined), and its time in its group's record, the longest first. A group takes files and globs only: a node option
|
|
@@ -555,4 +685,4 @@ async function runTestPool(groups) {
|
|
|
555
685
|
return exitCode;
|
|
556
686
|
}
|
|
557
687
|
|
|
558
|
-
export { defaultTestFiles, findTestFiles, missedTestFiles, planTestPool, planTestRuns, runTestPool, runTests, withTimeReporter };
|
|
688
|
+
export { defaultTestFiles, findTestFiles, missedTestFiles, planTestPool, planTestRuns, runTestPool, runTests, runnerInvocation, withTimeReporter };
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// (node --test starts one per file, with NODE_TEST_CONTEXT set), it stops the file at the time `jskit test` gave it
|
|
3
3
|
// (fileStop in time-report.mjs): a file that never finishes, because a test has no timeout or a server, child
|
|
4
4
|
// process, timer or socket was left open, then fails by name and the rest of the run still finishes and reports. It
|
|
5
|
-
// also stops a file whose tests have all ended but whose process is still running
|
|
6
|
-
// linger bound): something its tests left open, an interval, a server, a socket or a child
|
|
5
|
+
// also stops a file whose tests and top-level after() hooks have all ended but whose process is still running
|
|
6
|
+
// `lingerMs` later (the linger bound): something its tests left open, an interval, a server, a socket or a child
|
|
7
|
+
// process, keeps it alive. Its after hooks, its teardown, get a bound of their own of the same length from its last
|
|
8
|
+
// test, so one that never ends is stopped too.
|
|
7
9
|
// Before it stops one, it says what is still open, from process.getActiveResourcesInfo() read in that process, or
|
|
8
10
|
// that nothing is: then the process was still busy when its stop got a turn. The runner's own process, worker threads
|
|
9
11
|
// and the processes a test starts do nothing.
|
|
@@ -68,21 +70,26 @@ if (stopsFile && isMainThread && process.env.NODE_TEST_CONTEXT && !runsTestFiles
|
|
|
68
70
|
const record = (prefix, value) =>
|
|
69
71
|
writeFileSync(path.join(path.dirname(stopsFile), `${prefix}${process.pid}.json`), JSON.stringify(value));
|
|
70
72
|
const started = performance.now();
|
|
71
|
-
// node:test has
|
|
73
|
+
// node:test has started the root's after() hooks, and has run them all; then the file's module had finished
|
|
74
|
+
// loading too.
|
|
72
75
|
let testsEnded = false;
|
|
76
|
+
let hooksEnded = false;
|
|
73
77
|
let loaded = false;
|
|
74
78
|
// Tests running that started after the root's after() hooks: those a file declares after a top-level await.
|
|
75
79
|
let late = 0;
|
|
76
|
-
// When the linger bound last started, and its timer
|
|
80
|
+
// When the linger bound last started, and its timer: at the file's last test while its after hooks run, then at
|
|
81
|
+
// their end.
|
|
77
82
|
let ended = null;
|
|
78
83
|
let lingering;
|
|
79
84
|
let stopping = false;
|
|
80
85
|
const lingered = () => {
|
|
81
86
|
stopping = true;
|
|
82
|
-
const value = {
|
|
87
|
+
const value = {
|
|
88
|
+
file: hang.file, ms: Math.round(performance.now() - ended), resources: heldOpen(), afterHooks: !hooksEnded
|
|
89
|
+
};
|
|
83
90
|
record(LINGERED_PREFIX, value);
|
|
84
|
-
writeFileSync(2, `\njskit test: stopped ${value.file} ${(value.ms / 1000).toFixed(1)} s after its last test
|
|
85
|
-
`${describeHold(value.resources)}.\n`);
|
|
91
|
+
writeFileSync(2, `\njskit test: stopped ${value.file} ${(value.ms / 1000).toFixed(1)} s after its last test` +
|
|
92
|
+
`${value.afterHooks ? ", its after hooks still running" : " and after hooks"}, ${describeHold(value.resources)}.\n`);
|
|
86
93
|
exit.call(process, 1);
|
|
87
94
|
};
|
|
88
95
|
const settle = () => {
|
|
@@ -106,14 +113,21 @@ if (stopsFile && isMainThread && process.env.NODE_TEST_CONTEXT && !runsTestFiles
|
|
|
106
113
|
const nodeTest = await import("node:test");
|
|
107
114
|
// node:test runs the root's after() hooks, this one first, as soon as the file's last test so far has ended. A
|
|
108
115
|
// test declared after a top-level await comes later still, so the bound starts once the file's module has also
|
|
109
|
-
// finished loading, when its import settles; a test that starts after that holds the bound until it ends.
|
|
110
|
-
|
|
116
|
+
// finished loading, when its import settles; a test that starts after that holds the bound until it ends. The
|
|
117
|
+
// after() hook this one adds runs after the file's own, as node:test runs the root's hooks as they are added, and
|
|
118
|
+
// starts the bound again at their end. One that throws ends node:test's run of them, and the bound runs on from the
|
|
119
|
+
// file's last test.
|
|
120
|
+
nodeTest.after((context) => {
|
|
111
121
|
testsEnded = true;
|
|
112
122
|
const loading = () => {
|
|
113
123
|
loaded = true;
|
|
114
124
|
settle();
|
|
115
125
|
};
|
|
116
126
|
import(pathToFileURL(entry).href).then(loading, loading);
|
|
127
|
+
context.after(() => {
|
|
128
|
+
hooksEnded = true;
|
|
129
|
+
settle();
|
|
130
|
+
});
|
|
117
131
|
});
|
|
118
132
|
nodeTest.beforeEach(() => {
|
|
119
133
|
if (!testsEnded) return;
|
|
@@ -125,7 +139,7 @@ if (stopsFile && isMainThread && process.env.NODE_TEST_CONTEXT && !runsTestFiles
|
|
|
125
139
|
late = Math.max(0, late - 1);
|
|
126
140
|
settle();
|
|
127
141
|
});
|
|
128
|
-
// How long after its last test the file's process ended, for the run's report.
|
|
142
|
+
// How long after its last test and after hooks the file's process ended, for the run's report.
|
|
129
143
|
process.once("exit", () => {
|
|
130
144
|
if (ended !== null && !stopping) record(EXITED_PREFIX, { file: hang.file, ms: Math.round(performance.now() - ended) });
|
|
131
145
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The runner process of one `jskit test` run (command.mjs), in place of node --test's own: node:test's run() over the
|
|
2
|
+
// run's files in the order it is given them, the longest first, where node --test sorts the files it is given by name.
|
|
3
|
+
// Its one argument is a settings file: the files, the run() options command.mjs read from the run's node --test options,
|
|
4
|
+
// and the reporters, each paired with its destination as node pairs them. It fails as node --test fails, when a file or
|
|
5
|
+
// the run reports a failure. The run's other node options are this process's own, so node passes them on to each test
|
|
6
|
+
// file's process as node --test does. A signal ends the run: its files' processes are stopped and the reporters finish.
|
|
7
|
+
import { createWriteStream, readFileSync } from "node:fs";
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import process from "node:process";
|
|
11
|
+
import { run } from "node:test";
|
|
12
|
+
import * as builtInReporters from "node:test/reporters";
|
|
13
|
+
import { pathToFileURL } from "node:url";
|
|
14
|
+
|
|
15
|
+
const BUILT_IN_REPORTERS = new Set(["dot", "junit", "lcov", "spec", "tap"]);
|
|
16
|
+
const STREAM_DESTINATIONS = { stdout: process.stdout, stderr: process.stderr };
|
|
17
|
+
const URL_SPECIFIER = /^[a-z][a-z\d+.-]*:/iu;
|
|
18
|
+
|
|
19
|
+
/** A reporter module as node --test resolves its name: a path, or a package, from the working directory. */
|
|
20
|
+
function reporterSpecifier(name) {
|
|
21
|
+
if (path.isAbsolute(name) || name.startsWith(".")) return pathToFileURL(path.resolve(name)).href;
|
|
22
|
+
if (URL_SPECIFIER.test(name)) return name;
|
|
23
|
+
try {
|
|
24
|
+
return pathToFileURL(createRequire(path.join(process.cwd(), "package.json")).resolve(name)).href;
|
|
25
|
+
} catch {
|
|
26
|
+
// A package that only ESM imports resolve: from here, which is under the application's node_modules.
|
|
27
|
+
return name;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The reporter `--test-reporter` names, as node --test makes it: a class is constructed, a generator used as it is. */
|
|
32
|
+
async function loadReporter(name) {
|
|
33
|
+
let reporter = BUILT_IN_REPORTERS.has(name) ? builtInReporters[name] : await import(reporterSpecifier(name));
|
|
34
|
+
if (reporter?.default) reporter = reporter.default;
|
|
35
|
+
if (reporter?.prototype && Object.getOwnPropertyDescriptor(reporter.prototype, "constructor")) reporter = new reporter();
|
|
36
|
+
if (!reporter) throw new Error(`jskit test: --test-reporter ${name} names no test reporter.`);
|
|
37
|
+
return reporter;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const { files, reporters, ...options } = JSON.parse(readFileSync(process.argv[2], "utf8"));
|
|
41
|
+
// Every reporter is ready before the run starts, so each sees all of its events.
|
|
42
|
+
const outputs = await Promise.all(reporters.map(async ({ name, destination }) => ({
|
|
43
|
+
reporter: await loadReporter(name),
|
|
44
|
+
destination: STREAM_DESTINATIONS[destination] ?? createWriteStream(destination, { flush: true })
|
|
45
|
+
})));
|
|
46
|
+
const abort = new AbortController();
|
|
47
|
+
const interrupt = () => {
|
|
48
|
+
process.off("SIGINT", interrupt);
|
|
49
|
+
process.off("SIGTERM", interrupt);
|
|
50
|
+
abort.abort();
|
|
51
|
+
};
|
|
52
|
+
process.on("SIGINT", interrupt);
|
|
53
|
+
process.on("SIGTERM", interrupt);
|
|
54
|
+
const events = run({ ...options, files, signal: abort.signal });
|
|
55
|
+
events.on("test:summary", (summary) => {
|
|
56
|
+
if (!summary.success) process.exitCode = 1;
|
|
57
|
+
});
|
|
58
|
+
for (const { reporter, destination } of outputs) events.compose(reporter).pipe(destination);
|
|
@@ -12,8 +12,9 @@ import { EXITED_PREFIX, LINGERED_PREFIX, STOPPED_PREFIX, describeHold } from "./
|
|
|
12
12
|
// bounds in test-time-bounds.json, `{ "runMs": ..., "fileMs": ..., "lingerMs": ..., "files": { "<path>": ... } }`, with
|
|
13
13
|
// the measurement. A file that has not finished by a generous multiple of its time is stopped while it runs
|
|
14
14
|
// (file-stop.mjs), so one file that never ends fails by name instead of holding up the whole run until a runner's
|
|
15
|
-
// own ceiling ends it; so is a file still running `lingerMs` after its last test
|
|
16
|
-
//
|
|
15
|
+
// own ceiling ends it; so is a file still running `lingerMs` after its last test and after hooks, or whose after hooks
|
|
16
|
+
// still run `lingerMs` after its last test, naming what keeps it running, and a file still busy then that ends by itself
|
|
17
|
+
// before its stop gets a turn fails the run too. So does a file the run took
|
|
17
18
|
// as a test file that declares no tests, a helper or fixture outside the folders `jskit test` sets apart.
|
|
18
19
|
const SHOWN = 10;
|
|
19
20
|
// Stops a file at twice its bound (at least two seconds, well past any file's start-up), or at ten times its recorded
|
|
@@ -31,10 +32,13 @@ const BOUNDS_FILE = "test-time-bounds.json";
|
|
|
31
32
|
// running), then 1.0 s (realtime's providerRuntime.test.js, a 1 s one), 0.2 s in six suites and 0.1 s or less in the
|
|
32
33
|
// other 42.
|
|
33
34
|
const LINGER_MS = 10_000;
|
|
34
|
-
// What a file past the linger bound is told to do: close what its tests left open,
|
|
35
|
+
// What a file past the linger bound is told to do: close what its tests left open, finish the work it still does, or
|
|
36
|
+
// end what its after hooks wait on.
|
|
35
37
|
const CLOSE_WHAT_IS_OPEN = "Close what its tests leave open (an interval, a server, a socket, a child process) in the test or an after hook.";
|
|
36
|
-
const FINISH_THE_WORK = "Find the work it still does after its last test
|
|
37
|
-
"it) and finish it within
|
|
38
|
+
const FINISH_THE_WORK = "Find the work it still does after its last test and after hooks (work a test or an after hook started " +
|
|
39
|
+
"without waiting for it) and finish it within them.";
|
|
40
|
+
const END_THE_WAIT = "Find what its after hooks wait on that never ends (a server's open connections, a child process, a promise " +
|
|
41
|
+
"nothing settles) and end it.";
|
|
38
42
|
const DEFAULT_BOUNDS = Object.freeze({ runMs: 45 * 60_000, fileMs: 10 * 60_000, lingerMs: LINGER_MS, files: Object.freeze({}) });
|
|
39
43
|
const FILE_TIMES = path.join("node_modules", ".cache", "jskit-test", "file-times.json");
|
|
40
44
|
|
|
@@ -107,8 +111,9 @@ function fileStop({ bound, recorded }) {
|
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
/**
|
|
110
|
-
* Writes when each of the run's files is stopped, keyed by its absolute path, for file-stop.mjs, and how long
|
|
111
|
-
* after its last test (`lingerMs`, the same for every file); returns
|
|
114
|
+
* Writes when each of the run's files is stopped, keyed by its absolute path, for file-stop.mjs, and how long after its
|
|
115
|
+
* last test and after hooks, and its after hooks after its last test (`lingerMs`, the same for every file); returns
|
|
116
|
+
* the file.
|
|
112
117
|
* @param {{ cwd: string, files: string[], directory: string }} options `files`: the run's test files, relative to cwd
|
|
113
118
|
*/
|
|
114
119
|
function writeFileStops({ cwd, files, directory }) {
|
|
@@ -134,11 +139,12 @@ function writeFileStops({ cwd, files, directory }) {
|
|
|
134
139
|
* @param {{ bounds: { runMs: number, fileMs: number, lingerMs?: number, files: Record<string, number> },
|
|
135
140
|
* files: Record<string, number>, tests: Array<{ file: string, name: string, ms: number }>, wallMs: number,
|
|
136
141
|
* stopped?: Array<{ file: string, ms: number, reason: string }>,
|
|
137
|
-
* lingered?: Array<{ file: string, ms: number, resources: string[] }>,
|
|
142
|
+
* lingered?: Array<{ file: string, ms: number, resources: string[], afterHooks?: boolean }>,
|
|
138
143
|
* exited?: Array<{ file: string, ms: number }>, empty?: string[] }} times `stopped`: the files stopped while running;
|
|
139
|
-
* `lingered`: those stopped after their last test
|
|
140
|
-
*
|
|
141
|
-
*
|
|
144
|
+
* `lingered`: those stopped after their last test and after hooks, or while their after hooks still ran
|
|
145
|
+
* (`afterHooks`), with what was still open; `exited`: how long after its last test and after hooks each other file's
|
|
146
|
+
* process ended, failing one past `lingerMs`, which was still busy then with nothing holding it open; `empty`: the
|
|
147
|
+
* files that passed declaring no tests, which fail too
|
|
142
148
|
*/
|
|
143
149
|
function checkTestTimes({ bounds, files, tests, wallMs, stopped = [], lingered = [], exited = [], empty = [] }) {
|
|
144
150
|
const rows = Object.entries(files).map(([name, ms]) => ({ name, ms, bound: bounds.files[name] ?? bounds.fileMs }));
|
|
@@ -146,11 +152,14 @@ function checkTestTimes({ bounds, files, tests, wallMs, stopped = [], lingered =
|
|
|
146
152
|
const lingerMs = bounds.lingerMs ?? LINGER_MS;
|
|
147
153
|
const overruns = [
|
|
148
154
|
...stopped.map((stop) => `${stop.file} was stopped after ${seconds(stop.ms)}, ${stop.reason}: it did not finish.`),
|
|
149
|
-
...lingered.map((stop) =>
|
|
150
|
-
`${
|
|
155
|
+
...lingered.map((stop) => (stop.afterHooks
|
|
156
|
+
? `${stop.file}'s after hooks still ran ${seconds(stop.ms)} after its last test, and it was stopped, ` +
|
|
157
|
+
`${describeHold(stop.resources)}. ${END_THE_WAIT}`
|
|
158
|
+
: `${stop.file} outlived its last test and after hooks by ${seconds(stop.ms)} and was stopped, ` +
|
|
159
|
+
`${describeHold(stop.resources)}. ${stop.resources.length > 0 ? CLOSE_WHAT_IS_OPEN : FINISH_THE_WORK}`)),
|
|
151
160
|
// Its stop never got a turn: the process was still working when the bound passed, then ended with nothing open.
|
|
152
161
|
...exited.filter((exit) => exit.ms > lingerMs).map((exit) => `${exit.file} ended ${seconds(exit.ms)} after its last ` +
|
|
153
|
-
`test, past its ${seconds(lingerMs)} linger bound: busy, not held open. ${FINISH_THE_WORK}`),
|
|
162
|
+
`test and after hooks, past its ${seconds(lingerMs)} linger bound: busy, not held open. ${FINISH_THE_WORK}`),
|
|
154
163
|
...rows.filter((row) => row.ms > row.bound && !ended.has(row.name))
|
|
155
164
|
.map((row) => `${row.name} took ${seconds(row.ms)}, past its ${seconds(row.bound)} bound.`)
|
|
156
165
|
];
|
|
@@ -164,7 +173,7 @@ function checkTestTimes({ bounds, files, tests, wallMs, stopped = [], lingered =
|
|
|
164
173
|
];
|
|
165
174
|
const longest = [...exited].sort((a, b) => b.ms - a.ms)[0];
|
|
166
175
|
if (longest) {
|
|
167
|
-
lines.push(`jskit test: the longest a file's process lived after its last test, time / bound: ` +
|
|
176
|
+
lines.push(`jskit test: the longest a file's process lived after its last test and after hooks, time / bound: ` +
|
|
168
177
|
`${seconds(longest.ms)} / ${seconds(lingerMs)} ${longest.file}`);
|
|
169
178
|
}
|
|
170
179
|
if (empty.length > 0) {
|
|
@@ -185,8 +194,8 @@ function checkTestTimes({ bounds, files, tests, wallMs, stopped = [], lingered =
|
|
|
185
194
|
}
|
|
186
195
|
|
|
187
196
|
/**
|
|
188
|
-
* Reads what the runs' reporters wrote, which files file-stop.mjs stopped and how long after its last test
|
|
189
|
-
* other file's process ended, and records each finished file's time for the next command (a stopped file, one that
|
|
197
|
+
* Reads what the runs' reporters wrote, which files file-stop.mjs stopped and how long after its last test and after
|
|
198
|
+
* hooks each other file's process ended, and records each finished file's time for the next command (a stopped file, one that
|
|
190
199
|
* skipped a test, and every file of a run filtered to some of its tests keep the time they last finished all their
|
|
191
200
|
* tests in, since the next stop is reckoned from it). A run whose reporters were replaced (inside another node --test
|
|
192
201
|
* run) wrote nothing, and has no times unless a file was stopped.
|
|
@@ -195,7 +204,8 @@ function checkTestTimes({ bounds, files, tests, wallMs, stopped = [], lingered =
|
|
|
195
204
|
* ran only the tests a name pattern or `only` picked, so a file whose tests it left out declares none it ran
|
|
196
205
|
* @returns {{ files: Record<string, number>, tests: Array<{ file: string, name: string, ms: number }>,
|
|
197
206
|
* stopped: Array<{ file: string, ms: number, reason: string }>,
|
|
198
|
-
* lingered: Array<{ file: string, ms: number, resources: string[]
|
|
207
|
+
* lingered: Array<{ file: string, ms: number, resources: string[], afterHooks?: boolean }>,
|
|
208
|
+
* exited: Array<{ file: string, ms: number }>,
|
|
199
209
|
* empty: string[] } | null} `empty`: the files that passed declaring no test
|
|
200
210
|
*/
|
|
201
211
|
function recordTestTimes({ cwd, collected, directory, filtered = false }) {
|