bivium 0.9.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 +10 -6
- package/cli.js +51 -2192
- package/compute.js +4 -3
- package/config.js +3 -2
- package/docs/api.md +3 -0
- package/docs/ci.md +138 -4
- package/docs/cli.md +101 -3
- package/docs/config.md +115 -0
- package/docs/how-it-works.md +129 -0
- package/docs/tuning.md +24 -1
- package/errors.js +2 -1
- package/index.d.ts +62 -0
- package/package.json +1 -1
- package/shared-1erx1bv8.js +26 -0
- package/shared-6n8bazs5.js +103 -0
- package/shared-8kbmg99n.js +164 -0
- package/shared-9e8vfbjs.js +475 -0
- package/shared-9xwazb0f.js +1047 -0
- package/shared-apgq7xbk.js +13 -0
- package/shared-b9dpffxv.js +30 -0
- package/shared-dyz928f5.js +68 -0
- package/shared-graedbt1.js +12 -0
- package/shared-jee85qxj.js +149 -0
- package/shared-jp8yw63q.js +4 -0
- package/shared-k2ahcc61.js +68 -0
- package/shared-mpjk8met.js +320 -0
- package/shared-nyb7n090.js +655 -0
- package/shared-p3qfqmwd.js +40 -0
- package/{shared-550cvwt2.js → shared-qaqjsxsk.js} +42 -5
- package/shared-vaqyv5nn.js +19 -0
- package/{shared-07rt4zr7.js → shared-wxem8d5w.js} +2162 -1363
- package/shared-211m8fjt.js +0 -69
|
@@ -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");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fixFor2,
|
|
3
|
+
check2,
|
|
4
|
+
failed2,
|
|
5
|
+
summarize2,
|
|
6
|
+
formatReport2
|
|
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
|
+
export {
|
|
14
|
+
check2 as check,
|
|
15
|
+
failed2 as failed,
|
|
16
|
+
fixFor2 as fixFor,
|
|
17
|
+
formatReport2 as formatReport,
|
|
18
|
+
summarize2 as summarize
|
|
19
|
+
};
|