Skip to content

Commit ff4dbb4

Browse files
committed
doc: add wasm-harness explainer to README
1 parent 54ee001 commit ff4dbb4

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,29 @@ This project is currently under active development and should not be used in pro
2929
- [`matrix-transpose`](./crates/matrix-transpose/) - Bit-wise matrix transposition.
3030
- [`clmul`](./crates/clmul/) - Carry-less multiplication.
3131

32+
## Running tests/benches on WASM
33+
34+
Tests and benchmarks can be run against WASM targets using [`wasm-harness`](https://github.com/sinui0/wasm-harness), which is configured as the cargo runner for the `wasm32-wasip1` and `wasm32-wasip1-threads` targets in [`.cargo/config.toml`](./.cargo/config.toml).
35+
36+
Install the harness and a supported WASM target:
37+
38+
```bash
39+
cargo install wasm-harness
40+
rustup target add wasm32-wasip1-threads
41+
```
42+
43+
`wasm-harness` requires a WASM execution engine ([wasmtime](https://wasmtime.dev/), or V8/SpiderMonkey via [jsvu](https://github.com/GoogleChromeLabs/jsvu)). It auto-discovers an available engine, or one can be selected explicitly with `--engine` or the `WASM_HARNESS_ENGINE` environment variable.
44+
45+
Then run tests/benches as usual, passing the WASM target:
46+
47+
```bash
48+
# Run tests (use the threaded target for crates relying on rayon)
49+
cargo test -p <crate> --target wasm32-wasip1-threads
50+
51+
# Run benches
52+
cargo bench -p <crate> --target wasm32-wasip1-threads
53+
```
54+
3255
## License
3356
All crates in this repository are licensed under either of
3457

0 commit comments

Comments
 (0)