Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a wit-bindgen test subcommand #1192

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

alexcrichton
Copy link
Member

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.

@alexcrichton
Copy link
Member Author

For now I'd definitely considere this in a "hopefully working" but still somewhat draft form. I'm curious to get others' feedback on this design and possible improvements (if anyone has any).

Documentation is available here in rendered form.

The remaining work items after this PR are:

  • Finish migrating other languages supported in this repository to this new test subcommand: C# and teavm-java.
  • Finish migrating Rust codegen tests to this repository
  • Migrate all preexisting tests/runtime/* tests to tests/runtime-new/* (this new subcommand)
  • Jettison crates/test-helpers and all other preexisting test support.

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 bytecodealliance#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.
Use one deduplicated method for showing a list of errors.
Add in configuration to drop default bindings args, aka `--generate-all`
in Rust.
* 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`.
@alexcrichton
Copy link
Member Author

@pchickey would you be willing to take on review of this?

If you're ok with it you can ignore all changes in test/* and take my word for it that tests are migrated over. That leaves mostly just crates/test/* and some misc changes here and there which should in theory be much smaller than the 7kloc size as posted on the PR itself

@pchickey pchickey self-requested a review March 10, 2025 22:51
alexcrichton added a commit to alexcrichton/witx-bindgen that referenced this pull request Mar 11, 2025
This has been unmaintained for quite some time now and has never reached
feature parity with other backends. In preparation for bytecodealliance#1192 this commit
removes the teavm-java generator entirely with a "tombstone" left in the
README about the last commit which had the code.
alexcrichton added a commit to alexcrichton/witx-bindgen that referenced this pull request Mar 11, 2025
This has been unmaintained for quite some time now and has never reached
feature parity with other backends. In preparation for bytecodealliance#1192 this commit
removes the teavm-java generator entirely with a "tombstone" left in the
README about the last commit which had the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant