Skip to content

Commit

Permalink
README, Makefile: update testing instructions, add make golden target
Browse files Browse the repository at this point in the history
  • Loading branch information
ydnar committed Aug 31, 2024
1 parent df30e68 commit 5d7df13
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
wit_files = $(sort $(shell find testdata -name '*.wit' ! -name '*.golden.*'))

# json recompiles the JSON intermediate representation test files.
.PHONY: json
json: $(wit_files)

.PHONY: $(wit_files)
$(wit_files):
wasm-tools component wit -j --all-features $@ > $@.json

# golden recompiles the .golden.wit test files.
.PHONY: golden
golden: json
go test ./wit -update
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,31 @@ This will emit JSON on `stdout`, which can be piped to a file or another program
wasm-tools component wit -j --all-features example.wit > example.wit.json
```

## License
## Contributing

This project is licensed under the Apache 2.0 license with the LLVM exception. See [LICENSE](LICENSE) for more details.
Developing and testing `wit-bindgen-go` requires an up-to-date installation of [Go](https://go.dev), [TinyGo](https://tinygo.org), [Wasmtime](https://wasmtime.dev), and [`wasm-tools`](https://crates.io/crates/wasm-tools).

### Contributing
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Developing and testing `wit-bindgen-go` requires an up-to-date installation of [Go](https://go.dev), [TinyGo](https://tinygo.org), and [`wasm-tools`](https://crates.io/crates/wasm-tools).
### Testing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
Tests are supported under both Go and TinyGo, on Linux, macOS, and WebAssembly.

```sh
go test ./...
tinygo test ./...
```

Testing with WebAssembly (`wasip1`) requires an installation of [`go_wasip1_wasm32_exec`](https://go.dev/blog/wasi) and [Wasmtime](https://wasmtime.dev). WASI 0.2 `wasip2` is supported under TinyGo version 0.33.0 or later.

```sh
GOARCH=wasm GOOS=wasip1 go test ./...
GOARCH=wasm GOOS=wasip1 tinygo test ./...
tinygo test -target=wasip2 ./... # requires TinyGo 0.33.0 or later
```

This package contains tests that validate the round-trip parsing and re-serialization of WIT files back into WIT. To rebuild the test files in the [testdata](./testdata) directory, run `make golden`. This will reregenerate the JSON intermediate representation and the equivalent `*.golden.wit` files.

## License

This project is licensed under the Apache 2.0 license with the LLVM exception. See [LICENSE](LICENSE) for more details.

0 comments on commit 5d7df13

Please sign in to comment.