bivium 0.6.2 → 0.8.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 +26 -22
- package/cli.js +652 -298
- package/compute.js +20 -0
- package/config.js +15 -0
- package/docs/api.md +5 -1
- package/docs/ci.md +4 -2
- package/docs/cli.md +93 -13
- package/docs/config.md +19 -12
- package/docs/how-it-works.md +18 -3
- package/docs/recipes.md +6 -4
- package/docs/tuning.md +35 -29
- package/errors.js +8 -0
- package/index.d.ts +22 -27
- package/index.js +8 -7
- package/package.json +1 -1
- package/shared-211m8fjt.js +69 -0
- package/shared-550cvwt2.js +503 -0
- package/{shared.js → shared-9qcbzxw3.js} +1652 -2046
package/compute.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readSources2,
|
|
3
|
+
collectPackages2,
|
|
4
|
+
extractRevision2,
|
|
5
|
+
graphView2,
|
|
6
|
+
computePlan2,
|
|
7
|
+
prepare2,
|
|
8
|
+
plan2
|
|
9
|
+
} from "./shared-9qcbzxw3.js";
|
|
10
|
+
import"./shared-550cvwt2.js";
|
|
11
|
+
import"./shared-211m8fjt.js";
|
|
12
|
+
export {
|
|
13
|
+
collectPackages2 as collectPackages,
|
|
14
|
+
computePlan2 as computePlan,
|
|
15
|
+
extractRevision2 as extractRevision,
|
|
16
|
+
graphView2 as graphView,
|
|
17
|
+
plan2 as plan,
|
|
18
|
+
prepare2 as prepare,
|
|
19
|
+
readSources2 as readSources
|
|
20
|
+
};
|
package/config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineConfig2,
|
|
3
|
+
resolveConfig2,
|
|
4
|
+
inRoot2,
|
|
5
|
+
checkConfig2,
|
|
6
|
+
loadConfig2
|
|
7
|
+
} from "./shared-550cvwt2.js";
|
|
8
|
+
import"./shared-211m8fjt.js";
|
|
9
|
+
export {
|
|
10
|
+
checkConfig2 as checkConfig,
|
|
11
|
+
defineConfig2 as defineConfig,
|
|
12
|
+
inRoot2 as inRoot,
|
|
13
|
+
loadConfig2 as loadConfig,
|
|
14
|
+
resolveConfig2 as resolveConfig
|
|
15
|
+
};
|
package/docs/api.md
CHANGED
|
@@ -111,10 +111,14 @@ It returns one of two shapes:
|
|
|
111
111
|
A narrower that throws, or returns anything else,
|
|
112
112
|
runs its suites in full with the reason too.
|
|
113
113
|
|
|
114
|
-
carbon-components-svelte runs one
|
|
114
|
+
carbon-components-svelte runs one built on
|
|
115
|
+
[crassus](https://github.com/metonym/crassus), a CSS cascade
|
|
116
|
+
regression tool.
|
|
115
117
|
|
|
116
118
|
## Related
|
|
117
119
|
|
|
118
120
|
- [Config](config.md): `defineConfig` and every key
|
|
119
121
|
- [CLI](cli.md): the same plan from the command line
|
|
120
122
|
- [How it works](how-it-works.md): the graph a plan walks
|
|
123
|
+
- [Not supported](how-it-works.md#not-supported): what bivium leaves to
|
|
124
|
+
other tools
|
package/docs/ci.md
CHANGED
|
@@ -120,8 +120,8 @@ when no key matches exactly.
|
|
|
120
120
|
The cache lives in `node_modules/.cache/bivium`
|
|
121
121
|
when `node_modules` exists, and in `.bivium/cache` otherwise.
|
|
122
122
|
The plan job runs before any install, so its cache is `.bivium/cache`.
|
|
123
|
-
bivium writes a `.gitignore` there, so the cache never shows up as
|
|
124
|
-
change.
|
|
123
|
+
bivium writes a `.gitignore` there, so the cache never shows up as
|
|
124
|
+
a change.
|
|
125
125
|
|
|
126
126
|
## What a plan costs
|
|
127
127
|
|
|
@@ -146,3 +146,5 @@ and 124 MB on Node.
|
|
|
146
146
|
- [CLI](cli.md): `plan --github` and the other commands
|
|
147
147
|
- [Config](config.md): a suite's `output`, and `cache`
|
|
148
148
|
- [How it works](how-it-works.md): what a plan reads
|
|
149
|
+
- [Not supported](how-it-works.md#not-supported): what bivium leaves to
|
|
150
|
+
other tools
|
package/docs/cli.md
CHANGED
|
@@ -24,11 +24,39 @@ It has five commands:
|
|
|
24
24
|
`plan` prints the tests each suite needs for the changes since a base.
|
|
25
25
|
|
|
26
26
|
```sh
|
|
27
|
-
bivium plan [base] [--json] [--github]
|
|
27
|
+
bivium plan [base] [--json] [--github] [--list]
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
`base` defaults to the config's `base`,
|
|
31
31
|
else the upstream default branch.
|
|
32
|
+
|
|
33
|
+
On a terminal, each suite gets a verdict first:
|
|
34
|
+
how many of its tests run, and for how many changed files;
|
|
35
|
+
or that all of them run, or none, and why.
|
|
36
|
+
A gray line says what it planned against: the base, its merge base,
|
|
37
|
+
and the config file.
|
|
38
|
+
Lines for each other full-run cause,
|
|
39
|
+
package change and narrower note follow it.
|
|
40
|
+
Then a table counts the selected tests by folder,
|
|
41
|
+
and a last line says how many tests it planned and what that took:
|
|
42
|
+
|
|
43
|
+
```console
|
|
44
|
+
$ bunx bivium plan
|
|
45
|
+
3 of 12 tests run for 1 changed file (unit)
|
|
46
|
+
no tests run (e2e): no change reaches a test
|
|
47
|
+
since origin/main (merge base 6b844dd) · config bivium.config.ts
|
|
48
|
+
|
|
49
|
+
directory unit
|
|
50
|
+
tests/* 2
|
|
51
|
+
tests/css/ 1
|
|
52
|
+
────
|
|
53
|
+
2 directories 3
|
|
54
|
+
|
|
55
|
+
✓ Planned 3 tests · 323 ms · --list for the files
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Piped, run by a coding agent, or with `--list`,
|
|
59
|
+
it prints the files instead.
|
|
32
60
|
The first line says what it planned against: the base, its merge base,
|
|
33
61
|
how many files changed, and the config file.
|
|
34
62
|
Then each suite gets one line:
|
|
@@ -42,6 +70,7 @@ Then each suite gets one line:
|
|
|
42
70
|
|
|
43
71
|
Options:
|
|
44
72
|
|
|
73
|
+
- `--list` prints the files on a terminal too, as a pipe gets them.
|
|
45
74
|
- `--json` prints the plan as data, with the fields below.
|
|
46
75
|
- `--github` also writes each suite's selection to `$GITHUB_OUTPUT` as
|
|
47
76
|
`<output>=all`, `none`, or the files separated by spaces.
|
|
@@ -74,12 +103,31 @@ bivium run [base] [--suite <name>]
|
|
|
74
103
|
- `--suite <name>` picks the suite.
|
|
75
104
|
Default: the first one in the config.
|
|
76
105
|
|
|
77
|
-
It prints the plan first, as `plan` does.
|
|
78
106
|
The selected files go where the command says `{files}`, or at its end.
|
|
79
|
-
When every test is selected,
|
|
80
|
-
so
|
|
81
|
-
|
|
82
|
-
|
|
107
|
+
When every test is selected, the suite's `root` goes there instead,
|
|
108
|
+
so a runner that would run every suite's tests runs only this one's;
|
|
109
|
+
`runAll` in the config replaces the command for that case.
|
|
110
|
+
When no test is selected, `run` skips the command and exits 0.
|
|
111
|
+
Otherwise it exits with the command's status,
|
|
112
|
+
or 130 when Ctrl-C interrupted it.
|
|
113
|
+
|
|
114
|
+
On a terminal, it opens as `plan` does, names the suites it didn't run,
|
|
115
|
+
echoes the command, then closes with the result:
|
|
116
|
+
|
|
117
|
+
```console
|
|
118
|
+
$ bivium run main
|
|
119
|
+
1 of 2 tests run for 1 changed file (unit)
|
|
120
|
+
since main (merge base f601cb4) · config bivium.config.ts
|
|
121
|
+
running unit · 2 more suites: --suite=e2e, --suite=visual
|
|
122
|
+
$ bun test tests/unit/name.test.ts
|
|
123
|
+
|
|
124
|
+
…the runner's output…
|
|
125
|
+
|
|
126
|
+
✓ unit passed · 247 ms
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Piped, or for a coding agent, it prints the plan as text,
|
|
130
|
+
then the runner's output.
|
|
83
131
|
|
|
84
132
|
```sh
|
|
85
133
|
bivium run --suite e2e
|
|
@@ -128,7 +176,7 @@ bivium why tests/Button.test.ts src/Button.svelte --format chain
|
|
|
128
176
|
each with where it is and how to fix it.
|
|
129
177
|
|
|
130
178
|
```sh
|
|
131
|
-
bivium check [--base <ref>] [--max-unknown <n>] [--json]
|
|
179
|
+
bivium check [--base <ref>] [--max-unknown <n>] [--all] [--json]
|
|
132
180
|
```
|
|
133
181
|
|
|
134
182
|
A node is a file, a barrel name, or a package in the graph.
|
|
@@ -138,9 +186,34 @@ Every test that reaches one runs on every change.
|
|
|
138
186
|
A changed file under a suite's `root` that no test reaches runs the
|
|
139
187
|
whole suite: the orphan rule.
|
|
140
188
|
|
|
141
|
-
`check` leads with
|
|
189
|
+
`check` leads with a verdict: how many files it can't follow,
|
|
190
|
+
and how many tests those run on every change.
|
|
191
|
+
A gray line counts the rest.
|
|
192
|
+
Then each cause gets a section: the cause, how many,
|
|
193
|
+
up to three places it's at, and its fix once.
|
|
194
|
+
A place whose fix differs carries its own.
|
|
195
|
+
A last line says whether the check passes, and what failed:
|
|
196
|
+
|
|
197
|
+
```console
|
|
198
|
+
$ bunx bivium check
|
|
199
|
+
2 files bivium can't follow send 2 tests to every change
|
|
200
|
+
|
|
201
|
+
reads the disk without @depends-on · 2 files
|
|
202
|
+
├ test/u.test.js:1
|
|
203
|
+
└ test/w.test.js:1
|
|
204
|
+
fix name what it reads: `// @depends-on <glob>`, or `// @reads <glob>` for…
|
|
205
|
+
|
|
206
|
+
unresolved relative import · 1 import in 1 file
|
|
207
|
+
└ test/u.test.js:2 "./gone.js"
|
|
208
|
+
fix no file at that path: fix the import, or add an `edges` entry if a build…
|
|
209
|
+
|
|
210
|
+
✓ Check passes · checked in 152 ms · --all for every file
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The sections cover:
|
|
142
214
|
|
|
143
|
-
- every unknown
|
|
215
|
+
- every unknown a test reaches, by cause,
|
|
216
|
+
with where and how to fix each;
|
|
144
217
|
- unknowns no test depends on, apart and not counted toward
|
|
145
218
|
`--max-unknown`: plans only run tests, so these widen nothing;
|
|
146
219
|
- files under a suite's `root` that no test reaches,
|
|
@@ -161,6 +234,8 @@ whole suite: the orphan rule.
|
|
|
161
234
|
|
|
162
235
|
Options:
|
|
163
236
|
|
|
237
|
+
- `--all` lists every place, and each fix whole.
|
|
238
|
+
`--json` has the rest, such as the tests each unknown runs.
|
|
164
239
|
- `--max-unknown <n>` fails when more than `n` unknowns reach a test.
|
|
165
240
|
- `--base <ref>` sets the base.
|
|
166
241
|
Default: `HEAD`.
|
|
@@ -208,6 +283,9 @@ These work with every command, before or after it:
|
|
|
208
283
|
- `--cwd <dir>`: the repository.
|
|
209
284
|
Default: the current directory.
|
|
210
285
|
- `--no-cache`: read every file, and skip the extraction cache.
|
|
286
|
+
- `--color` or `--no-color`: force color on or off.
|
|
287
|
+
Default: on when stdout is a terminal and no coding agent runs it;
|
|
288
|
+
`NO_COLOR` and `FORCE_COLOR` are read too.
|
|
211
289
|
- `--help` or `-h`: print usage.
|
|
212
290
|
- `--version` or `-v`: print the version.
|
|
213
291
|
|
|
@@ -217,8 +295,8 @@ A path can be repo-relative, relative to the current directory
|
|
|
217
295
|
(`./tests/a.test.ts`), or absolute.
|
|
218
296
|
|
|
219
297
|
An unknown command, option, suite, test, or `--format` is an error.
|
|
220
|
-
The message names what's close, when something
|
|
221
|
-
`unknown option --jsno (did you mean --json?)`.
|
|
298
|
+
The message names what's close, when something
|
|
299
|
+
is: `unknown option --jsno (did you mean --json?)`.
|
|
222
300
|
|
|
223
301
|
## Exit status
|
|
224
302
|
|
|
@@ -267,8 +345,8 @@ Each command has a JSON form that answers one question:
|
|
|
267
345
|
- `bivium plan --json` gives the selection per suite and why:
|
|
268
346
|
`causes` (typed) for each full run, `totals` for the scale,
|
|
269
347
|
and `changed`, `base`, and `mergeBase`.
|
|
270
|
-
- `bivium why <test> --format json` gives the chain from a change to
|
|
271
|
-
test.
|
|
348
|
+
- `bivium why <test> --format json` gives the chain from a change to
|
|
349
|
+
a test.
|
|
272
350
|
Each link has a `kind`, such as `import` or `goto`, and an `at`,
|
|
273
351
|
as `file:line`.
|
|
274
352
|
- `bivium check --json` gives `ok` and a `summary` of what widens plans,
|
|
@@ -357,3 +435,5 @@ tests/e2e.test.ts runs on every change
|
|
|
357
435
|
- [CI](ci.md): planning in GitHub Actions
|
|
358
436
|
- [Tuning a plan](tuning.md): fixing what `check` reports
|
|
359
437
|
- [API](api.md): the same plan from code
|
|
438
|
+
- [Not supported](how-it-works.md#not-supported): what bivium leaves to
|
|
439
|
+
other tools
|
package/docs/config.md
CHANGED
|
@@ -44,6 +44,7 @@ a set of test files and the command that runs them.
|
|
|
44
44
|
|:---|:---|:---|
|
|
45
45
|
| `tests` | The suite's test files | required |
|
|
46
46
|
| `run` | The command `bivium run` runs | none; `bivium run` needs one |
|
|
47
|
+
| `runAll` | The command for a full run, when every test is selected | `run`, with `root` for `{files}` |
|
|
47
48
|
| `root` | Where the orphan rule applies | the whole repository |
|
|
48
49
|
| `urls` | URL pattern → the page a `page.goto()` opens | none |
|
|
49
50
|
| `pages` | Pages only a `goto()` opens | none |
|
|
@@ -57,9 +58,12 @@ a set of test files and the command that runs them.
|
|
|
57
58
|
|
|
58
59
|
`bivium run` puts the selected files where `{files}` is:
|
|
59
60
|
`vitest run {files}` runs `vitest run tests/a.test.ts tests/b.test.ts`.
|
|
60
|
-
When the whole suite is selected, `{files}` becomes
|
|
61
|
-
|
|
61
|
+
When the whole suite is selected, `{files}` becomes the suite's `root`,
|
|
62
|
+
`vitest run tests`, since a bare `vitest run` or `bun test` would run
|
|
63
|
+
every suite's tests; without a `root`, it becomes nothing.
|
|
62
64
|
Without `{files}`, the files go at the end of the command.
|
|
65
|
+
When the runner needs another command for a full run,
|
|
66
|
+
set `runAll`: `runAll: "playwright test --project=e2e"`.
|
|
63
67
|
|
|
64
68
|
### `root` and the orphan rule
|
|
65
69
|
|
|
@@ -93,8 +97,8 @@ The rest become edges where their files exist.
|
|
|
93
97
|
`pages` lists the pages only a `goto()` opens.
|
|
94
98
|
A listed page that no test opens is wired to no test,
|
|
95
99
|
and so are the files only such pages load.
|
|
96
|
-
A change to one selects nothing, and doesn't run the suite by the
|
|
97
|
-
rule.
|
|
100
|
+
A change to one selects nothing, and doesn't run the suite by the
|
|
101
|
+
orphan rule.
|
|
98
102
|
|
|
99
103
|
### `setup` and `wiring`
|
|
100
104
|
|
|
@@ -201,8 +205,8 @@ or vouch that they read nothing in the repository.
|
|
|
201
205
|
|
|
202
206
|
### `edges`
|
|
203
207
|
|
|
204
|
-
`edges` maps a generated file to the inputs a build makes it
|
|
205
|
-
`{ "dist/*.css": "styles/**" }`.
|
|
208
|
+
`edges` maps a generated file to the inputs a build makes it
|
|
209
|
+
from: `{ "dist/*.css": "styles/**" }`.
|
|
206
210
|
The generated file depends on its inputs transitively,
|
|
207
211
|
as with `@depends-on`.
|
|
208
212
|
|
|
@@ -212,13 +216,14 @@ An import that resolves under the key, by extension or as an index,
|
|
|
212
216
|
then lands on that file instead of being unresolved.
|
|
213
217
|
|
|
214
218
|
In a value, `$1`, `$2`… stand for what the key's wildcards matched,
|
|
215
|
-
counted from the
|
|
216
|
-
`{ "examples/*/package.json": "examples/$1/**" }`.
|
|
219
|
+
counted from the
|
|
220
|
+
left: `{ "examples/*/package.json": "examples/$1/**" }`.
|
|
217
221
|
|
|
218
222
|
### `reads`
|
|
219
223
|
|
|
220
|
-
`reads` maps a file to the files it reads as text,
|
|
221
|
-
`
|
|
224
|
+
`reads` maps a file to the files it reads as text,
|
|
225
|
+
as `@reads`
|
|
226
|
+
does: `{ "tests/*.test.ts": "tests/__snapshots__/$1.test.ts.snap" }`.
|
|
222
227
|
Only a direct change to a read file counts:
|
|
223
228
|
its imports and unknowns don't spread to the reader.
|
|
224
229
|
Values take `$1`… as in `edges`.
|
|
@@ -262,8 +267,8 @@ bivium itself is always inert.
|
|
|
262
267
|
or a plugin a config names by string.
|
|
263
268
|
Setting it, even to `[]`, says every other package without a `bin` is
|
|
264
269
|
loaded only by imports.
|
|
265
|
-
A lockfile change that reaches one no test imports
|
|
266
|
-
importers.
|
|
270
|
+
A lockfile change that reaches one no test imports
|
|
271
|
+
then selects only its importers.
|
|
267
272
|
A package with a `bin` always counts as one a test may run.
|
|
268
273
|
|
|
269
274
|
## What `check` allows
|
|
@@ -342,3 +347,5 @@ whatever loads an entry names it itself.
|
|
|
342
347
|
- [Recipes](recipes.md): Vitest, Jest, Playwright, pnpm workspaces,
|
|
343
348
|
generated code
|
|
344
349
|
- [How it works](how-it-works.md): what the graph follows
|
|
350
|
+
- [Not supported](how-it-works.md#not-supported): what bivium leaves to
|
|
351
|
+
other tools
|
package/docs/how-it-works.md
CHANGED
|
@@ -93,9 +93,10 @@ so bivium reads it:
|
|
|
93
93
|
|
|
94
94
|
```console
|
|
95
95
|
$ bunx bivium plan
|
|
96
|
+
4 of 12 tests run for 1 changed file
|
|
97
|
+
since origin/main (merge base 1c0ffee) · config bivium.config.ts
|
|
96
98
|
bun.lock: @biomejs/biome 2.5.14 → 2.6.3, inert
|
|
97
99
|
bun.lock: svelte 5.57.1 → 5.57.2
|
|
98
|
-
unit tests: 4 of 12 files
|
|
99
100
|
…
|
|
100
101
|
```
|
|
101
102
|
|
|
@@ -118,8 +119,8 @@ A changed package can also be used in ways the graph can't see:
|
|
|
118
119
|
a CLI a test spawns, a runner, a type package.
|
|
119
120
|
So when a change reaches a package that a `package.json` declares
|
|
120
121
|
or some file imports, and no test imports it, everything runs.
|
|
121
|
-
The plan names the
|
|
122
|
-
(`bun.lock: playwright 1.63.0 → 1.64.0, and no test imports it`).
|
|
122
|
+
The plan names the
|
|
123
|
+
reason (`bun.lock: playwright 1.63.0 → 1.64.0, and no test imports it`).
|
|
123
124
|
A package in `inert` is the exception:
|
|
124
125
|
`inert` lists packages no test uses except by importing them,
|
|
125
126
|
such as linters and formatters.
|
|
@@ -145,6 +146,20 @@ Other lockfiles (`yarn.lock`, `bun.lockb`, `npm-shrinkwrap.json`) are
|
|
|
145
146
|
files like any other.
|
|
146
147
|
Outside the roots, a change to one runs everything.
|
|
147
148
|
|
|
149
|
+
## Not supported
|
|
150
|
+
|
|
151
|
+
What bivium leaves to other tools, and what to use instead:
|
|
152
|
+
|
|
153
|
+
| bivium doesn't | Instead |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| run your tests | `bivium run` hands the selection to your runner's command |
|
|
156
|
+
| read your runner's config | name its setup files in a suite's `setup` |
|
|
157
|
+
| scan CSS | `edges` from a stylesheet to its sources, or a [narrower](api.md#narrowers) |
|
|
158
|
+
| parse `yarn.lock` or `bun.lockb` | they're files like any other, so a change to one doesn't seed packages |
|
|
159
|
+
| select below the file | a test file is selected whole, every case in it |
|
|
160
|
+
| follow an import it can't read | the file counts as depending on every change, so its tests always run |
|
|
161
|
+
| build or cache outputs | Nx, Turborepo, or Bazel, which skip whole projects |
|
|
162
|
+
|
|
148
163
|
## Compared with
|
|
149
164
|
|
|
150
165
|
Tools that select or skip tests differ in what they select
|
package/docs/recipes.md
CHANGED
|
@@ -46,8 +46,8 @@ which the imports alone don't show:
|
|
|
46
46
|
`src/a/Button.test.tsx` reads
|
|
47
47
|
`src/a/__snapshots__/Button.test.tsx.snap`.
|
|
48
48
|
|
|
49
|
-
For Jest, set `run` to your Jest command
|
|
50
|
-
`setupFiles`.
|
|
49
|
+
For Jest, set `run` to your Jest command
|
|
50
|
+
and `setup` to Jest's `setupFiles`.
|
|
51
51
|
bivium reads tsconfig `paths` itself, as `vite-tsconfig-paths` does,
|
|
52
52
|
so they need no `alias`.
|
|
53
53
|
An extensionless `vi.mock("@/x")` resolves as an import does.
|
|
@@ -75,8 +75,8 @@ Set `roots` to the packages and apps whose changes the suites need to
|
|
|
75
75
|
see; a changed file outside them that isn't ignored runs everything.
|
|
76
76
|
|
|
77
77
|
Workspace packages resolve through their `package.json` `exports`.
|
|
78
|
-
A `.js` specifier into one (`@acme/ui/Button.js`) reaches its
|
|
79
|
-
source.
|
|
78
|
+
A `.js` specifier into one (`@acme/ui/Button.js`) reaches its
|
|
79
|
+
`.ts` source.
|
|
80
80
|
A `pnpm-lock.yaml` change selects through the packages it changed
|
|
81
81
|
(see [Lockfiles](how-it-works.md#lockfiles)).
|
|
82
82
|
|
|
@@ -133,3 +133,5 @@ and the generator's config, and not every change.
|
|
|
133
133
|
|
|
134
134
|
- [Config](config.md): every key
|
|
135
135
|
- [Tuning a plan](tuning.md): when a plan still runs too much
|
|
136
|
+
- [Not supported](how-it-works.md#not-supported): what bivium leaves to
|
|
137
|
+
other tools
|
package/docs/tuning.md
CHANGED
|
@@ -10,26 +10,30 @@ or `vitest.config.ts` runs the whole suite:
|
|
|
10
10
|
|
|
11
11
|
```console
|
|
12
12
|
$ bunx bivium plan
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
all 4 tests run: README.md: no unit test imports it
|
|
14
|
+
since origin/main (merge base 9236bd3) · config bivium.config.ts
|
|
15
|
+
full run: vitest.config.ts: no unit test imports it
|
|
16
|
+
|
|
17
|
+
✓ Planned 4 tests · 256 ms
|
|
16
18
|
```
|
|
17
19
|
|
|
18
20
|
`bivium check` lists those files before they change, each with a fix:
|
|
19
21
|
|
|
20
22
|
```console
|
|
21
|
-
$ bunx bivium check
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
$ bunx bivium check --all
|
|
24
|
+
bivium can follow every file a test reaches
|
|
25
|
+
2 files no test reaches
|
|
26
|
+
|
|
27
|
+
no test reaches: a change runs the whole suite · 2 files in suite unit
|
|
28
|
+
├ README.md
|
|
29
|
+
fix if a test reads or runs it, say so with `reads` or `@depends-on` in that
|
|
30
|
+
test or what loads it; if none can observe it, list it in the suite's
|
|
31
|
+
`nonInputs`, or delete it if it's dead
|
|
32
|
+
└ vitest.config.ts
|
|
33
|
+
fix if the runner loads it, name it in the suite's `wiring` (or `setup`, if
|
|
34
|
+
it runs before every test), which makes the full run deliberate
|
|
35
|
+
|
|
36
|
+
✓ Check passes · checked in 254 ms
|
|
33
37
|
```
|
|
34
38
|
|
|
35
39
|
## A change no test reaches
|
|
@@ -130,14 +134,14 @@ takes `// @lists <path>`.
|
|
|
130
134
|
## Dead globs
|
|
131
135
|
|
|
132
136
|
A dead glob is a pattern that looks fine and never selects its file,
|
|
133
|
-
such as a typo'd `@depends-on`, or one that points only at files
|
|
134
|
-
skips.
|
|
137
|
+
such as a typo'd `@depends-on`, or one that points only at files
|
|
138
|
+
bivium skips.
|
|
135
139
|
`check` looks for them.
|
|
136
140
|
It tests these patterns against every file git lists,
|
|
137
141
|
tracked or untracked, inside the roots or not:
|
|
138
142
|
|
|
139
|
-
- every `@depends-on`, `@reads`, `@lists`
|
|
140
|
-
pattern;
|
|
143
|
+
- every `@depends-on`, `@reads`, `@lists`
|
|
144
|
+
and `import.meta.glob` pattern;
|
|
141
145
|
- every `edges` and `reads` value;
|
|
142
146
|
- every suite's `setup`.
|
|
143
147
|
|
|
@@ -151,16 +155,16 @@ It reports a pattern with one of these problems:
|
|
|
151
155
|
|
|
152
156
|
```console
|
|
153
157
|
$ bunx bivium check
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
tests/a.test.ts
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
bivium can follow every file a test reaches
|
|
159
|
+
2 dead globs
|
|
160
|
+
|
|
161
|
+
dead glob: a change to what it matches selects nothing · 2 globs in 1 file
|
|
162
|
+
├ tests/a.test.ts:1 depends-on docs/**: matches only ignored files (1…
|
|
163
|
+
fix point it at files the selector reads, or allowlist it in `deadGlobs`…
|
|
164
|
+
└ tests/a.test.ts:2 reads src/tokns.css: matches nothing
|
|
165
|
+
fix fix the path
|
|
166
|
+
|
|
167
|
+
✗ 2 dead globs · checked in 241 ms · --all for every file
|
|
164
168
|
```
|
|
165
169
|
|
|
166
170
|
A config value with captures (`$1`) is dead only when it matches nothing
|
|
@@ -190,3 +194,5 @@ deadGlobs: [
|
|
|
190
194
|
- [Config](config.md): every key named here
|
|
191
195
|
- [CLI](cli.md): `check`, `why` and `graph`
|
|
192
196
|
- [Recipes](recipes.md): settings for common runners
|
|
197
|
+
- [Not supported](how-it-works.md#not-supported): what bivium leaves to
|
|
198
|
+
other tools
|
package/errors.js
ADDED
package/index.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export interface Config<Suite extends string = string> {
|
|
|
27
27
|
narrowers?: readonly Narrower<NoInfer<Suite>>[];
|
|
28
28
|
/**
|
|
29
29
|
* Paths (directories or files, not globs) the graph reads. A changed file
|
|
30
|
-
* outside them that isn't ignored runs everything. Default: the
|
|
31
|
-
* repository.
|
|
30
|
+
* outside them that isn't ignored runs everything. Default: the
|
|
31
|
+
* whole repository.
|
|
32
32
|
*/
|
|
33
33
|
roots?: string | readonly string[];
|
|
34
34
|
/**
|
|
@@ -81,8 +81,8 @@ export interface Config<Suite extends string = string> {
|
|
|
81
81
|
barrels?: Globs;
|
|
82
82
|
/**
|
|
83
83
|
* Packages to treat as external though no `package.json` declares them:
|
|
84
|
-
* ones a dependency installs. Any other undeclared bare specifier
|
|
85
|
-
* unknown.
|
|
84
|
+
* ones a dependency installs. Any other undeclared bare specifier
|
|
85
|
+
* is unknown.
|
|
86
86
|
*/
|
|
87
87
|
external?: readonly string[];
|
|
88
88
|
/**
|
|
@@ -141,13 +141,19 @@ export interface Config<Suite extends string = string> {
|
|
|
141
141
|
}
|
|
142
142
|
/** A test suite: its files, how to run them, and how they're wired. */
|
|
143
143
|
export interface SuiteConfig {
|
|
144
|
-
/** The suite's test files. */
|
|
145
144
|
tests: Globs;
|
|
146
145
|
/**
|
|
147
146
|
* The command `bivium run` runs. `{files}` is replaced by the selected
|
|
148
|
-
* files
|
|
147
|
+
* files; without it, they're appended. When every test is selected,
|
|
148
|
+
* `{files}` is the suite's `root`, or nothing without one.
|
|
149
149
|
*/
|
|
150
150
|
run?: string;
|
|
151
|
+
/**
|
|
152
|
+
* The command for a full run of the suite, when every test is selected
|
|
153
|
+
* and `run` with the suite's root wouldn't run exactly this suite.
|
|
154
|
+
* Default: `run`, with the root for `{files}`.
|
|
155
|
+
*/
|
|
156
|
+
runAll?: string;
|
|
151
157
|
/**
|
|
152
158
|
* Where the orphan rule applies: a changed file under one of these paths
|
|
153
159
|
* that no test of the suite reaches is wired some other way (a setup
|
|
@@ -168,8 +174,8 @@ export interface SuiteConfig {
|
|
|
168
174
|
*/
|
|
169
175
|
pages?: Globs;
|
|
170
176
|
/**
|
|
171
|
-
* Files whose change runs the whole suite: a second harness, a
|
|
172
|
-
* config.
|
|
177
|
+
* Files whose change runs the whole suite: a second harness, a
|
|
178
|
+
* runner config.
|
|
173
179
|
*/
|
|
174
180
|
wiring?: Globs;
|
|
175
181
|
/**
|
|
@@ -194,12 +200,11 @@ export interface SuiteConfig {
|
|
|
194
200
|
*/
|
|
195
201
|
types?: boolean;
|
|
196
202
|
/**
|
|
197
|
-
* The step output `bivium plan --github` writes the selection
|
|
198
|
-
* `<name>-tests`.
|
|
203
|
+
* The step output `bivium plan --github` writes the selection
|
|
204
|
+
* to. Default: `<name>-tests`.
|
|
199
205
|
*/
|
|
200
206
|
output?: string;
|
|
201
207
|
}
|
|
202
|
-
/** One glob, or several. */
|
|
203
208
|
export type Globs = string | readonly string[];
|
|
204
209
|
/**
|
|
205
210
|
* Replaces the coarse seeds of some changed files with finer ones from a
|
|
@@ -256,7 +261,6 @@ export interface GraphView<Suite extends string = string> {
|
|
|
256
261
|
* them, not counting files whose dependencies are unknown.
|
|
257
262
|
*/
|
|
258
263
|
dependents(nodes: Iterable<string>): ReadonlySet<string>;
|
|
259
|
-
/** A suite's test files. */
|
|
260
264
|
tests(suite: Suite): readonly string[];
|
|
261
265
|
}
|
|
262
266
|
/**
|
|
@@ -285,11 +289,10 @@ export interface PlanResult<Suite extends string = string> {
|
|
|
285
289
|
* 5.2.0`.
|
|
286
290
|
*/
|
|
287
291
|
packages: string[];
|
|
288
|
-
/** The base ref. */
|
|
289
292
|
base: string;
|
|
290
293
|
/**
|
|
291
|
-
* The merge base of `base` and `HEAD`, which the working tree is
|
|
292
|
-
* with.
|
|
294
|
+
* The merge base of `base` and `HEAD`, which the working tree is
|
|
295
|
+
* compared with.
|
|
293
296
|
*/
|
|
294
297
|
mergeBase: string;
|
|
295
298
|
/** The files changed since the merge base, untracked ones included. */
|
|
@@ -334,8 +337,8 @@ export interface FullRunCause<Suite extends string = string> {
|
|
|
334
337
|
/** Types a config. Returns it unchanged. */
|
|
335
338
|
export declare function defineConfig<Suite extends string>(config: Config<Suite>): Config<Suite>;
|
|
336
339
|
/**
|
|
337
|
-
* An error bivium names: its `code` says which failure, its `kind` what
|
|
338
|
-
* do.
|
|
340
|
+
* An error bivium names: its `code` says which failure, its `kind` what
|
|
341
|
+
* to do.
|
|
339
342
|
*/
|
|
340
343
|
export declare class BiviumError extends Error {
|
|
341
344
|
readonly code: BiviumErrorCode;
|
|
@@ -348,17 +351,9 @@ export declare class BiviumError extends Error {
|
|
|
348
351
|
*/
|
|
349
352
|
export type BiviumErrorCode =
|
|
350
353
|
/** No command, or `why` without a test. */
|
|
351
|
-
"BV_MISSING_ARGUMENT"
|
|
352
|
-
/** A command bivium doesn't have. */
|
|
353
|
-
| "BV_UNKNOWN_COMMAND"
|
|
354
|
-
/** An option the command doesn't take. */
|
|
355
|
-
| "BV_UNKNOWN_OPTION"
|
|
354
|
+
"BV_MISSING_ARGUMENT" | "BV_UNKNOWN_COMMAND" | "BV_UNKNOWN_OPTION"
|
|
356
355
|
/** An option's value is missing or of the wrong form. */
|
|
357
|
-
| "BV_BAD_OPTION_VALUE"
|
|
358
|
-
/** More arguments than the command takes. */
|
|
359
|
-
| "BV_UNEXPECTED_ARGUMENT"
|
|
360
|
-
/** A suite the config doesn't define. */
|
|
361
|
-
| "BV_UNKNOWN_SUITE"
|
|
356
|
+
| "BV_BAD_OPTION_VALUE" | "BV_UNEXPECTED_ARGUMENT" | "BV_UNKNOWN_SUITE"
|
|
362
357
|
/** A path that is no suite's test. */
|
|
363
358
|
| "BV_UNKNOWN_TEST"
|
|
364
359
|
/** A path that names no file of the graph. */
|
package/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { plan } from "./compute.js";
|
|
3
|
+
import { defineConfig } from "./config.js";
|
|
1
4
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
plan2
|
|
5
|
-
} from "./shared.js";
|
|
5
|
+
BiviumError
|
|
6
|
+
} from "./errors.js";
|
|
6
7
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
BiviumError,
|
|
9
|
+
defineConfig,
|
|
10
|
+
plan
|
|
10
11
|
};
|