bivium 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cli.js +5 -5
- package/compute.js +4 -4
- package/config.js +3 -3
- package/docs/api.md +2 -0
- package/docs/ci.md +117 -4
- package/docs/cli.md +73 -1
- package/docs/config.md +65 -0
- package/docs/how-it-works.md +30 -0
- package/errors.js +2 -2
- package/index.d.ts +56 -0
- package/package.json +1 -1
- package/{shared-m8z858pr.js → shared-1erx1bv8.js} +3 -3
- package/{shared-y7y281x3.js → shared-6n8bazs5.js} +1 -1
- package/{shared-my87dhfd.js → shared-8kbmg99n.js} +2 -2
- package/{shared-84c9vs8a.js → shared-9e8vfbjs.js} +7 -7
- package/{shared-byhfswm9.js → shared-9xwazb0f.js} +5 -5
- package/{shared-v5gfq9zy.js → shared-apgq7xbk.js} +4 -4
- package/{shared-yfvpkeff.js → shared-b9dpffxv.js} +1 -1
- package/{shared-wahjx628.js → shared-dyz928f5.js} +3 -1
- package/{shared-ke52sg37.js → shared-jee85qxj.js} +2 -2
- package/{shared-x17wzptz.js → shared-jp8yw63q.js} +1 -1
- package/{shared-a5kfg3qy.js → shared-k2ahcc61.js} +2 -2
- package/{shared-a8ebfhzf.js → shared-mpjk8met.js} +2 -1
- package/{shared-rzbfbyqq.js → shared-nyb7n090.js} +130 -24
- package/{shared-118ck8qt.js → shared-p3qfqmwd.js} +1 -1
- package/{shared-px5a17nj.js → shared-qaqjsxsk.js} +42 -5
- package/{shared-qe34axez.js → shared-vaqyv5nn.js} +6 -6
- package/{shared-70w84x4c.js → shared-wxem8d5w.js} +156 -14
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
fanIn2,
|
|
3
3
|
graphReport2,
|
|
4
4
|
formatGraph2
|
|
5
|
-
} from "./shared-
|
|
6
|
-
import"./shared-
|
|
7
|
-
import"./shared-
|
|
8
|
-
import"./shared-
|
|
5
|
+
} from "./shared-8kbmg99n.js";
|
|
6
|
+
import"./shared-qaqjsxsk.js";
|
|
7
|
+
import"./shared-p3qfqmwd.js";
|
|
8
|
+
import"./shared-mpjk8met.js";
|
|
9
9
|
export {
|
|
10
10
|
fanIn2 as fanIn,
|
|
11
11
|
formatGraph2 as formatGraph,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
hideCursor2,
|
|
12
12
|
showCursor2,
|
|
13
13
|
cursorHidden2,
|
|
14
|
+
MISSING2,
|
|
14
15
|
SEPARATOR2,
|
|
15
16
|
branch2,
|
|
16
17
|
NOTE_INDENT2,
|
|
@@ -30,10 +31,11 @@ import {
|
|
|
30
31
|
plural2,
|
|
31
32
|
SILENT2,
|
|
32
33
|
createProgress2
|
|
33
|
-
} from "./shared-
|
|
34
|
+
} from "./shared-mpjk8met.js";
|
|
34
35
|
export {
|
|
35
36
|
ASCII_GLYPHS2 as ASCII_GLYPHS,
|
|
36
37
|
MEASURE2 as MEASURE,
|
|
38
|
+
MISSING2 as MISSING,
|
|
37
39
|
NOTE_INDENT2 as NOTE_INDENT,
|
|
38
40
|
PLAIN2 as PLAIN,
|
|
39
41
|
RULE2 as RULE,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
createPaint2,
|
|
4
4
|
wantsColor2,
|
|
5
5
|
isAgent2
|
|
6
|
-
} from "./shared-
|
|
6
|
+
} from "./shared-mpjk8met.js";
|
|
7
7
|
import {
|
|
8
8
|
BiviumError2,
|
|
9
9
|
didYouMean2
|
|
10
|
-
} from "./shared-
|
|
10
|
+
} from "./shared-p3qfqmwd.js";
|
|
11
11
|
|
|
12
12
|
// src/args.ts
|
|
13
13
|
var VALUED = new Set([
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SEPARATOR2
|
|
3
|
-
} from "./shared-
|
|
3
|
+
} from "./shared-mpjk8met.js";
|
|
4
4
|
import {
|
|
5
5
|
version
|
|
6
|
-
} from "./shared-
|
|
6
|
+
} from "./shared-jp8yw63q.js";
|
|
7
7
|
|
|
8
8
|
// src/help.ts
|
|
9
9
|
var row = (p, name, does, preset) => ` ${name.padEnd(21)}${does}${preset === undefined ? "" : p.dim(`${SEPARATOR2}${preset}`)}`;
|
|
@@ -93,6 +93,7 @@ function showCursor2() {
|
|
|
93
93
|
return SHOW_CURSOR;
|
|
94
94
|
}
|
|
95
95
|
var cursorHidden2 = () => cursor.hidden;
|
|
96
|
+
var MISSING2 = "n/a";
|
|
96
97
|
var SEPARATOR2 = " · ";
|
|
97
98
|
var branch2 = (index, count) => index === count - 1 ? "└ " : "├ ";
|
|
98
99
|
var NOTE_INDENT2 = " ";
|
|
@@ -316,4 +317,4 @@ function createProgress2(write, paint, nowMs, glyphs = UNICODE_GLYPHS2) {
|
|
|
316
317
|
};
|
|
317
318
|
}
|
|
318
319
|
|
|
319
|
-
export { PLAIN2, createPaint2, wantsColor2, isDumb2, isAgent2, UNICODE_GLYPHS2, ASCII_GLYPHS2, markOf2, wantsAscii2, hideCursor2, showCursor2, cursorHidden2, SEPARATOR2, branch2, NOTE_INDENT2, closingLine2, failLine2, keyHints2, nearest2, truncateWords2, truncatePath2, textWidth2, MEASURE2, fitTerminal2, fitWidth2, RULE2, aligned2, headerRow2, plural2, SILENT2, createProgress2 };
|
|
320
|
+
export { PLAIN2, createPaint2, wantsColor2, isDumb2, isAgent2, UNICODE_GLYPHS2, ASCII_GLYPHS2, markOf2, wantsAscii2, hideCursor2, showCursor2, cursorHidden2, MISSING2, SEPARATOR2, branch2, NOTE_INDENT2, closingLine2, failLine2, keyHints2, nearest2, truncateWords2, truncatePath2, textWidth2, MEASURE2, fitTerminal2, fitWidth2, RULE2, aligned2, headerRow2, plural2, SILENT2, createProgress2 };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isDumb2,
|
|
3
|
+
MISSING2,
|
|
3
4
|
SEPARATOR2,
|
|
4
5
|
closingLine2,
|
|
5
6
|
failLine2,
|
|
@@ -13,24 +14,29 @@ import {
|
|
|
13
14
|
plural2,
|
|
14
15
|
SILENT2,
|
|
15
16
|
createProgress2
|
|
16
|
-
} from "./shared-
|
|
17
|
+
} from "./shared-mpjk8met.js";
|
|
17
18
|
import {
|
|
18
19
|
BiviumError2,
|
|
19
20
|
didYouMean2
|
|
20
|
-
} from "./shared-
|
|
21
|
+
} from "./shared-p3qfqmwd.js";
|
|
21
22
|
import {
|
|
22
23
|
usageError2,
|
|
23
24
|
json2
|
|
24
|
-
} from "./shared-
|
|
25
|
-
import"./shared-
|
|
25
|
+
} from "./shared-jee85qxj.js";
|
|
26
|
+
import"./shared-qaqjsxsk.js";
|
|
26
27
|
import {
|
|
27
28
|
formatSelection,
|
|
29
|
+
loadTimings,
|
|
30
|
+
timingsWarning,
|
|
31
|
+
durationsOf,
|
|
32
|
+
longestFirst,
|
|
33
|
+
shardPlan,
|
|
28
34
|
computePlan2,
|
|
29
35
|
prepare2
|
|
30
|
-
} from "./shared-
|
|
36
|
+
} from "./shared-wxem8d5w.js";
|
|
31
37
|
import {
|
|
32
38
|
duration
|
|
33
|
-
} from "./shared-
|
|
39
|
+
} from "./shared-b9dpffxv.js";
|
|
34
40
|
import {
|
|
35
41
|
githubOutputPath,
|
|
36
42
|
nowMs,
|
|
@@ -92,7 +98,35 @@ async function logContext(base, config, computed) {
|
|
|
92
98
|
function caseNotes({ plan }, only) {
|
|
93
99
|
return Object.entries(plan.cases).flatMap(([name, tests]) => only === undefined || name === only ? Object.entries(tests).map(([test, cases]) => `${test} runs ${cases.length} of ${plural2(plan.caseTotals.get(test) ?? cases.length, "case")}: ${cases.join(" ")}`) : []);
|
|
94
100
|
}
|
|
95
|
-
function
|
|
101
|
+
function shardSummaries(config, sharding) {
|
|
102
|
+
return config.suites.flatMap(({ name, shards: spec }) => {
|
|
103
|
+
const shards = sharding.shards[name];
|
|
104
|
+
const timings = sharding.timings[name];
|
|
105
|
+
if (shards === undefined || timings === undefined)
|
|
106
|
+
return [];
|
|
107
|
+
const files = shards.reduce((sum, shard) => sum + shard.files.length, 0);
|
|
108
|
+
const count = plural2(shards.length, "shard");
|
|
109
|
+
const cold = sharding.cold.has(name);
|
|
110
|
+
if (files === 0)
|
|
111
|
+
return [{ name, summary: count, where: "", shards, cold }];
|
|
112
|
+
if (timings.timed === 0) {
|
|
113
|
+
const summary = `${count} by file count${SEPARATOR2}none timed in ${timings.file}`;
|
|
114
|
+
return [{ name, summary, where: "", shards, cold }];
|
|
115
|
+
}
|
|
116
|
+
const target = typeof spec === "object" ? `${SEPARATOR2}target ${duration(spec.targetMs)}, max ${spec.max}` : "";
|
|
117
|
+
const timed = `${timings.timed} of ${plural2(files, "file")} timed`;
|
|
118
|
+
return [
|
|
119
|
+
{
|
|
120
|
+
name,
|
|
121
|
+
summary: `${count}${target}${SEPARATOR2}${timed}`,
|
|
122
|
+
where: ` in ${timings.file}`,
|
|
123
|
+
shards,
|
|
124
|
+
cold
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function logPlan(computed, sharded) {
|
|
96
130
|
const { plan, narrowed } = computed;
|
|
97
131
|
for (const reason of plan.reasons)
|
|
98
132
|
console.log(`Full run: ${reason}`);
|
|
@@ -113,6 +147,36 @@ function logPlan(computed) {
|
|
|
113
147
|
const total = plan.totals[name] ?? 0;
|
|
114
148
|
logSelection(`${name} tests`, selection, total, plan.full.includes(name));
|
|
115
149
|
}
|
|
150
|
+
if (sharded === undefined)
|
|
151
|
+
return;
|
|
152
|
+
const { config, sharding } = sharded;
|
|
153
|
+
for (const { name, summary, where, shards, cold } of shardSummaries(config, sharding)) {
|
|
154
|
+
console.log(`${name} shards: ${summary}${where}`);
|
|
155
|
+
for (const { shard, files, estimatedMs } of shards) {
|
|
156
|
+
const estimate = cold ? "" : `, ${duration(estimatedMs)}`;
|
|
157
|
+
console.log(` shard ${shard}: ${plural2(files.length, "file")}${estimate}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
var SHOWN_SHARDS = 8;
|
|
162
|
+
function shardTables(paint, config, sharding, several) {
|
|
163
|
+
return shardSummaries(config, sharding).flatMap(({ name, summary, shards, cold }) => {
|
|
164
|
+
const note = paint.dim(truncateWords2(`${several ? `${name}: ` : ""}${summary}`, MEASURE2));
|
|
165
|
+
if (shards.length === 0)
|
|
166
|
+
return [];
|
|
167
|
+
const rows = shards.slice(0, SHOWN_SHARDS).map(({ shard, files, estimatedMs }) => [
|
|
168
|
+
String(shard),
|
|
169
|
+
String(files.length),
|
|
170
|
+
cold ? MISSING2 : duration(estimatedMs)
|
|
171
|
+
]);
|
|
172
|
+
const hidden = shards.length - rows.length;
|
|
173
|
+
return [
|
|
174
|
+
"",
|
|
175
|
+
note,
|
|
176
|
+
...aligned2([headerRow2(paint, ["shard", "files", "estimate"]), ...rows], [0, 1, 2], paint.dim),
|
|
177
|
+
...hidden > 0 ? [paint.dim(` + ${plural2(hidden, "more shard")}: --json for each`)] : []
|
|
178
|
+
];
|
|
179
|
+
});
|
|
116
180
|
}
|
|
117
181
|
function verdictOf(name, selection, total, { plan, changed }, used, paint) {
|
|
118
182
|
const suite = Object.keys(plan.suites).length > 1 ? ` (${name})` : "";
|
|
@@ -173,7 +237,7 @@ function countTable(paint, { plan }) {
|
|
|
173
237
|
]
|
|
174
238
|
], right, paint.dim);
|
|
175
239
|
}
|
|
176
|
-
async function showPlan(out, base, config, computed) {
|
|
240
|
+
async function showPlan(out, base, config, computed, sharding) {
|
|
177
241
|
const { paint } = out;
|
|
178
242
|
const { plan, narrowed } = computed;
|
|
179
243
|
const used = new Set;
|
|
@@ -204,6 +268,8 @@ async function showPlan(out, base, config, computed) {
|
|
|
204
268
|
const table = countTable(paint, computed);
|
|
205
269
|
if (table.length > 0)
|
|
206
270
|
lines.push("", ...table);
|
|
271
|
+
const several = Object.keys(plan.suites).length > 1;
|
|
272
|
+
lines.push(...shardTables(paint, config, sharding, several));
|
|
207
273
|
const some = Object.values(plan.suites).some(({ mode }) => mode === "some");
|
|
208
274
|
const cost = duration(nowMs() - out.startMs);
|
|
209
275
|
lines.push("", closingLine2(paint, `Planned ${plural2(planned, "test")}`, some ? `${cost}${SEPARATOR2}--list for the files` : cost));
|
|
@@ -217,18 +283,40 @@ function githubOutput() {
|
|
|
217
283
|
}
|
|
218
284
|
return output;
|
|
219
285
|
}
|
|
220
|
-
|
|
221
|
-
|
|
286
|
+
var LINE_BREAK = /[\r\n]/;
|
|
287
|
+
var LINE_ENDING = /\r?\n/;
|
|
288
|
+
function outputEntry(name, value) {
|
|
289
|
+
if (!LINE_BREAK.test(value))
|
|
290
|
+
return `${name}=${value}
|
|
291
|
+
`;
|
|
292
|
+
const lines = new Set(value.split(LINE_ENDING));
|
|
293
|
+
let delimiter = "BIVIUM_EOF";
|
|
294
|
+
for (let i = 1;lines.has(delimiter); i++)
|
|
295
|
+
delimiter = `BIVIUM_EOF_${i}`;
|
|
296
|
+
return `${name}<<${delimiter}
|
|
297
|
+
${value}
|
|
298
|
+
${delimiter}
|
|
299
|
+
`;
|
|
300
|
+
}
|
|
301
|
+
function matrixOf(shards) {
|
|
302
|
+
return JSON.stringify(shards.map(({ shard, files }) => ({ shard, files: files.join(" ") })));
|
|
303
|
+
}
|
|
304
|
+
function writeOutputs(output, config, { plan }, sharding) {
|
|
305
|
+
const entries = config.suites.map((suite) => {
|
|
222
306
|
const selection = plan.suites[suite.name];
|
|
223
307
|
if (selection === undefined) {
|
|
224
308
|
throw new BiviumError2("BV_INTERNAL", `bivium: plan: no selection for suite "${suite.name}".`);
|
|
225
309
|
}
|
|
226
310
|
const cases = plan.caseLists.get(suite.name);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
311
|
+
const shards = sharding.shards[suite.name];
|
|
312
|
+
return [
|
|
313
|
+
outputEntry(suite.output, formatSelection(selection)),
|
|
314
|
+
cases ? outputEntry(`${suite.name}-cases`, cases.join(" ")) : "",
|
|
315
|
+
shards ? outputEntry(`${suite.name}-matrix`, matrixOf(shards)) : "",
|
|
316
|
+
shards ? outputEntry(`${suite.name}-shards`, String(shards.length)) : ""
|
|
317
|
+
].join("");
|
|
230
318
|
});
|
|
231
|
-
appendFileSync(output,
|
|
319
|
+
appendFileSync(output, entries.join(""));
|
|
232
320
|
}
|
|
233
321
|
function findSuite(config, name) {
|
|
234
322
|
if (name === undefined)
|
|
@@ -265,8 +353,8 @@ function repoPath(root, arg, known) {
|
|
|
265
353
|
}
|
|
266
354
|
async function inspect(command, { flags, positional }, out) {
|
|
267
355
|
const [{ check, failed, formatReport, summarize }, why] = await Promise.all([
|
|
268
|
-
import("./shared-
|
|
269
|
-
import("./shared-
|
|
356
|
+
import("./shared-vaqyv5nn.js"),
|
|
357
|
+
import("./shared-9e8vfbjs.js")
|
|
270
358
|
]);
|
|
271
359
|
const format = flags.get("--format") ?? "tree";
|
|
272
360
|
if (format !== "json" && !why.isFormat(format)) {
|
|
@@ -310,7 +398,7 @@ async function inspect(command, { flags, positional }, out) {
|
|
|
310
398
|
}
|
|
311
399
|
}
|
|
312
400
|
async function whyCommand(root, config, computed, flags, [testArg, fileArg], out) {
|
|
313
|
-
const { explain, formatExplanation, isFormat } = await import("./shared-
|
|
401
|
+
const { explain, formatExplanation, isFormat } = await import("./shared-9e8vfbjs.js");
|
|
314
402
|
const format = flags.get("--format") ?? "tree";
|
|
315
403
|
const inGraph = (path) => computed.graph.has(path);
|
|
316
404
|
const isTest = (path) => config.suites.some((suite) => suite.isTest(path));
|
|
@@ -344,7 +432,7 @@ async function graphCommand({ flags }) {
|
|
|
344
432
|
const { graph } = await computePlan2(root, base, config, {
|
|
345
433
|
...flags.has("--no-cache") && { cache: false }
|
|
346
434
|
});
|
|
347
|
-
const { formatGraph, graphReport } = await import("./shared-
|
|
435
|
+
const { formatGraph, graphReport } = await import("./shared-apgq7xbk.js");
|
|
348
436
|
const report = graphReport(graph, suites);
|
|
349
437
|
console.log(flags.has("--json") ? json2(report) : formatGraph(report, top));
|
|
350
438
|
return 0;
|
|
@@ -369,6 +457,13 @@ async function runCommand(command, { flags, positional }, out) {
|
|
|
369
457
|
mergeBase: true
|
|
370
458
|
});
|
|
371
459
|
if (command === "plan") {
|
|
460
|
+
const sharding = await shardPlan(root, config, computed.plan);
|
|
461
|
+
for (const suite of config.suites) {
|
|
462
|
+
const problem = sharding.timings[suite.name]?.problem;
|
|
463
|
+
if (problem !== undefined) {
|
|
464
|
+
out.io.writeError(timingsWarning("plan", suite, problem));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
372
467
|
if (flags.has("--json")) {
|
|
373
468
|
const { suites, cases, reasons, causes, totals, packages } = computed.plan;
|
|
374
469
|
const narrowed = computed.narrowed.map((ran) => ({
|
|
@@ -386,16 +481,18 @@ async function runCommand(command, { flags, positional }, out) {
|
|
|
386
481
|
causes,
|
|
387
482
|
totals,
|
|
388
483
|
packages,
|
|
389
|
-
narrowed
|
|
484
|
+
narrowed,
|
|
485
|
+
shards: sharding.shards,
|
|
486
|
+
timings: sharding.timings
|
|
390
487
|
}));
|
|
391
488
|
} else if (out.io.stdout && !out.agent && !flags.has("--list")) {
|
|
392
|
-
await showPlan(out, base, config, computed);
|
|
489
|
+
await showPlan(out, base, config, computed, sharding);
|
|
393
490
|
} else {
|
|
394
491
|
await logContext(base, config, computed);
|
|
395
|
-
logPlan(computed);
|
|
492
|
+
logPlan(computed, { config, sharding });
|
|
396
493
|
}
|
|
397
494
|
if (output !== undefined)
|
|
398
|
-
writeOutputs(output, config, computed);
|
|
495
|
+
writeOutputs(output, config, computed, sharding);
|
|
399
496
|
return 0;
|
|
400
497
|
}
|
|
401
498
|
const human = out.io.stdout && !out.agent;
|
|
@@ -415,7 +512,16 @@ async function runCommand(command, { flags, positional }, out) {
|
|
|
415
512
|
}
|
|
416
513
|
return 0;
|
|
417
514
|
}
|
|
418
|
-
|
|
515
|
+
let files = [];
|
|
516
|
+
if (selection.mode === "some") {
|
|
517
|
+
const { recorded, problem } = await loadTimings(root, suite);
|
|
518
|
+
if (problem !== undefined) {
|
|
519
|
+
out.io.writeError(timingsWarning("run", suite, problem));
|
|
520
|
+
}
|
|
521
|
+
const tests = computed.plan.tests[suite.name] ?? [];
|
|
522
|
+
files = longestFirst(selection.files, durationsOf(tests, recorded));
|
|
523
|
+
}
|
|
524
|
+
const [program, ...args] = selection.mode === "some" ? commandFor(suite.run ?? "", files) : suite.runAll !== undefined ? commandFor(suite.runAll, []) : commandFor(suite.run ?? "", suite.roots.filter((root) => root !== "."));
|
|
419
525
|
if (program === undefined) {
|
|
420
526
|
throw usageError2("BV_NO_RUN_COMMAND", `bivium run: suite "${suite.name}" has no run command: add suites.${suite.name}.run to the config`);
|
|
421
527
|
}
|
|
@@ -444,7 +550,7 @@ async function runCommand(command, { flags, positional }, out) {
|
|
|
444
550
|
var SIGNAL_NAMES = { SIGINT: "Ctrl-C", SIGTERM: "SIGTERM" };
|
|
445
551
|
var PASS_ON_MS = 1000;
|
|
446
552
|
async function runSuite(program, args, root, name, out, human, env) {
|
|
447
|
-
const { EXIT_INTERRUPTED, exitCodeOf, handleInterrupt } = await import("./shared-
|
|
553
|
+
const { EXIT_INTERRUPTED, exitCodeOf, handleInterrupt } = await import("./shared-6n8bazs5.js");
|
|
448
554
|
const started = nowMs();
|
|
449
555
|
const child = spawn(program, args, {
|
|
450
556
|
cwd: root,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BiviumError2,
|
|
3
3
|
didYouMean2
|
|
4
|
-
} from "./shared-
|
|
4
|
+
} from "./shared-p3qfqmwd.js";
|
|
5
5
|
|
|
6
6
|
// src/config.ts
|
|
7
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -131,6 +131,9 @@ function optional(key, value) {
|
|
|
131
131
|
out[key] = value;
|
|
132
132
|
return out;
|
|
133
133
|
}
|
|
134
|
+
function timingsOf(suite) {
|
|
135
|
+
return `.bivium/timings/${suite}.json`;
|
|
136
|
+
}
|
|
134
137
|
function resolveConfig2(config) {
|
|
135
138
|
const names = Object.keys(config.suites);
|
|
136
139
|
if (names.length === 0)
|
|
@@ -151,8 +154,12 @@ function resolveConfig2(config) {
|
|
|
151
154
|
setup: list(suite.setup, []),
|
|
152
155
|
isNonInput: matcher(suite.nonInputs),
|
|
153
156
|
output: suite.output ?? `${name}-tests`,
|
|
154
|
-
types: suite.types ?? true
|
|
157
|
+
types: suite.types ?? true,
|
|
158
|
+
timings: normalizeRoot(suite.timings ?? timingsOf(name)),
|
|
159
|
+
...optional("shards", suite.shards)
|
|
155
160
|
}));
|
|
161
|
+
const timings = new Set(suites.map((suite) => suite.timings));
|
|
162
|
+
const ignored = matcher(config.ignore);
|
|
156
163
|
const narrowers = (config.narrowers ?? []).map((narrower) => {
|
|
157
164
|
const unknown = narrower.suites?.find((name) => !names.includes(name));
|
|
158
165
|
if (unknown !== undefined) {
|
|
@@ -170,7 +177,7 @@ function resolveConfig2(config) {
|
|
|
170
177
|
suites,
|
|
171
178
|
narrowers,
|
|
172
179
|
roots: list(config.roots, ["."]).map(normalizeRoot),
|
|
173
|
-
isIgnored:
|
|
180
|
+
isIgnored: (path) => timings.has(path) || ignored(path),
|
|
174
181
|
alias: Object.entries(config.alias ?? {}).map(([key, path]) => [
|
|
175
182
|
key.replace(TRAILING_SLASHES, "") || key,
|
|
176
183
|
normalizeRoot(path)
|
|
@@ -237,8 +244,11 @@ var SUITE_KEYS = new Set([
|
|
|
237
244
|
"setup",
|
|
238
245
|
"nonInputs",
|
|
239
246
|
"output",
|
|
240
|
-
"types"
|
|
247
|
+
"types",
|
|
248
|
+
"timings",
|
|
249
|
+
"shards"
|
|
241
250
|
]);
|
|
251
|
+
var SHARD_KEYS = new Set(["targetMs", "max"]);
|
|
242
252
|
var NARROWER_KEYS = new Set(["name", "match", "opaque", "suites", "narrow"]);
|
|
243
253
|
var DEAD_GLOB_KEYS = new Set(["file", "glob", "reason"]);
|
|
244
254
|
var KNOWN_UNKNOWN_KEYS = new Set(["file", "reason"]);
|
|
@@ -277,6 +287,8 @@ function unknownKeys(value) {
|
|
|
277
287
|
if (isRecord(value.suites)) {
|
|
278
288
|
for (const [name, suite] of Object.entries(value.suites)) {
|
|
279
289
|
visit(suite, SUITE_KEYS, `suites.${name}.`);
|
|
290
|
+
if (isRecord(suite))
|
|
291
|
+
visit(suite.shards, SHARD_KEYS, `suites.${name}.shards.`);
|
|
280
292
|
}
|
|
281
293
|
}
|
|
282
294
|
const lists = [
|
|
@@ -315,9 +327,34 @@ function checkSuite(name, value) {
|
|
|
315
327
|
...optional("setup", field(value, "setup", isGlobs, at, globs)),
|
|
316
328
|
...optional("nonInputs", field(value, "nonInputs", isGlobs, at, globs)),
|
|
317
329
|
...optional("output", field(value, "output", isString, at, "an output name")),
|
|
318
|
-
...optional("types", field(value, "types", isBoolean, at, "a boolean"))
|
|
330
|
+
...optional("types", field(value, "types", isBoolean, at, "a boolean")),
|
|
331
|
+
...optional("timings", field(value, "timings", isString, at, "a path")),
|
|
332
|
+
...optional("shards", shardsOf(value.shards, at))
|
|
319
333
|
};
|
|
320
334
|
}
|
|
335
|
+
var MAX_SHARDS = 256;
|
|
336
|
+
function isShardCount(value) {
|
|
337
|
+
return Number.isInteger(value) && Number(value) >= 1 && Number(value) <= MAX_SHARDS;
|
|
338
|
+
}
|
|
339
|
+
function shardsOf(value, at) {
|
|
340
|
+
if (value === undefined || isShardCount(value))
|
|
341
|
+
return value;
|
|
342
|
+
const expected = `a whole number from 1 to ${MAX_SHARDS}, or { targetMs, max }`;
|
|
343
|
+
if (!isRecord(value)) {
|
|
344
|
+
throw new Error(`bivium config: ${at}shards must be ${expected}`);
|
|
345
|
+
}
|
|
346
|
+
const { targetMs, max } = value;
|
|
347
|
+
if (targetMs === undefined || max === undefined) {
|
|
348
|
+
throw new Error(`bivium config: ${at}shards needs a targetMs and a max`);
|
|
349
|
+
}
|
|
350
|
+
if (typeof targetMs !== "number" || !Number.isFinite(targetMs) || targetMs <= 0) {
|
|
351
|
+
throw new Error(`bivium config: ${at}shards.targetMs must be a duration in milliseconds above 0`);
|
|
352
|
+
}
|
|
353
|
+
if (!isShardCount(max)) {
|
|
354
|
+
throw new Error(`bivium config: ${at}shards.max must be a whole number from 1 to ${MAX_SHARDS}`);
|
|
355
|
+
}
|
|
356
|
+
return { targetMs, max };
|
|
357
|
+
}
|
|
321
358
|
var WILDCARD = /[*?{}[\]]/;
|
|
322
359
|
function paths(record, key, at) {
|
|
323
360
|
const value = field(record, key, isGlobs, at, "a path or a list of paths");
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
failed2,
|
|
5
5
|
summarize2,
|
|
6
6
|
formatReport2
|
|
7
|
-
} from "./shared-
|
|
8
|
-
import"./shared-
|
|
9
|
-
import"./shared-
|
|
10
|
-
import"./shared-
|
|
11
|
-
import"./shared-
|
|
12
|
-
import"./shared-
|
|
7
|
+
} from "./shared-9xwazb0f.js";
|
|
8
|
+
import"./shared-8kbmg99n.js";
|
|
9
|
+
import"./shared-b9dpffxv.js";
|
|
10
|
+
import"./shared-qaqjsxsk.js";
|
|
11
|
+
import"./shared-p3qfqmwd.js";
|
|
12
|
+
import"./shared-mpjk8met.js";
|
|
13
13
|
export {
|
|
14
14
|
check2 as check,
|
|
15
15
|
failed2 as failed,
|