Skip to content

Commit e7656df

Browse files
authored
Add a wit-bindgen test subcommand (#1192)
* Add a `wit-bindgen test` subcommand As I've read more and more of the Rust async runtime support and other various bits and pieces I've wanted more and more the ability to easily write tests for guest interactions with the host. While I don't think it's feasible to generate arbitrary hosts I do think it's possible to do this much more easily than is done today with the testing support in this repository. In essence this commit is an implementation of #1161. The goal of this commit is to add a `wit-bindgen test` test suite runner. This test suite will be used to migrate all existing tests in this repository to this new framework. In the limit this is expected to make it easier to write tests (no Rust knowledge necessary), make it more flexible to write tests (now you can use raw `*.wat`), and additionally improve the quality of the test suite by making it more reusable. The reusability isn't the highest priority at this time as it's not clear what else would want to reuse this, but my hope is that this refactoring is at least a large-ish leap forward towards having a component model test suite of some kind eventually. * Add the p2 target * Add new crate to publish list * Update crate metadata * Add back in crate test * Don't prepare ignored languages * Actually fail the process if tests fail * Install wasmtime on CI too * Always install wasi-sdk for all deps (which is now just a bunch of deps too) * Migrate some more Rust codegen tests to the new framework * Improve rendering of errors in test subcommand Use one deduplicated method for showing a list of errors. * Remove warnings in generated Rust programs * More migrated Rust codegen tests Add in configuration to drop default bindings args, aka `--generate-all` in Rust. * Move Rust/C-specific tests to their own folder * Migrate another rust codegen test * Migrate Rust numbers test to new framework * Migrate numbers/wasm.c to new framework * Migrate the `wasm/lists.rs` test to the new framework * Migrate `lists/wasm.c` test to new framework * Update test docs * Beef up Rust support to pull in `futures` and support WASIp1 * The `futures` crate will be necessary for upcoming async tests. * Support for WASIp1 is required as `wasm32-wasip2` can't produce an async component natively as it's not new enough. * Test runner support is extended slightly to support passing runtime arguments, such as `-Wcomponent-model-async`. * Document test's `config.rs` * Enable debuginfo in Rust tests Helps symbolicate backtraces better. * Fixup some merge conflicts
1 parent ebe5fc1 commit e7656df

File tree

120 files changed

+4608
-1910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+4608
-1910
lines changed

.github/actions/install-wasi-sdk/action.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ runs:
2323
uses: bytecodealliance/actions/wasm-tools/setup@v1
2424
with:
2525
version: "1.215.0"
26-
github_token: ${{ github.token }}
26+
- name: Setup `wasmtime`
27+
uses: bytecodealliance/actions/wasmtime/setup@v1
28+
with:
29+
version: "30.0.1"

.github/workflows/main.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,12 @@ jobs:
7171
submodules: true
7272
- name: Install Rust
7373
run: rustup update stable --no-self-update && rustup default stable
74-
- run: rustup target add wasm32-wasip1
74+
- run: rustup target add wasm32-wasip1 wasm32-wasip2
7575

7676
- run: rustup target add wasm32-unknown-unknown
7777
if: matrix.lang == 'rust'
7878

7979
- uses: ./.github/actions/install-wasi-sdk
80-
if: matrix.lang == 'c' || matrix.lang == 'csharp'
8180

8281
- name: Setup .NET
8382
uses: actions/setup-dotnet@v4
@@ -106,6 +105,14 @@ jobs:
106105
--no-default-features \
107106
--features ${{ matrix.lang }} \
108107
--release
108+
- run: |
109+
cargo run test --languages rust,${{ matrix.lang }} tests/codegen \
110+
--artifacts target/artifacts \
111+
--rust-wit-bindgen-path ./crates/guest-rust
112+
- run: |
113+
cargo run test --languages rust,${{ matrix.lang }} tests/runtime-new \
114+
--artifacts target/artifacts \
115+
--rust-wit-bindgen-path ./crates/guest-rust
109116
110117
test_unit:
111118
name: Crate Unit Tests

0 commit comments

Comments
 (0)