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

Migrate the rust_xcrate test to wit-bindgen test #1236

Merged
merged 2 commits into from
Mar 24, 2025

Conversation

alexcrichton
Copy link
Member

This was a tricky test to migrate. Doing this required implementing a number of new features:

  • Rust now has a [lang]-specific configuration externs = [...] which is a list of files to compile as external crates. This tests the cross-crate behavior of the test.
  • Tests now support more than just runner/test composed components, now they also support multiple components being composed. This is required because the test was specifically testing behavior where a component simultaneously imports and exports.

This last point was particularly tricky. Namely this required abstracting the definition of a test to a runner plus a list of tests, not just one test. These are still modeled as a list of world items in the original WIT document. Additionally I was having trouble getting wasm-compose working so I ended up switching to wac. This means that tests can now support custom wac composition scripts to configure how exactly the composition is created, and that's used in this new test to insert a component as a sandwich between two others.

@@ -0,0 +1,75 @@
//@ tests = ['intermediate', 'leaf']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean runner is run with both intermediate and leaf?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, and mostly points to this being a bad name. I've renamed this to dependencies which should make it more clear that these are dependencies of the runner component, not separate and individual tests. The sum total of all three components are what makes a single test.

This was a tricky test to migrate. Doing this required implementing a
number of new features:

* Rust now has a `[lang]`-specific configuration `externs = [...]` which
  is a list of files to compile as external crates. This tests the
  cross-crate behavior of the test.
* Tests now support more than just runner/test composed components, now
  they also support multiple components being composed. This is required
  because the test was specifically testing behavior where a component
  simultaneously imports and exports.

This last point was particularly tricky. Namely this required
abstracting the definition of a test to a runner plus a list of tests,
not just one test. These are still modeled as a list of `world` items in
the original WIT document. Additionally I was having trouble getting
`wasm-compose` working so I ended up switching to `wac`. This means that
tests can now support custom `wac` composition scripts to configure how
exactly the composition is created, and that's used in this new test to
insert a component as a sandwich between two others.
@alexcrichton alexcrichton enabled auto-merge March 24, 2025 20:34
@alexcrichton alexcrichton added this pull request to the merge queue Mar 24, 2025
Merged via the queue into bytecodealliance:main with commit 33442e3 Mar 24, 2025
18 checks passed
@alexcrichton alexcrichton deleted the migrate-xcrate branch March 24, 2025 21:31
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.

3 participants