as-test 0.5.1 → 0.5.3
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/CHANGELOG.md +101 -0
- package/README.md +268 -3
- package/as-test.config.schema.json +171 -2
- package/assembly/coverage.ts +20 -0
- package/assembly/index.ts +196 -12
- package/assembly/src/expectation.ts +15 -29
- package/assembly/src/log.ts +13 -1
- package/assembly/src/suite.ts +53 -9
- package/assembly/src/tests.ts +25 -5
- package/assembly/util/helpers.ts +0 -1
- package/assembly/util/json.ts +78 -0
- package/bin/build.js +118 -33
- package/bin/index.js +524 -35
- package/bin/init.js +35 -10
- package/bin/reporters/default.js +26 -9
- package/bin/reporters/tap.js +294 -0
- package/bin/run.js +368 -44
- package/bin/types.js +18 -0
- package/bin/util.js +229 -1
- package/package.json +40 -50
- package/transform/lib/coverage.js +135 -124
- package/transform/lib/index.js +57 -23
- package/transform/lib/log.js +2 -39
- package/transform/lib/mock.js +42 -22
- package/transform/lib/builder.js.map +0 -1
- package/transform/lib/coverage.js.map +0 -1
- package/transform/lib/index.js.map +0 -1
- package/transform/lib/linker.js.map +0 -1
- package/transform/lib/location.js.map +0 -1
- package/transform/lib/log.js.map +0 -1
- package/transform/lib/mock.js.map +0 -1
- package/transform/lib/range.js.map +0 -1
- package/transform/lib/types.js.map +0 -1
- package/transform/lib/util.js.map +0 -1
- package/transform/lib/visitor.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,106 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2026-02-25 - v0.5.3
|
|
4
|
+
|
|
5
|
+
### CLI, Modes & Matrix
|
|
6
|
+
|
|
7
|
+
- feat: support mode fan-out behavior consistently across `ast build`, `ast run`, and `ast test`.
|
|
8
|
+
- feat: when no `--mode` is provided and modes are configured, run using configured modes.
|
|
9
|
+
- feat: add matrix-style per-file output with mode-aware timing:
|
|
10
|
+
- non-verbose: average time
|
|
11
|
+
- verbose: per-mode times.
|
|
12
|
+
- feat: add real-time matrix line updates in the default reporter and normalize timing precision to one decimal.
|
|
13
|
+
- feat: support comma-separated bare selectors (for example `ast test box,custom,generics,string`) across build/run/test selectors.
|
|
14
|
+
|
|
15
|
+
### Config Merge & Env Behavior
|
|
16
|
+
|
|
17
|
+
- fix: apply mode config as field-level merge over base config instead of replacing entire sections.
|
|
18
|
+
- fix: merge `buildOptions.args` between base config and mode config.
|
|
19
|
+
- fix: pass config env variables to both build and run processes for mode execution.
|
|
20
|
+
|
|
21
|
+
### Build Pipeline & Feature Flags
|
|
22
|
+
|
|
23
|
+
- feat: include the exact build command in build failure output.
|
|
24
|
+
- feat: allow `buildOptions.cmd` to override default command generation while still appending user build args.
|
|
25
|
+
- feat: support CLI feature toggles:
|
|
26
|
+
- `--enable coverage` / `--disable coverage`
|
|
27
|
+
- `--enable try-as` / `--disable try-as`.
|
|
28
|
+
|
|
29
|
+
### Reporter & Summaries
|
|
30
|
+
|
|
31
|
+
- fix: move mode summary rendering into the default reporter (via run-complete event payload).
|
|
32
|
+
- feat: include `modeSummary` for single-mode runs.
|
|
33
|
+
- feat: include mode and snapshot totals in final summary output.
|
|
34
|
+
- fix: `--clean` output now behaves as non-TTY in default reporter:
|
|
35
|
+
- no in-place line editing,
|
|
36
|
+
- no suite expand/collapse logs,
|
|
37
|
+
- final per-file verdict lines only.
|
|
38
|
+
|
|
39
|
+
### Coverage & Transform
|
|
40
|
+
|
|
41
|
+
- fix: ignore AssemblyScript builtin/compiler helper calls during coverage instrumentation (including `isString`, `changetype<T>`, `idof<T>`, `sizeof<T>`).
|
|
42
|
+
- fix: mock transform now collects mocked import targets across sources so WASI mock imports are rewritten reliably (resolves import-shape runtime failures).
|
|
43
|
+
|
|
44
|
+
## 2026-02-24 - v0.5.2
|
|
45
|
+
|
|
46
|
+
### Runtime & Serialization
|
|
47
|
+
|
|
48
|
+
- refactor: remove `json-as` dependency by inlining portable serialization and deserialization helpers into the runtime.
|
|
49
|
+
|
|
50
|
+
### CLI
|
|
51
|
+
|
|
52
|
+
- fix: enforce deterministic alphanumeric test input ordering for `ast build`, `ast run`, and `ast test`.
|
|
53
|
+
|
|
54
|
+
### Dependencies
|
|
55
|
+
|
|
56
|
+
- chore: remove unused runtime dependencies `as-variant` and `gradient-string`.
|
|
57
|
+
|
|
58
|
+
## 2026-02-23
|
|
59
|
+
|
|
60
|
+
### Runtime Matrix & Mode Execution
|
|
61
|
+
|
|
62
|
+
- feat: add `--mode <name[,name...]>` support for `ast build`, `ast run`, and `ast test`, including multi-mode fan-out in one command.
|
|
63
|
+
- feat: add config `modes` map for per-mode overrides (`buildOptions`, `runOptions`, `env`, and optional output/log/coverage/snapshot directories).
|
|
64
|
+
- feat: when running with `--mode`, compile artifacts are emitted as `<name>.<mode>.<type>.wasm` (where `type` is `wasi` or `bindings`).
|
|
65
|
+
|
|
66
|
+
### Bindings Runner Naming
|
|
67
|
+
|
|
68
|
+
- feat: switch default bindings runner path to `./.as-test/runners/default.bindings.js`.
|
|
69
|
+
- fix: keep backward compatibility with deprecated `./.as-test/runners/default.run.js` and legacy `*.run.js` bindings helper files.
|
|
70
|
+
- feat: add runtime warnings for deprecated bindings runner path usage and automatic fallback to `default.bindings.js` when needed.
|
|
71
|
+
|
|
72
|
+
### Init, Examples & Docs
|
|
73
|
+
|
|
74
|
+
- feat: `init` now writes both `.as-test/runners/default.wasi.js` and `.as-test/runners/default.bindings.js`.
|
|
75
|
+
- docs: update README runtime examples and mode artifact naming guidance for `--mode`.
|
|
76
|
+
- docs: refresh `examples/` docs/configs for `default.bindings.js` and add a mode matrix example config.
|
|
77
|
+
|
|
78
|
+
## 2026-02-18
|
|
79
|
+
|
|
80
|
+
### Reporter & CLI
|
|
81
|
+
|
|
82
|
+
- feat: add built-in TAP v13 reporter (`tap`) for `ast run` and `ast test`.
|
|
83
|
+
- feat: add reporter selection flags `--tap` and `--reporter <name|path>`.
|
|
84
|
+
- feat: when TAP reporter is active, write a single TAP artifact by default to `./.as-test/reports/report.tap`.
|
|
85
|
+
- feat: allow reporter object config (`name`, `options`, `outDir`, `outFile`) for TAP output control, including `single-file` (default) and `per-file`.
|
|
86
|
+
- feat: emit GitHub Actions `::error` annotations for failed TAP assertions (with file/line/col when available).
|
|
87
|
+
- fix: keep TAP stdout clean by routing runtime passthrough output to stderr in TAP mode.
|
|
88
|
+
- fix: ensure reporter flag values are not treated as test selectors in `ast test`.
|
|
89
|
+
|
|
90
|
+
### Mocking API & Transform
|
|
91
|
+
|
|
92
|
+
- feat: add `unmockFn(oldFn)` and `unmockImport(path)` APIs to complement `mockFn` and `mockImport`.
|
|
93
|
+
- feat: add `snapshotImport(imp, version)` and `restoreImport(imp, version)` to snapshot and restore a single import mock by version.
|
|
94
|
+
- feat: support both import path strings and import functions for `imp`, and `string`/`i32` versions.
|
|
95
|
+
- feat: `snapshotImport` also supports callback form (`snapshotImport(imp, () => ...)`) that snapshots to default version `"default"`.
|
|
96
|
+
- feat: update transform/runtime handling so `unmockFn` stops later function-call rewrites and `unmockImport` clears the active import mock mapping.
|
|
97
|
+
|
|
98
|
+
### Config & Docs
|
|
99
|
+
|
|
100
|
+
- docs: document built-in TAP usage in README (`--tap`, `--reporter tap`, and config-based usage).
|
|
101
|
+
- docs: update config schema reporter description to include built-in `default` and `tap` values.
|
|
102
|
+
- docs: add README mocking section covering `mockFn`, `unmockFn`, `mockImport`, and `unmockImport`.
|
|
103
|
+
|
|
3
104
|
## 2026-02-16 - v0.5.1
|
|
4
105
|
|
|
5
106
|
### Miscellaneous
|
package/README.md
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
<details>
|
|
6
6
|
<summary>Table of Contents</summary>
|
|
7
7
|
|
|
8
|
+
- [Why as-test](#why-as-test)
|
|
8
9
|
- [Installation](#installation)
|
|
10
|
+
- [Examples](#examples)
|
|
9
11
|
- [Writing Tests](#writing-tests)
|
|
12
|
+
- [Mocking](#mocking)
|
|
10
13
|
- [Snapshots](#snapshots)
|
|
11
14
|
- [Coverage](#coverage)
|
|
12
15
|
- [Custom Reporters](#custom-reporters)
|
|
@@ -16,6 +19,20 @@
|
|
|
16
19
|
|
|
17
20
|
</details>
|
|
18
21
|
|
|
22
|
+
## Why as-test
|
|
23
|
+
|
|
24
|
+
Most AssemblyScript testing tools are tied to a single runtime, usually Node.js. This works for development, but it doesn’t reflect how your code runs in production.
|
|
25
|
+
If you deploy to WASI, Wazero, or a custom runtime, you often end up mocking everything and maintaining parallel logic just for tests.
|
|
26
|
+
as-test solves this by letting you run tests on your actual target runtime, while only mocking what’s necessary.
|
|
27
|
+
|
|
28
|
+
Key benefits
|
|
29
|
+
|
|
30
|
+
- Runtime-agnostic: test on WASI, bindings, or custom runners
|
|
31
|
+
- Minimal mocking: keep real imports when possible
|
|
32
|
+
- Production-like testing: catch runtime-specific issues early
|
|
33
|
+
- Inline mocking and snapshots
|
|
34
|
+
- Custom reporters and coverage
|
|
35
|
+
|
|
19
36
|
## Installation
|
|
20
37
|
|
|
21
38
|
The installation script will set everything up for you:
|
|
@@ -28,6 +45,17 @@ Alternatively, you can install it manually:
|
|
|
28
45
|
npm install as-test --save-dev
|
|
29
46
|
```
|
|
30
47
|
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
Full runnable examples live in `examples/`, including:
|
|
51
|
+
|
|
52
|
+
- complete spec files for core features
|
|
53
|
+
- import mocking and import snapshot patterns
|
|
54
|
+
- mode-based runtime matrix config in `examples/as-test.config.json`
|
|
55
|
+
- a dedicated config you can run directly
|
|
56
|
+
|
|
57
|
+
See `examples/README.md` for the walkthrough.
|
|
58
|
+
|
|
31
59
|
## Writing Tests
|
|
32
60
|
|
|
33
61
|
Create `assembly/__tests__/math.spec.ts`:
|
|
@@ -46,7 +74,7 @@ describe("math", () => {
|
|
|
46
74
|
});
|
|
47
75
|
```
|
|
48
76
|
|
|
49
|
-
###
|
|
77
|
+
### File selection (`ast run`, `ast build`, `ast test`)
|
|
50
78
|
|
|
51
79
|
No selectors:
|
|
52
80
|
|
|
@@ -77,6 +105,14 @@ Multiple selectors:
|
|
|
77
105
|
ast test sleep array ./assembly/__tests__/snapshot.spec.ts
|
|
78
106
|
```
|
|
79
107
|
|
|
108
|
+
Comma-separated bare suite names:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
ast test box,custom,generics,string
|
|
112
|
+
ast run box,custom,generics,string
|
|
113
|
+
ast build box,custom,generics,string
|
|
114
|
+
```
|
|
115
|
+
|
|
80
116
|
If nothing matches, `ast test` exits non-zero with:
|
|
81
117
|
|
|
82
118
|
```text
|
|
@@ -86,10 +122,76 @@ No test files matched: ...
|
|
|
86
122
|
### Useful flags
|
|
87
123
|
|
|
88
124
|
- `--config <path>`: use another config file
|
|
125
|
+
- `--mode <name[,name...]>`: run one or multiple named config modes (if omitted and `modes` is configured, as-test runs all configured modes)
|
|
89
126
|
- `--update-snapshots`: write snapshot updates
|
|
90
127
|
- `--no-snapshot`: disable snapshot assertions for the run
|
|
91
128
|
- `--show-coverage`: print uncovered coverage points
|
|
129
|
+
- `--enable <feature>`: enable as-test feature (`coverage`, `try-as`)
|
|
130
|
+
- `--disable <feature>`: disable as-test feature (`coverage`, `try-as`)
|
|
92
131
|
- `--verbose`: keep expanded suite/test lines and update running `....` statuses in place
|
|
132
|
+
- `--clean`: disable in-place TTY updates and print only final per-file verdict lines. Useful for CI/CD.
|
|
133
|
+
|
|
134
|
+
Example:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
ast build --enable try-as
|
|
138
|
+
ast test --disable coverage
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Mocking
|
|
142
|
+
|
|
143
|
+
Use these helpers when you need to replace behavior during tests:
|
|
144
|
+
|
|
145
|
+
- `mockFn(oldFn, newFn)`: rewrites subsequent calls to `oldFn` in the same spec file to use `newFn`
|
|
146
|
+
- `unmockFn(oldFn)`: stops that rewrite for subsequent calls
|
|
147
|
+
- `mockImport("module.field", fn)`: sets the runtime mock for an external import
|
|
148
|
+
- `unmockImport("module.field")`: clears the runtime mock for an external import
|
|
149
|
+
- `snapshotImport<T = Function | string>(imp: T, version: string | i32)`: snapshots a single import mock
|
|
150
|
+
- `snapshotImport<T = Function | string>(imp: T, capture: () => unknown)`: runs `capture` and snapshots using version `"default"`
|
|
151
|
+
- `restoreImport<T = Function | string>(imp: T, version: string | i32)`: restores a single import mock
|
|
152
|
+
|
|
153
|
+
Example:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import {
|
|
157
|
+
expect,
|
|
158
|
+
it,
|
|
159
|
+
mockFn,
|
|
160
|
+
mockImport,
|
|
161
|
+
restoreImport,
|
|
162
|
+
run,
|
|
163
|
+
snapshotImport,
|
|
164
|
+
unmockFn,
|
|
165
|
+
unmockImport,
|
|
166
|
+
} from "as-test";
|
|
167
|
+
import { foo } from "./mock";
|
|
168
|
+
|
|
169
|
+
mockImport("mock.foo", (): string => "buz");
|
|
170
|
+
mockFn(foo, (): string => "baz " + foo());
|
|
171
|
+
|
|
172
|
+
it("mocked function", () => {
|
|
173
|
+
expect(foo()).toBe("baz buz");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
unmockFn(foo);
|
|
177
|
+
|
|
178
|
+
it("function restored", () => {
|
|
179
|
+
expect(foo()).toBe("buz");
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
snapshotImport(foo, 1);
|
|
183
|
+
mockImport("mock.foo", (): string => "temp");
|
|
184
|
+
snapshotImport("mock.foo", "v2");
|
|
185
|
+
restoreImport(foo, 1);
|
|
186
|
+
|
|
187
|
+
snapshotImport("mock.foo", () => foo()); // snapshots to version "default"
|
|
188
|
+
restoreImport("mock.foo", "default");
|
|
189
|
+
|
|
190
|
+
unmockImport("mock.foo");
|
|
191
|
+
mockImport("mock.foo", (): string => "buz");
|
|
192
|
+
|
|
193
|
+
run();
|
|
194
|
+
```
|
|
93
195
|
|
|
94
196
|
## Snapshots
|
|
95
197
|
|
|
@@ -152,10 +254,13 @@ Example:
|
|
|
152
254
|
"snapshotDir": "./.as-test/snapshots",
|
|
153
255
|
"config": "none",
|
|
154
256
|
"coverage": true,
|
|
257
|
+
"env": {},
|
|
155
258
|
"buildOptions": {
|
|
259
|
+
"cmd": "",
|
|
156
260
|
"args": [],
|
|
157
261
|
"target": "wasi"
|
|
158
262
|
},
|
|
263
|
+
"modes": {},
|
|
159
264
|
"runOptions": {
|
|
160
265
|
"runtime": {
|
|
161
266
|
"cmd": "node ./.as-test/runners/default.wasi.js <file>"
|
|
@@ -172,11 +277,162 @@ Key fields:
|
|
|
172
277
|
- `logs`: log output dir or `"none"`
|
|
173
278
|
- `coverageDir`: coverage output dir or `"none"`
|
|
174
279
|
- `snapshotDir`: snapshot storage dir
|
|
280
|
+
- `env`: environment variables injected into build and runtime processes
|
|
281
|
+
- `buildOptions.cmd`: optional custom build command template; when set it replaces default build command and flags. Supports `<file>`, `<name>`, `<outFile>`, `<target>`, `<mode>`
|
|
175
282
|
- `buildOptions.target`: `wasi` or `bindings`
|
|
283
|
+
- `modes`: named overrides for command/target/args/runtime/env/artifact directories (selected via `--mode`); `mode.env` overrides top-level `env`
|
|
176
284
|
- `runOptions.runtime.cmd`: runtime command, supports `<file>` and `<name>`; if its script path is missing, as-test falls back to the default runner for the selected target
|
|
177
|
-
- `runOptions.reporter`:
|
|
285
|
+
- `runOptions.reporter`: reporter selection as a string or object
|
|
286
|
+
|
|
287
|
+
Example multi-runtime matrix:
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"modes": {
|
|
292
|
+
"wasi-simd": {
|
|
293
|
+
"buildOptions": {
|
|
294
|
+
"target": "wasi",
|
|
295
|
+
"args": ["--enable", "simd"]
|
|
296
|
+
},
|
|
297
|
+
"runOptions": {
|
|
298
|
+
"runtime": {
|
|
299
|
+
"cmd": "wasmer run <file>"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
"wasi-nosimd": {
|
|
304
|
+
"buildOptions": {
|
|
305
|
+
"target": "wasi"
|
|
306
|
+
},
|
|
307
|
+
"runOptions": {
|
|
308
|
+
"runtime": {
|
|
309
|
+
"cmd": "wasmer run <file>"
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
"bindings-node-simd": {
|
|
314
|
+
"buildOptions": {
|
|
315
|
+
"target": "bindings",
|
|
316
|
+
"args": ["--enable", "simd"]
|
|
317
|
+
},
|
|
318
|
+
"runOptions": {
|
|
319
|
+
"runtime": {
|
|
320
|
+
"cmd": "node ./.as-test/runners/default.bindings.js <file>"
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Run all modes:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
ast test --mode wasi-simd,wasi-nosimd,bindings-node-simd
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Summary totals:
|
|
335
|
+
|
|
336
|
+
- `Modes` in the default reporter is config-scoped (`total` is all configured modes)
|
|
337
|
+
- when selecting fewer modes with `--mode`, unselected modes are counted as `skipped`
|
|
338
|
+
- `Files` in the default reporter is also config-scoped (`total` is all files from configured input patterns)
|
|
339
|
+
- when selecting fewer files, unselected files are counted as `skipped`
|
|
340
|
+
|
|
341
|
+
When using `--mode`, compiled artifacts are emitted as:
|
|
342
|
+
|
|
343
|
+
```text
|
|
344
|
+
<test-name>.<mode>.<target>.wasm
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Example:
|
|
348
|
+
|
|
349
|
+
```text
|
|
350
|
+
math.wasi-simd.wasi.wasm
|
|
351
|
+
math.bindings-node-simd.bindings.wasm
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Bindings runner naming:
|
|
355
|
+
|
|
356
|
+
- preferred: `./.as-test/runners/default.bindings.js`
|
|
357
|
+
- deprecated but supported: `./.as-test/runners/default.run.js`
|
|
358
|
+
|
|
359
|
+
`ast init` now scaffolds both local runners:
|
|
360
|
+
|
|
361
|
+
- `.as-test/runners/default.wasi.js`
|
|
362
|
+
- `.as-test/runners/default.bindings.js`
|
|
363
|
+
|
|
364
|
+
## Custom Reporters
|
|
365
|
+
|
|
366
|
+
Built-in TAP reporter (useful for CI, including GitHub Actions):
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
ast run --reporter tap
|
|
370
|
+
```
|
|
178
371
|
|
|
179
|
-
|
|
372
|
+
TAP output is written to `./.as-test/reports/report.tap` by default.
|
|
373
|
+
|
|
374
|
+
Or in config:
|
|
375
|
+
|
|
376
|
+
```json
|
|
377
|
+
{
|
|
378
|
+
"runOptions": {
|
|
379
|
+
"reporter": "tap"
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Or with reporter object config:
|
|
385
|
+
|
|
386
|
+
```json
|
|
387
|
+
{
|
|
388
|
+
"runOptions": {
|
|
389
|
+
"reporter": {
|
|
390
|
+
"name": "tap",
|
|
391
|
+
"options": ["single-file"],
|
|
392
|
+
"outDir": "./.as-test/reports"
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
`options` supports `single-file` (default) and `per-file`.
|
|
399
|
+
|
|
400
|
+
Single-file explicit path:
|
|
401
|
+
|
|
402
|
+
```json
|
|
403
|
+
{
|
|
404
|
+
"runOptions": {
|
|
405
|
+
"reporter": {
|
|
406
|
+
"name": "tap",
|
|
407
|
+
"outFile": "./.as-test/reports/report.tap"
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
In GitHub Actions, failed TAP points emit `::error` annotations with file and line when available.
|
|
414
|
+
|
|
415
|
+
Example GitHub workflow (Bun + Wasmtime + TAP summary):
|
|
416
|
+
|
|
417
|
+
```yaml
|
|
418
|
+
name: Run Tests
|
|
419
|
+
|
|
420
|
+
on: [push, pull_request]
|
|
421
|
+
|
|
422
|
+
jobs:
|
|
423
|
+
build:
|
|
424
|
+
runs-on: ubuntu-latest
|
|
425
|
+
steps:
|
|
426
|
+
- uses: actions/checkout@v4
|
|
427
|
+
- uses: jcbhmr/setup-wasmtime@v2
|
|
428
|
+
- uses: oven-sh/setup-bun@v1
|
|
429
|
+
- run: bun install
|
|
430
|
+
- run: bun run test --update-snapshots --tap
|
|
431
|
+
- uses: test-summary/action@v2
|
|
432
|
+
if: always()
|
|
433
|
+
with:
|
|
434
|
+
paths: ".as-test/reports/*.tap"
|
|
435
|
+
```
|
|
180
436
|
|
|
181
437
|
Set reporter path in config:
|
|
182
438
|
|
|
@@ -188,6 +444,13 @@ Set reporter path in config:
|
|
|
188
444
|
}
|
|
189
445
|
```
|
|
190
446
|
|
|
447
|
+
It's even possible to use something like [tap-summary](https://github.com/zoubin/tap-summary) to summarize the test results!
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
npm install -g tap-summary
|
|
451
|
+
ast test --reporter tap | tap-summary
|
|
452
|
+
```
|
|
453
|
+
|
|
191
454
|
Reporter module should export `createReporter` (named or default):
|
|
192
455
|
|
|
193
456
|
```js
|
|
@@ -205,6 +468,8 @@ export function createReporter(context) {
|
|
|
205
468
|
}
|
|
206
469
|
```
|
|
207
470
|
|
|
471
|
+
With these hooks, you can emit machine-readable output (for example TAP/JSON) while still keeping the default human-readable terminal view for local runs.
|
|
472
|
+
|
|
208
473
|
## Assertions
|
|
209
474
|
|
|
210
475
|
Skip helpers:
|
|
@@ -80,10 +80,23 @@
|
|
|
80
80
|
],
|
|
81
81
|
"default": true
|
|
82
82
|
},
|
|
83
|
+
"env": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"description": "Environment variables injected when building/running.",
|
|
86
|
+
"additionalProperties": {
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"default": {}
|
|
90
|
+
},
|
|
83
91
|
"buildOptions": {
|
|
84
92
|
"type": "object",
|
|
85
93
|
"additionalProperties": false,
|
|
86
94
|
"properties": {
|
|
95
|
+
"cmd": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"description": "Custom build command template. When set, this replaces the default asc command/flags/output handling. Supports placeholders: <file>, <name>, <outFile>, <target>, <mode>.",
|
|
98
|
+
"default": ""
|
|
99
|
+
},
|
|
87
100
|
"args": {
|
|
88
101
|
"type": "array",
|
|
89
102
|
"items": {
|
|
@@ -98,10 +111,135 @@
|
|
|
98
111
|
}
|
|
99
112
|
},
|
|
100
113
|
"default": {
|
|
114
|
+
"cmd": "",
|
|
101
115
|
"args": [],
|
|
102
116
|
"target": "wasi"
|
|
103
117
|
}
|
|
104
118
|
},
|
|
119
|
+
"modes": {
|
|
120
|
+
"type": "object",
|
|
121
|
+
"description": "Named build/run modes. Each mode can override target/args/runtime/env and artifact directories.",
|
|
122
|
+
"additionalProperties": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"additionalProperties": false,
|
|
125
|
+
"properties": {
|
|
126
|
+
"outDir": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"description": "Mode-specific build output directory. If omitted, defaults to <outDir>/<mode-name>."
|
|
129
|
+
},
|
|
130
|
+
"logs": {
|
|
131
|
+
"type": "string",
|
|
132
|
+
"description": "Mode-specific log output directory."
|
|
133
|
+
},
|
|
134
|
+
"coverageDir": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"description": "Mode-specific coverage output directory."
|
|
137
|
+
},
|
|
138
|
+
"snapshotDir": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"description": "Mode-specific snapshot directory."
|
|
141
|
+
},
|
|
142
|
+
"config": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"description": "Mode-specific asconfig path or \"none\"."
|
|
145
|
+
},
|
|
146
|
+
"coverage": {
|
|
147
|
+
"description": "Mode-specific coverage settings.",
|
|
148
|
+
"oneOf": [
|
|
149
|
+
{
|
|
150
|
+
"type": "boolean"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"type": "object",
|
|
154
|
+
"additionalProperties": true,
|
|
155
|
+
"properties": {
|
|
156
|
+
"enabled": {
|
|
157
|
+
"type": "boolean"
|
|
158
|
+
},
|
|
159
|
+
"includeSpecs": {
|
|
160
|
+
"type": "boolean"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
"buildOptions": {
|
|
167
|
+
"type": "object",
|
|
168
|
+
"additionalProperties": false,
|
|
169
|
+
"properties": {
|
|
170
|
+
"cmd": {
|
|
171
|
+
"type": "string",
|
|
172
|
+
"description": "Mode-specific custom build command template."
|
|
173
|
+
},
|
|
174
|
+
"args": {
|
|
175
|
+
"type": "array",
|
|
176
|
+
"items": {
|
|
177
|
+
"type": "string"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"target": {
|
|
181
|
+
"type": "string",
|
|
182
|
+
"enum": ["wasi", "bindings"]
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"runOptions": {
|
|
187
|
+
"type": "object",
|
|
188
|
+
"additionalProperties": false,
|
|
189
|
+
"properties": {
|
|
190
|
+
"runtime": {
|
|
191
|
+
"type": "object",
|
|
192
|
+
"additionalProperties": false,
|
|
193
|
+
"properties": {
|
|
194
|
+
"cmd": {
|
|
195
|
+
"type": "string",
|
|
196
|
+
"description": "Mode-specific runtime command."
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"reporter": {
|
|
201
|
+
"description": "Mode-specific reporter config.",
|
|
202
|
+
"oneOf": [
|
|
203
|
+
{
|
|
204
|
+
"type": "string"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"type": "object",
|
|
208
|
+
"additionalProperties": false,
|
|
209
|
+
"properties": {
|
|
210
|
+
"name": {
|
|
211
|
+
"type": "string"
|
|
212
|
+
},
|
|
213
|
+
"options": {
|
|
214
|
+
"type": "array",
|
|
215
|
+
"items": {
|
|
216
|
+
"type": "string"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"outDir": {
|
|
220
|
+
"type": "string"
|
|
221
|
+
},
|
|
222
|
+
"outFile": {
|
|
223
|
+
"type": "string"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"required": ["name"]
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"env": {
|
|
233
|
+
"type": "object",
|
|
234
|
+
"description": "Environment variables injected when building/running this mode.",
|
|
235
|
+
"additionalProperties": {
|
|
236
|
+
"type": "string"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"default": {}
|
|
242
|
+
},
|
|
105
243
|
"runOptions": {
|
|
106
244
|
"type": "object",
|
|
107
245
|
"additionalProperties": false,
|
|
@@ -121,8 +259,39 @@
|
|
|
121
259
|
}
|
|
122
260
|
},
|
|
123
261
|
"reporter": {
|
|
124
|
-
"
|
|
125
|
-
"
|
|
262
|
+
"description": "Reporter selection. Use a string for built-in/default/custom path, or an object for named reporter configuration.",
|
|
263
|
+
"oneOf": [
|
|
264
|
+
{
|
|
265
|
+
"type": "string",
|
|
266
|
+
"description": "\"\" or \"default\" uses built-in default reporter, \"tap\" uses built-in TAP v13 reporter, otherwise treated as custom module path."
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"type": "object",
|
|
270
|
+
"additionalProperties": false,
|
|
271
|
+
"properties": {
|
|
272
|
+
"name": {
|
|
273
|
+
"type": "string",
|
|
274
|
+
"description": "Reporter name or module path. Built-in values: \"default\", \"tap\"."
|
|
275
|
+
},
|
|
276
|
+
"options": {
|
|
277
|
+
"type": "array",
|
|
278
|
+
"description": "Reporter options. TAP supports \"single-file\" (default) and \"per-file\".",
|
|
279
|
+
"items": {
|
|
280
|
+
"type": "string"
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"outDir": {
|
|
284
|
+
"type": "string",
|
|
285
|
+
"description": "TAP output directory. Defaults to \"./.as-test/reports\"."
|
|
286
|
+
},
|
|
287
|
+
"outFile": {
|
|
288
|
+
"type": "string",
|
|
289
|
+
"description": "TAP output file path for single-file mode. Defaults to \"./.as-test/reports/report.tap\"."
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"required": ["name"]
|
|
293
|
+
}
|
|
294
|
+
],
|
|
126
295
|
"default": ""
|
|
127
296
|
}
|
|
128
297
|
},
|
package/assembly/coverage.ts
CHANGED
|
@@ -23,6 +23,26 @@ export function __REGISTER(point: CoverPoint): void {
|
|
|
23
23
|
Coverage.SN.hashes.set(point.hash, point);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
export function __REGISTER_RAW(
|
|
27
|
+
file: string,
|
|
28
|
+
hash: string,
|
|
29
|
+
line: i32,
|
|
30
|
+
column: i32,
|
|
31
|
+
type: string,
|
|
32
|
+
): void {
|
|
33
|
+
if (Coverage.SN.allIndex.has(hash)) return;
|
|
34
|
+
const point = new CoverPoint();
|
|
35
|
+
point.file = file;
|
|
36
|
+
point.hash = hash;
|
|
37
|
+
point.line = line;
|
|
38
|
+
point.column = column;
|
|
39
|
+
point.type = type;
|
|
40
|
+
Coverage.SN.points++;
|
|
41
|
+
Coverage.SN.allIndex.set(hash, Coverage.SN.all.length);
|
|
42
|
+
Coverage.SN.all.push(point);
|
|
43
|
+
Coverage.SN.hashes.set(hash, point);
|
|
44
|
+
}
|
|
45
|
+
|
|
26
46
|
export function __COVER(hash: string): void {
|
|
27
47
|
if (Coverage.SN.allIndex.has(hash)) {
|
|
28
48
|
const index = Coverage.SN.allIndex.get(hash);
|