@dads-framework/testing 0.0.0-stage → 0.2.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/LICENSE.md +21 -0
- package/README.md +276 -2
- package/bin/dad-test.js +3 -0
- package/dist/cli-arguments.d.ts +26 -0
- package/dist/cli-arguments.d.ts.map +1 -0
- package/dist/cli-arguments.js +90 -0
- package/dist/cli-arguments.js.map +1 -0
- package/dist/cli-output.d.ts +8 -0
- package/dist/cli-output.d.ts.map +1 -0
- package/dist/cli-output.js +11 -0
- package/dist/cli-output.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/explain.d.ts +8 -0
- package/dist/commands/explain.d.ts.map +1 -0
- package/dist/commands/explain.js +39 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +57 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/plan-run.d.ts +8 -0
- package/dist/commands/plan-run.d.ts.map +1 -0
- package/dist/commands/plan-run.js +93 -0
- package/dist/commands/plan-run.js.map +1 -0
- package/dist/dad-test-cli.d.ts +33 -0
- package/dist/dad-test-cli.d.ts.map +1 -0
- package/dist/dad-test-cli.js +52 -0
- package/dist/dad-test-cli.js.map +1 -0
- package/dist/explain-plan.d.ts +86 -0
- package/dist/explain-plan.d.ts.map +1 -0
- package/dist/explain-plan.js +302 -0
- package/dist/explain-plan.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/init/check-testing-manifest.d.ts +11 -0
- package/dist/init/check-testing-manifest.d.ts.map +1 -0
- package/dist/init/check-testing-manifest.js +166 -0
- package/dist/init/check-testing-manifest.js.map +1 -0
- package/dist/init/describe-error.d.ts +11 -0
- package/dist/init/describe-error.d.ts.map +1 -0
- package/dist/init/describe-error.js +13 -0
- package/dist/init/describe-error.js.map +1 -0
- package/dist/init/detect-workspace.d.ts +21 -0
- package/dist/init/detect-workspace.d.ts.map +1 -0
- package/dist/init/detect-workspace.js +133 -0
- package/dist/init/detect-workspace.js.map +1 -0
- package/dist/init/infer-one-package.d.ts +43 -0
- package/dist/init/infer-one-package.d.ts.map +1 -0
- package/dist/init/infer-one-package.js +173 -0
- package/dist/init/infer-one-package.js.map +1 -0
- package/dist/init/infer-testing-manifest.d.ts +60 -0
- package/dist/init/infer-testing-manifest.d.ts.map +1 -0
- package/dist/init/infer-testing-manifest.js +90 -0
- package/dist/init/infer-testing-manifest.js.map +1 -0
- package/dist/init/init-testing-manifest.d.ts +30 -0
- package/dist/init/init-testing-manifest.d.ts.map +1 -0
- package/dist/init/init-testing-manifest.js +205 -0
- package/dist/init/init-testing-manifest.js.map +1 -0
- package/dist/init/package-inventory.d.ts +21 -0
- package/dist/init/package-inventory.d.ts.map +1 -0
- package/dist/init/package-inventory.js +215 -0
- package/dist/init/package-inventory.js.map +1 -0
- package/dist/init/pnpm-workspace-yaml.d.ts +15 -0
- package/dist/init/pnpm-workspace-yaml.d.ts.map +1 -0
- package/dist/init/pnpm-workspace-yaml.js +158 -0
- package/dist/init/pnpm-workspace-yaml.js.map +1 -0
- package/dist/init/project-ids.d.ts +18 -0
- package/dist/init/project-ids.d.ts.map +1 -0
- package/dist/init/project-ids.js +54 -0
- package/dist/init/project-ids.js.map +1 -0
- package/dist/init/strip-json-comments.d.ts +9 -0
- package/dist/init/strip-json-comments.d.ts.map +1 -0
- package/dist/init/strip-json-comments.js +119 -0
- package/dist/init/strip-json-comments.js.map +1 -0
- package/dist/init/workspace-glob.d.ts +22 -0
- package/dist/init/workspace-glob.d.ts.map +1 -0
- package/dist/init/workspace-glob.js +154 -0
- package/dist/init/workspace-glob.js.map +1 -0
- package/dist/init/workspace-relative-path.d.ts +11 -0
- package/dist/init/workspace-relative-path.d.ts.map +1 -0
- package/dist/init/workspace-relative-path.js +17 -0
- package/dist/init/workspace-relative-path.js.map +1 -0
- package/dist/native-platform.d.ts +19 -0
- package/dist/native-platform.d.ts.map +1 -0
- package/dist/native-platform.js +115 -0
- package/dist/native-platform.js.map +1 -0
- package/dist/parse-guards.d.ts +13 -0
- package/dist/parse-guards.d.ts.map +1 -0
- package/dist/parse-guards.js +17 -0
- package/dist/parse-guards.js.map +1 -0
- package/dist/path-ownership.d.ts +17 -0
- package/dist/path-ownership.d.ts.map +1 -0
- package/dist/path-ownership.js +37 -0
- package/dist/path-ownership.js.map +1 -0
- package/dist/plan-issues.d.ts +17 -0
- package/dist/plan-issues.d.ts.map +1 -0
- package/dist/plan-issues.js +39 -0
- package/dist/plan-issues.js.map +1 -0
- package/dist/plan-reasons.d.ts +3 -0
- package/dist/plan-reasons.d.ts.map +1 -0
- package/dist/plan-reasons.js +14 -0
- package/dist/plan-reasons.js.map +1 -0
- package/dist/testing-api.d.ts +115 -0
- package/dist/testing-api.d.ts.map +1 -0
- package/dist/testing-api.js +96 -0
- package/dist/testing-api.js.map +1 -0
- package/dist/testing-manifest.d.ts +59 -0
- package/dist/testing-manifest.d.ts.map +1 -0
- package/dist/testing-manifest.js +196 -0
- package/dist/testing-manifest.js.map +1 -0
- package/dist/testing-report.d.ts +77 -0
- package/dist/testing-report.d.ts.map +1 -0
- package/dist/testing-report.js +184 -0
- package/dist/testing-report.js.map +1 -0
- package/dist/testing.tsbuildinfo +1 -0
- package/dist/write-files-atomically.d.ts +11 -0
- package/dist/write-files-atomically.d.ts.map +1 -0
- package/dist/write-files-atomically.js +30 -0
- package/dist/write-files-atomically.js.map +1 -0
- package/package.json +43 -4
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bryton Cooper
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,277 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Dads Testing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@dads-framework/testing` decides which of your declared verification tasks a
|
|
4
|
+
change actually requires, and runs them.
|
|
5
|
+
|
|
6
|
+
## What Dad does for you
|
|
7
|
+
|
|
8
|
+
Dad will not rerun the whole workspace because one file moved, and he will not
|
|
9
|
+
skip your test to save four seconds. Every skip he takes, he can prove; when
|
|
10
|
+
the proof runs out he widens out loud, with a reason and a line number.
|
|
11
|
+
|
|
12
|
+
## Try it
|
|
13
|
+
|
|
14
|
+
Use Node.js 22 or newer and Git. The npm install below is for the public
|
|
15
|
+
release and includes the [matching native runtime](#native-packages). For a
|
|
16
|
+
source checkout, first run the following from its root, then skip the
|
|
17
|
+
`npm install` line in the example.
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm ci
|
|
21
|
+
npm run build
|
|
22
|
+
cargo build -p dad-test
|
|
23
|
+
export DADS_TEST_NATIVE_BINARY="$PWD/target/debug/dad-test"
|
|
24
|
+
export PATH="$PWD/node_modules/.bin:$PATH"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Run the example in an empty directory.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm init -y
|
|
31
|
+
npm install --save-dev @dads-framework/testing
|
|
32
|
+
git init -q
|
|
33
|
+
printf 'node_modules/\n' > .gitignore
|
|
34
|
+
mkdir -p api web
|
|
35
|
+
|
|
36
|
+
cat > dads.testing.json <<'JSON'
|
|
37
|
+
{
|
|
38
|
+
"schemaVersion": 1,
|
|
39
|
+
"workspace": { "root": ".", "fullFallback": { "taskIds": ["api:test", "web:test"] } },
|
|
40
|
+
"projects": [
|
|
41
|
+
{ "id": "api", "root": "api", "fallbackDependencies": [] },
|
|
42
|
+
{ "id": "web", "root": "web", "fallbackDependencies": [] }
|
|
43
|
+
],
|
|
44
|
+
"tasks": [
|
|
45
|
+
{
|
|
46
|
+
"id": "api:test",
|
|
47
|
+
"project": "api",
|
|
48
|
+
"kind": "test",
|
|
49
|
+
"execution": { "executable": "node", "args": ["--version"], "cwd": "api" },
|
|
50
|
+
"dependsOn": [],
|
|
51
|
+
"impact": { "mode": "project" }
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "web:test",
|
|
55
|
+
"project": "web",
|
|
56
|
+
"kind": "test",
|
|
57
|
+
"execution": { "executable": "node", "args": ["--version"], "cwd": "web" },
|
|
58
|
+
"dependsOn": [],
|
|
59
|
+
"impact": { "mode": "project" }
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
JSON
|
|
64
|
+
|
|
65
|
+
printf 'export const port = 3000;\n' > api/config.js
|
|
66
|
+
printf 'export const title = "Home";\n' > web/config.js
|
|
67
|
+
git add .
|
|
68
|
+
git -c user.name="Dads Example" -c user.email="example@example.invalid" commit -qm baseline
|
|
69
|
+
|
|
70
|
+
printf 'export const port = 3001;\n' > api/config.js
|
|
71
|
+
PATH="$PWD/node_modules/.bin:$PATH"
|
|
72
|
+
dad-test explain
|
|
73
|
+
result=$(dad-test run --json)
|
|
74
|
+
printf '%s\n' "$result" | node -p 'JSON.parse(require("node:fs").readFileSync(0, "utf8")).result.run.exitCode'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The explanation reports `RUN api:test` and `SKIP web:test`. The run executes
|
|
78
|
+
the API task's sample command and prints a run exit code of `0`. To generate
|
|
79
|
+
a starting manifest from an existing npm, pnpm, or Yarn workspace, start with
|
|
80
|
+
`dad-test init` and review `dads.testing.init-report.json`.
|
|
81
|
+
|
|
82
|
+
In a checked-in workspace, keep `dads.testing.json` at the workspace root.
|
|
83
|
+
The repository's [testing manifest fixture](../../../fixtures/testing/dads.testing.json)
|
|
84
|
+
does this in `fixtures/testing/` and makes its test task depend on typecheck.
|
|
85
|
+
|
|
86
|
+
## Commands
|
|
87
|
+
|
|
88
|
+
`plan`, `run`, and `explain` share the same selection flags: `--manifest`
|
|
89
|
+
(path to `dads.testing.json`), `--base` and `--head` (Git refs), `--all`,
|
|
90
|
+
and `--task` (repeatable, one task id each). `plan` and `run` additionally
|
|
91
|
+
take `--jobs` and `--report` (with an optional path). `--json` works on every
|
|
92
|
+
command and is the contract; the human line format is not.
|
|
93
|
+
|
|
94
|
+
`dad-test plan` selects tasks and reports one decision per task without
|
|
95
|
+
executing anything. With `--report [path]` it also writes the analysis report
|
|
96
|
+
described under [Contract](#contract).
|
|
97
|
+
|
|
98
|
+
`dad-test run` selects the same way and then executes the selected tasks as a
|
|
99
|
+
dependency-aware DAG, four workers at a time by default; `--jobs` sets a
|
|
100
|
+
different positive limit. Independent tasks keep going after another task
|
|
101
|
+
fails; dependents of a failed or blocked prerequisite are blocked.
|
|
102
|
+
|
|
103
|
+
`dad-test explain` prints the same selection in readable lines, taking
|
|
104
|
+
`--manifest`, `--base`, `--head`, `--all`, `--task`, and `--json`:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
explain: N of M tasks selected, K skipped, W widened detail=engine|derived
|
|
108
|
+
scope: <scope facts>
|
|
109
|
+
full-fallback: yes|no
|
|
110
|
+
forced-by <issue>
|
|
111
|
+
RUN|SKIP <id> project=<p> reason=<code> confidence=<c> widened=yes|no
|
|
112
|
+
because <plain words>
|
|
113
|
+
changed <path>
|
|
114
|
+
export <symbol> <path>
|
|
115
|
+
import <path>:line:col from <path> [symbols]
|
|
116
|
+
prerequisite-of <id>
|
|
117
|
+
direct-task-input <id>
|
|
118
|
+
issue <code> <path:line:col> <message>
|
|
119
|
+
fallback-dependency <project>
|
|
120
|
+
info <code> <message>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`forced-by` lines appear only when the fallback is full. `detail=engine` means
|
|
124
|
+
every cause came from the plan the native engine returned; `detail=derived`
|
|
125
|
+
means that engine predates structured causes, so `explain` reconstructs what
|
|
126
|
+
each reason code implies from the plan and the manifest instead.
|
|
127
|
+
|
|
128
|
+
`dad-test init` refuses Nx workspaces and writes an unsuccessful coverage report
|
|
129
|
+
instead of treating a few root scripts as the repository's entire task inventory.
|
|
130
|
+
Use the optional `@dads-framework/testing-import-nx` live adapter (`dad-test-nx
|
|
131
|
+
plan`) for those repositories.
|
|
132
|
+
|
|
133
|
+
`dad-test init` writes `dads.testing.json` at the workspace root, taking
|
|
134
|
+
`--manifest`, `--force`, and `--json`. It detects the package manager — npm,
|
|
135
|
+
yarn, or pnpm — from the lockfile. Workspace patterns come from
|
|
136
|
+
`pnpm-workspace.yaml`'s `packages` list of strings; other top-level keys in
|
|
137
|
+
that file are ignored and reported, and anything else refuses with a
|
|
138
|
+
`file:line` pointing at the problem. Absent that file, patterns come from
|
|
139
|
+
`package.json`'s `workspaces` field; absent that, the workspace is one
|
|
140
|
+
package. Recognized `test` scripts become `reachability` tasks; `typecheck`,
|
|
141
|
+
`lint`, and `build` scripts become `project` tasks; `test` depends on
|
|
142
|
+
`typecheck`; and `fallbackDependencies` come from workspace dependencies and
|
|
143
|
+
`tsconfig` references. `init` refuses to overwrite an existing manifest
|
|
144
|
+
without `--force`, and a workspace with zero recognized scripts still gets a
|
|
145
|
+
report before `init` refuses.
|
|
146
|
+
|
|
147
|
+
Toolbox's `dad test plan|run|explain|init` is a passthrough to the commands
|
|
148
|
+
above. Toolbox's own `dad init` (scaffolds an application) and `dad explain
|
|
149
|
+
<path>` (names which package owns a path) are unrelated commands.
|
|
150
|
+
|
|
151
|
+
## The manifest
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"schemaVersion": 1,
|
|
156
|
+
"workspace": { "root": ".", "fullFallback": { "taskIds": ["api:test"] } },
|
|
157
|
+
"projects": [{ "id": "api", "root": "apps/api", "fallbackDependencies": [] }],
|
|
158
|
+
"tasks": [
|
|
159
|
+
{
|
|
160
|
+
"id": "api:test",
|
|
161
|
+
"project": "api",
|
|
162
|
+
"kind": "test",
|
|
163
|
+
"execution": { "executable": "npm", "args": ["test"], "cwd": "apps/api" },
|
|
164
|
+
"dependsOn": [],
|
|
165
|
+
"impact": { "mode": "reachability" }
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
All fields are strict. Paths must stay within the workspace. Project and task
|
|
172
|
+
ids are unique, all references must resolve, task cycles are rejected, and
|
|
173
|
+
`workspace.fullFallback.taskIds` must list every task exactly once. Ordinary
|
|
174
|
+
tasks are an executable plus arguments; an explicit `shell: true` runs
|
|
175
|
+
`executable` and `args` through the platform shell for shell recipes.
|
|
176
|
+
|
|
177
|
+
## How selection works
|
|
178
|
+
|
|
179
|
+
- Without refs, scope is `HEAD` plus staged, unstaged, deleted, renamed, and
|
|
180
|
+
untracked working-tree paths.
|
|
181
|
+
- `--base` compares that base with the working tree; `--base --head` compares
|
|
182
|
+
two commits; `--all` selects the complete fallback with no Git comparison.
|
|
183
|
+
- An unknown changed path selects the complete fallback.
|
|
184
|
+
- A direct task input selects that task's prerequisite closure.
|
|
185
|
+
- A task with `impact.mode` `always` runs in every plan.
|
|
186
|
+
- Otherwise selection is reachability from persisted graph-analysis state
|
|
187
|
+
built from the Oxc symbol graph. Oxc sits behind a language-neutral frontend
|
|
188
|
+
boundary, so other language frontends can contribute the same facts without
|
|
189
|
+
changing the planner. This state is analysis state, never a result cache.
|
|
190
|
+
- That state is keyed to the current head and the resolved comparison base,
|
|
191
|
+
because it carries the changed-export evidence that base implies; alternating
|
|
192
|
+
between two bases re-analyzes rather than reusing.
|
|
193
|
+
- That graph is analyzed only when the manifest declares at least one
|
|
194
|
+
`reachability` task; a manifest whose tasks are all `always`, `changed-files`,
|
|
195
|
+
or `project` reaches the same plan without it, so the workspace is not parsed,
|
|
196
|
+
the persisted state is not read or rewritten, and the plan says so with a
|
|
197
|
+
`graph-analysis-unneeded` issue.
|
|
198
|
+
- If a graph fact is unavailable or untrusted for an owned path, Dads widens
|
|
199
|
+
from that project through its declared `fallbackDependencies`. Unowned paths
|
|
200
|
+
and unowned graph uncertainty select the complete workspace fallback.
|
|
201
|
+
- The only skip decision is `skip-proven-unaffected`.
|
|
202
|
+
- A project rooted at `.` owns every path in the workspace.
|
|
203
|
+
|
|
204
|
+
## What it refuses to do
|
|
205
|
+
|
|
206
|
+
- No Nx runtime.
|
|
207
|
+
- No test-result cache and no result reuse: every `run` executes its selected
|
|
208
|
+
tasks again.
|
|
209
|
+
- No daemon, no network service, no telemetry.
|
|
210
|
+
- No skip it cannot prove.
|
|
211
|
+
- `DADS_TEST_NATIVE_BINARY` is for local development only. When it is set it
|
|
212
|
+
replaces the platform package: it is read before any package lookup, it must
|
|
213
|
+
point at an existing executable, and the resolution records
|
|
214
|
+
`DADS_TEST_NATIVE_BINARY` as the source of that path. An explicit
|
|
215
|
+
`nativeBinary` option is read before the variable.
|
|
216
|
+
|
|
217
|
+
## Contract
|
|
218
|
+
|
|
219
|
+
The plan JSON carries `scope`, `tasks`, and `issues`. A task has `id`,
|
|
220
|
+
`decision`, `reason`, `confidence`, and `widened`, plus an optional `project`
|
|
221
|
+
that owns it and an optional `causes` list naming every reason it was
|
|
222
|
+
selected: a direct task input, a prerequisite of another selected task, a
|
|
223
|
+
changed path, a changed export, a reached import (with its location, the
|
|
224
|
+
module it was imported from, and the symbols), a plan issue, or a fallback
|
|
225
|
+
dependency. An issue has `code` and `message`, and may carry `severity`,
|
|
226
|
+
`scope`, `path`, `line`, `column`, and `project`. A cause of kind `issue`
|
|
227
|
+
holds an `index` into `issues` as emitted, so a reader that reorders or
|
|
228
|
+
filters issues must resolve that reference against the original order. Every
|
|
229
|
+
one of these fields is optional for one reason: a missing field means the
|
|
230
|
+
engine that produced the plan is older than this facade, not that the fact
|
|
231
|
+
does not hold.
|
|
232
|
+
|
|
233
|
+
A run reports each selected task as `executed`, `failed`, `blocked`, or
|
|
234
|
+
`not-applicable`. Executed tasks may include `durationMs`, captured `stdout`
|
|
235
|
+
and `stderr` (each with `text` and `truncated`), and an `error` explanation.
|
|
236
|
+
|
|
237
|
+
`--report [path]` writes the report; `--json` embeds the same object under
|
|
238
|
+
`result.report`. It carries totals by reason and confidence; the fallback's
|
|
239
|
+
full/`forced-by` state, issue counts by code and severity, and the widening
|
|
240
|
+
issues with their locations; a `projectClosure` comparing the manifest's
|
|
241
|
+
transitive `fallbackDependencies` closure of changed projects against what was
|
|
242
|
+
actually selected, including a `reductionRatio` expressing the Dads selection
|
|
243
|
+
as a fraction of what an Nx-style project closure would have run; the
|
|
244
|
+
`execution` results; and `receipts`. These numbers are descriptive: they say
|
|
245
|
+
how much narrower the selection was and why it widened, not whether it was
|
|
246
|
+
correct. Judging correctness needs an oracle — a known-required task set —
|
|
247
|
+
and that comparison is out of scope for the report.
|
|
248
|
+
|
|
249
|
+
`init` writes `dads.testing.init-report.json` beside the manifest, recording
|
|
250
|
+
workspace facts, each package's tasks and skips, inferences, unsupported
|
|
251
|
+
constructs, the manifest's checksum, and the validation method: `native` when
|
|
252
|
+
a binary was available, otherwise `structural`, or `none`.
|
|
253
|
+
|
|
254
|
+
The package also exposes `planTesting(request)` and `runTesting(request)`.
|
|
255
|
+
Each operation makes one JSON request to the native `dad-test` process.
|
|
256
|
+
|
|
257
|
+
## Native packages
|
|
258
|
+
|
|
259
|
+
The public npm release will ship platform executables as separate optional
|
|
260
|
+
packages for macOS arm64/x64, Linux glibc arm64/x64, and Windows x64. npm selects
|
|
261
|
+
the dependency matching the host platform and architecture, and the facade
|
|
262
|
+
uses its executable.
|
|
263
|
+
|
|
264
|
+
Inside this repository those packages are deliberately not npm workspaces:
|
|
265
|
+
each declares `os` and `cpu`, and npm refuses to install a workspace whose
|
|
266
|
+
platform does not match the host. As plain optional dependencies, `npm ci`
|
|
267
|
+
links the package for the current platform and skips the rest. For local
|
|
268
|
+
development, build the native CLI with `cargo build -p dad-test` from
|
|
269
|
+
the repository root and set `DADS_TEST_NATIVE_BINARY` to the resulting
|
|
270
|
+
`target/debug/dad-test` executable (`dad-test.exe` on Windows).
|
|
271
|
+
|
|
272
|
+
## Daddy issues this prevents
|
|
273
|
+
|
|
274
|
+
Two failures wear the same face: the suite that reruns everything because
|
|
275
|
+
nobody could say what changed, and the suite that skips your test because
|
|
276
|
+
somebody once said "that's unrelated" and never wrote down why. Here
|
|
277
|
+
uncertainty always widens, and it always leaves a note.
|
package/bin/dad-test.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One option parser for every `dad-test` command. Each command declares the
|
|
3
|
+
* options it accepts; anything else is a command-line error rather than a
|
|
4
|
+
* silently ignored argument. `--json` is accepted by every command because it
|
|
5
|
+
* selects the output envelope rather than command behaviour.
|
|
6
|
+
*/
|
|
7
|
+
export type OptionKind = "flag" | "value" | "repeatable" | "optional-value";
|
|
8
|
+
export type OptionSpecification = {
|
|
9
|
+
readonly name: `--${string}`;
|
|
10
|
+
readonly kind: OptionKind;
|
|
11
|
+
};
|
|
12
|
+
export type ParsedArguments = {
|
|
13
|
+
/** Options declared as `flag` that appeared at least once. */
|
|
14
|
+
readonly flags: ReadonlySet<string>;
|
|
15
|
+
/** Values of `value` options, and of `optional-value` options given a value. */
|
|
16
|
+
readonly values: ReadonlyMap<string, string>;
|
|
17
|
+
/** Every value of each `repeatable` option, in command-line order. */
|
|
18
|
+
readonly repeated: ReadonlyMap<string, readonly string[]>;
|
|
19
|
+
/** Every option that appeared, whether or not it carried a value. */
|
|
20
|
+
readonly present: ReadonlySet<string>;
|
|
21
|
+
};
|
|
22
|
+
/** Parses the arguments that follow a command name. */
|
|
23
|
+
export declare function parseCommandOptions(argumentsAfterCommand: readonly string[], specification: readonly OptionSpecification[]): ParsedArguments;
|
|
24
|
+
/** Reads an option value that must be a positive integer. */
|
|
25
|
+
export declare function readPositiveInteger(value: string, option: string): number;
|
|
26
|
+
//# sourceMappingURL=cli-arguments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-arguments.d.ts","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAE5E,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC1D,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAYF,uDAAuD;AACvD,wBAAgB,mBAAmB,CACjC,qBAAqB,EAAE,SAAS,MAAM,EAAE,EACxC,aAAa,EAAE,SAAS,mBAAmB,EAAE,GAC5C,eAAe,CAqBjB;AAmFD,6DAA6D;AAC7D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMzE"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One option parser for every `dad-test` command. Each command declares the
|
|
3
|
+
* options it accepts; anything else is a command-line error rather than a
|
|
4
|
+
* silently ignored argument. `--json` is accepted by every command because it
|
|
5
|
+
* selects the output envelope rather than command behaviour.
|
|
6
|
+
*/
|
|
7
|
+
const jsonOption = { name: "--json", kind: "flag" };
|
|
8
|
+
/** Parses the arguments that follow a command name. */
|
|
9
|
+
export function parseCommandOptions(argumentsAfterCommand, specification) {
|
|
10
|
+
const kinds = declaredOptionKinds(specification);
|
|
11
|
+
const collected = {
|
|
12
|
+
flags: new Set(),
|
|
13
|
+
values: new Map(),
|
|
14
|
+
repeated: new Map(),
|
|
15
|
+
present: new Set(),
|
|
16
|
+
};
|
|
17
|
+
for (let index = 0; index < argumentsAfterCommand.length; index += 1) {
|
|
18
|
+
const argument = argumentsAfterCommand[index];
|
|
19
|
+
if (argument === undefined)
|
|
20
|
+
break;
|
|
21
|
+
index += collectOption(collected, requireDeclaredKind(argument, kinds), argument, argumentsAfterCommand[index + 1]);
|
|
22
|
+
}
|
|
23
|
+
return collected;
|
|
24
|
+
}
|
|
25
|
+
/** `--json` is accepted everywhere, so every command's kinds start with it. */
|
|
26
|
+
function declaredOptionKinds(specification) {
|
|
27
|
+
const kinds = new Map([
|
|
28
|
+
[jsonOption.name, jsonOption.kind],
|
|
29
|
+
]);
|
|
30
|
+
for (const option of specification)
|
|
31
|
+
kinds.set(option.name, option.kind);
|
|
32
|
+
return kinds;
|
|
33
|
+
}
|
|
34
|
+
/** Anything the command did not declare is a command-line error, not a positional. */
|
|
35
|
+
function requireDeclaredKind(argument, kinds) {
|
|
36
|
+
if (!argument.startsWith("--")) {
|
|
37
|
+
throw new Error(`Unexpected argument ${argument}.`);
|
|
38
|
+
}
|
|
39
|
+
const kind = kinds.get(argument);
|
|
40
|
+
if (kind === undefined)
|
|
41
|
+
throw new Error(`Unknown option ${argument}.`);
|
|
42
|
+
return kind;
|
|
43
|
+
}
|
|
44
|
+
/** Records one option and reports how many further arguments it consumed. */
|
|
45
|
+
function collectOption(collected, kind, argument, nextArgument) {
|
|
46
|
+
if (kind === "flag") {
|
|
47
|
+
collected.flags.add(argument);
|
|
48
|
+
collected.present.add(argument);
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
const value = valueOf(nextArgument);
|
|
52
|
+
requireUsableValue(collected.present, kind, argument, value);
|
|
53
|
+
if (value !== undefined)
|
|
54
|
+
recordValue(collected, kind, argument, value);
|
|
55
|
+
collected.present.add(argument);
|
|
56
|
+
return value === undefined ? 0 : 1;
|
|
57
|
+
}
|
|
58
|
+
/** The next argument is this option's value unless it is itself an option. */
|
|
59
|
+
function valueOf(nextArgument) {
|
|
60
|
+
if (nextArgument === undefined || nextArgument.startsWith("--")) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
return nextArgument;
|
|
64
|
+
}
|
|
65
|
+
function requireUsableValue(present, kind, argument, value) {
|
|
66
|
+
if (kind !== "repeatable" && present.has(argument)) {
|
|
67
|
+
throw new Error(`${argument} may only be provided once.`);
|
|
68
|
+
}
|
|
69
|
+
if (kind !== "optional-value" && value === undefined) {
|
|
70
|
+
throw new Error(`${argument} requires a value.`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function recordValue(collected, kind, argument, value) {
|
|
74
|
+
if (kind !== "repeatable") {
|
|
75
|
+
collected.values.set(argument, value);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const collectedValues = collected.repeated.get(argument) ?? [];
|
|
79
|
+
collectedValues.push(value);
|
|
80
|
+
collected.repeated.set(argument, collectedValues);
|
|
81
|
+
}
|
|
82
|
+
/** Reads an option value that must be a positive integer. */
|
|
83
|
+
export function readPositiveInteger(value, option) {
|
|
84
|
+
const parsed = Number.parseInt(value, 10);
|
|
85
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
86
|
+
throw new Error(`${option} must be a positive integer.`);
|
|
87
|
+
}
|
|
88
|
+
return parsed;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=cli-arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-arguments.js","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,MAAM,UAAU,GAAwB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAUzE,uDAAuD;AACvD,MAAM,UAAU,mBAAmB,CACjC,qBAAwC,EACxC,aAA6C;IAE7C,MAAM,KAAK,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACjD,MAAM,SAAS,GAAqB;QAClC,KAAK,EAAE,IAAI,GAAG,EAAU;QACxB,MAAM,EAAE,IAAI,GAAG,EAAkB;QACjC,QAAQ,EAAE,IAAI,GAAG,EAAoB;QACrC,OAAO,EAAE,IAAI,GAAG,EAAU;KAC3B,CAAC;IAEF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,qBAAqB,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,QAAQ,KAAK,SAAS;YAAE,MAAM;QAClC,KAAK,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C,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/D,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AACpD,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,MAAc;IAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,8BAA8B,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DadTestCliIo } from "./dad-test-cli.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every successful command writes the same two shapes: one versioned JSON
|
|
4
|
+
* envelope for machines, and a human line plus indented JSON for people. The
|
|
5
|
+
* envelope is the contract; the human form is explicitly not.
|
|
6
|
+
*/
|
|
7
|
+
export declare function writeCommandSuccess(io: DadTestCliIo, json: boolean, operation: string, result: unknown): void;
|
|
8
|
+
//# sourceMappingURL=cli-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-output.d.ts","sourceRoot":"","sources":["../src/cli-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,YAAY,EAChB,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,OAAO,GACd,IAAI,CAMN"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every successful command writes the same two shapes: one versioned JSON
|
|
3
|
+
* envelope for machines, and a human line plus indented JSON for people. The
|
|
4
|
+
* envelope is the contract; the human form is explicitly not.
|
|
5
|
+
*/
|
|
6
|
+
export function writeCommandSuccess(io, json, operation, result) {
|
|
7
|
+
io.stdout(json
|
|
8
|
+
? `${JSON.stringify({ schemaVersion: 1, ok: true, result })}\n`
|
|
9
|
+
: `${operation} completed. Use --json for the versioned machine-readable result.\n${JSON.stringify(result, null, 2)}\n`);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=cli-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-output.js","sourceRoot":"","sources":["../src/cli-output.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,EAAgB,EAChB,IAAa,EACb,SAAiB,EACjB,MAAe;IAEf,EAAE,CAAC,MAAM,CACP,IAAI;QACF,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,IAAI;QAC/D,CAAC,CAAC,GAAG,SAAS,sEAAsE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAC1H,CAAC;AACJ,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { runDadTestCli } from "./dad-test-cli.js";
|
|
4
|
+
process.exitCode = await runDadTestCli(process.argv.slice(2), {
|
|
5
|
+
cwd: process.cwd(),
|
|
6
|
+
env: process.env,
|
|
7
|
+
stdout: (text) => {
|
|
8
|
+
process.stdout.write(text);
|
|
9
|
+
},
|
|
10
|
+
stderr: (text) => {
|
|
11
|
+
process.stderr.write(text);
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,CAAC,QAAQ,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC5D,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DadTestCommand } from "../dad-test-cli.js";
|
|
2
|
+
/**
|
|
3
|
+
* `dad-test explain` reports the evidence behind a plan. The manifest is read
|
|
4
|
+
* here rather than inside the explanation so an unreadable manifest fails the
|
|
5
|
+
* command with its own message instead of quietly producing a thinner report.
|
|
6
|
+
*/
|
|
7
|
+
export declare const explainCommand: DadTestCommand;
|
|
8
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../src/commands/explain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAkBzD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,cAkB5B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { writeCommandSuccess } from "../cli-output.js";
|
|
2
|
+
import { explainPlan, renderPlanExplanation } from "../explain-plan.js";
|
|
3
|
+
import { planTesting } from "../testing-api.js";
|
|
4
|
+
import { readTestingManifest } from "../testing-manifest.js";
|
|
5
|
+
import { buildOperationRequest } from "./plan-run.js";
|
|
6
|
+
/**
|
|
7
|
+
* `explain` selects the same scope as `plan`, so it accepts the same options
|
|
8
|
+
* minus `--jobs`: explaining a plan runs nothing and has no worker limit.
|
|
9
|
+
*/
|
|
10
|
+
const explainOptions = [
|
|
11
|
+
{ name: "--manifest", kind: "value" },
|
|
12
|
+
{ name: "--base", kind: "value" },
|
|
13
|
+
{ name: "--head", kind: "value" },
|
|
14
|
+
{ name: "--all", kind: "flag" },
|
|
15
|
+
{ name: "--task", kind: "repeatable" },
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* `dad-test explain` reports the evidence behind a plan. The manifest is read
|
|
19
|
+
* here rather than inside the explanation so an unreadable manifest fails the
|
|
20
|
+
* command with its own message instead of quietly producing a thinner report.
|
|
21
|
+
*/
|
|
22
|
+
export const explainCommand = {
|
|
23
|
+
options: explainOptions,
|
|
24
|
+
execute: async (parsed, io, json) => {
|
|
25
|
+
const plan = await planTesting(buildOperationRequest(parsed, io));
|
|
26
|
+
const manifest = readTestingManifest(io.cwd, parsed.values.get("--manifest"));
|
|
27
|
+
const explanation = explainPlan(plan, manifest);
|
|
28
|
+
if (json) {
|
|
29
|
+
writeCommandSuccess(io, json, "explain", explanation);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// The rendered explanation is the whole human output: a "completed"
|
|
33
|
+
// preamble above a report the reader is meant to read is noise.
|
|
34
|
+
io.stdout(renderPlanExplanation(explanation));
|
|
35
|
+
}
|
|
36
|
+
return 0;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL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IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,oEAAoE;YACpE,gEAAgE;YAChE,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DadTestCommand } from "../dad-test-cli.js";
|
|
2
|
+
/**
|
|
3
|
+
* `dad-test init` generates a manifest for a workspace that has none. The human
|
|
4
|
+
* form leads with what was written and how it was checked, then names every
|
|
5
|
+
* package it skipped and everything it could not read — the two things that
|
|
6
|
+
* decide whether the generated manifest is worth keeping.
|
|
7
|
+
*/
|
|
8
|
+
export declare const initCommand: DadTestCommand;
|
|
9
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AASvE;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,cAoBzB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { writeCommandSuccess } from "../cli-output.js";
|
|
2
|
+
import { initTestingManifest } from "../init/init-testing-manifest.js";
|
|
3
|
+
const initOptions = [
|
|
4
|
+
{ name: "--manifest", kind: "value" },
|
|
5
|
+
{ name: "--force", kind: "flag" },
|
|
6
|
+
];
|
|
7
|
+
/**
|
|
8
|
+
* `dad-test init` generates a manifest for a workspace that has none. The human
|
|
9
|
+
* form leads with what was written and how it was checked, then names every
|
|
10
|
+
* package it skipped and everything it could not read — the two things that
|
|
11
|
+
* decide whether the generated manifest is worth keeping.
|
|
12
|
+
*/
|
|
13
|
+
export const initCommand = {
|
|
14
|
+
options: initOptions,
|
|
15
|
+
execute: async (parsed, io, json) => {
|
|
16
|
+
const manifestPath = parsed.values.get("--manifest");
|
|
17
|
+
const result = await initTestingManifest({
|
|
18
|
+
workspaceRoot: io.cwd,
|
|
19
|
+
...(manifestPath === undefined ? {} : { manifestPath }),
|
|
20
|
+
force: parsed.flags.has("--force"),
|
|
21
|
+
...(io.nativeBinary === undefined
|
|
22
|
+
? {}
|
|
23
|
+
: { nativeBinary: io.nativeBinary }),
|
|
24
|
+
environment: io.env,
|
|
25
|
+
});
|
|
26
|
+
if (json) {
|
|
27
|
+
writeCommandSuccess(io, true, "init", result);
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
writeHumanReport(io, result);
|
|
31
|
+
return 0;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
function writeHumanReport(io, result) {
|
|
35
|
+
const validation = result.report.validation;
|
|
36
|
+
const selected = validation.selectedTaskCount === undefined
|
|
37
|
+
? ""
|
|
38
|
+
: ` selected=${String(validation.selectedTaskCount)}`;
|
|
39
|
+
const counted = `${count(result.manifest.projects.length, "project")}, ${count(result.manifest.tasks.length, "task")}`;
|
|
40
|
+
const lines = [
|
|
41
|
+
`init: wrote ${result.manifestPath} (${counted}) validation=${validation.method}${selected}`,
|
|
42
|
+
`report: ${result.reportPath}`,
|
|
43
|
+
];
|
|
44
|
+
for (const entry of result.report.packages) {
|
|
45
|
+
if (entry.skipped === undefined)
|
|
46
|
+
continue;
|
|
47
|
+
lines.push(`skipped ${entry.directory}: ${entry.skipped}`);
|
|
48
|
+
}
|
|
49
|
+
for (const entry of result.report.unsupported) {
|
|
50
|
+
lines.push(`unsupported ${entry.subject}: ${entry.message}`);
|
|
51
|
+
}
|
|
52
|
+
io.stdout(`${lines.join("\n")}\n`);
|
|
53
|
+
}
|
|
54
|
+
function count(total, noun) {
|
|
55
|
+
return `${String(total)} ${noun}${total === 1 ? "" : "s"}`;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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I,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ParsedArguments } from "../cli-arguments.js";
|
|
2
|
+
import type { DadTestCliIo, DadTestCommand } from "../dad-test-cli.js";
|
|
3
|
+
import type { TestingOperationRequest } from "../testing-api.js";
|
|
4
|
+
export declare const planCommand: DadTestCommand;
|
|
5
|
+
export declare const runCommand: DadTestCommand;
|
|
6
|
+
/** Builds the one request the native engine receives for `plan` and `run`. */
|
|
7
|
+
export declare function buildOperationRequest(parsed: ParsedArguments, io: DadTestCliIo): TestingOperationRequest;
|
|
8
|
+
//# sourceMappingURL=plan-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-run.d.ts","sourceRoot":"","sources":["../../src/commands/plan-run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGhF,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,mBAAmB,CAAC;AAiB3B,eAAO,MAAM,WAAW,EAAE,cAczB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAgBxB,CAAC;AA6CF,8EAA8E;AAC9E,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,eAAe,EACvB,EAAE,EAAE,YAAY,GACf,uBAAuB,CAiBzB"}
|