| 1 |
# Wasm Spec Tests |
| 2 |
|
| 3 |
This directory contains scripts and configs to manage the in-tree import of the |
| 4 |
wasm spec testsuite. |
| 5 |
|
| 6 |
## Format of tests |
| 7 |
|
| 8 |
Spec tests are given in `test/core` of the `spec` repository as `.wast` files. |
| 9 |
A `.wast` file is a superset of the `.wat` format with commands for running |
| 10 |
tests. |
| 11 |
|
| 12 |
The spec interpreter can natively consume `.wast` files to run the tests, but |
| 13 |
we cannot run them directly ourselves. To workaround this, we have a tool which |
| 14 |
can convert `.wast` files to `.js` that can be run efficiently in our jit-test |
| 15 |
harness. |
| 16 |
|
| 17 |
## Running tests |
| 18 |
|
| 19 |
Tests are imported to `jit-test` to be run in the JS shell. |
| 20 |
|
| 21 |
To run under `jit-test`: |
| 22 |
```bash |
| 23 |
cd js/src |
| 24 |
./jit-test.py path_to_build/dist/bin/js wasm/spec/ |
| 25 |
``` |
| 26 |
|
| 27 |
## Test importing |
| 28 |
|
| 29 |
There are many proposals in addition to the canonical spec. Each proposal is a |
| 30 |
fork of the canonical spec and may modify any amount of files. |
| 31 |
|
| 32 |
This causes a challenge for any engine implementing multiple proposals, as any |
| 33 |
proposal may conflict (and often will) with each other. This makes it |
| 34 |
infeasible to merge all spec and proposal repos together. |
| 35 |
|
| 36 |
Testing each proposal separately in full isn't an attractive option either, as |
| 37 |
most tests are unchanged and that would cause a significant amount of wasted |
| 38 |
computation time. |
| 39 |
|
| 40 |
For this reason, we generate a set of separate test-suites that are 'pruned' to |
| 41 |
obtain a minimal set of tests. The tool works by merging each proposal with the |
| 42 |
proposal it is based off of and removing tests that have not changed. |
| 43 |
|
| 44 |
### Configuration |
| 45 |
|
| 46 |
The import tool relies on `config.toml` for the list of proposals to import, |
| 47 |
and `config-lock.toml` for a list of commits to use for each proposal. |
| 48 |
|
| 49 |
The lock file makes test importing deterministic and controllable. This is |
| 50 |
useful as proposals often make inconvenient and breaking changes. |
| 51 |
|
| 52 |
### Operation |
| 53 |
|
| 54 |
```bash |
| 55 |
# Add, remove, or modify proposals |
| 56 |
vim generate-spectests/config.toml |
| 57 |
# Remove locks for any proposals you wish to pull the latest changes on |
| 58 |
vim generate-spectests/config-lock.toml |
| 59 |
# Import the tests |
| 60 |
make update |
| 61 |
# View the tests that were imported |
| 62 |
hg stat |
| 63 |
# Run the imported tests and note failures |
| 64 |
./jit-test.py dist/bin/js wasm/spec/ |
| 65 |
# Exclude test failures |
| 66 |
vim generate-spectests/config.toml |
| 67 |
# Re-import the tests to exclude failing tests |
| 68 |
make update |
| 69 |
# Commit the changes |
| 70 |
hg commit |
| 71 |
``` |
| 72 |
|
| 73 |
### Debugging import failures |
| 74 |
|
| 75 |
Proposals can often have conflicts with their upstream proposals. This is okay, |
| 76 |
and the test importer will fallback to building tests on an unmerged tree. |
| 77 |
|
| 78 |
This will likely result in extra tests being imported due to spurious |
| 79 |
differences between the proposal and upstream, but generally is okay. |
| 80 |
|
| 81 |
The import tool uses `RUST_LOG` to output debug information. `Makefile` |
| 82 |
automatically uses `RUST_LOG=info`. Change that to `RUST_LOG=debug` to get |
| 83 |
verbose output of all the commands run. |