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

Refactor how wasm features are calculated for *.wast tests #9560

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

alexcrichton
Copy link
Member

This commit refactors the tests/wast.rs test suite which runs all of the upstream spec tests as *.wast files as well as our own misc_testsuite which has its own suite of *.wast files. Previously the set of wasm features active for each test was a sort of random mishmash and convoluted set of conditionals which was updated and edited over time as upstream proposal test suites evolved. This was then mirrored into our own conventions for misc_testsuite as well. Overall though this has a number of downsides I'm trying to fix here:

  • The calculation of what features are enabled is quite complicated and effectively a random mishmash of || conditionals with hierarchies that don't make any sense beyond "this is just required to get things to pass".

  • There is no means of per-test configuration. For example canonicalize-nans.wast had hardcoded logic in tests/wast.rs that it needed a different setting turned on in Config.

  • There was no easy means to write tests for Wasmtime which take a union of a number of proposals together without having lots of sub-folders that may not make sense.

  • Tests that require a particular proposal had to have duplicate logic for Winch as it doesn't support the full suite of features of all proposals that Cranelift does.

The new system implemented in this commit takes a leaf out of the disas tests. There is a new TestConfig structure in the tests/wast.rs harness which is decoded from each test (leading ;;! comments) which enables specifying, in each test, what's required. This encompasses many wasm proposals but additionally captures other behavior like nan-canonicalization. This means that all test files in misc_testsuite/**/*.wast are now manually annotated with what wasm features they require and what's needed to run. This makes per-test configuration much easier, per-config-setting much easier, and blanket ignore-by-proposal for Winch much easier as well.

For spec tests we can't modify the contents of the upstream *.wast files. To handle this they're handled specially where TestConfig is manually created and manipulated for each spec proposal and the main test suite itself. This enables per-proposal configuration that doesn't leak into any others and makes it more obvious what proposals are doing what.

This commit refactors the `tests/wast.rs` test suite which runs all of
the upstream spec tests as `*.wast` files as well as our own
`misc_testsuite` which has its own suite of `*.wast` files. Previously
the set of wasm features active for each test was a sort of random
mishmash and convoluted set of conditionals which was updated and edited
over time as upstream proposal test suites evolved. This was then
mirrored into our own conventions for `misc_testsuite` as well. Overall
though this has a number of downsides I'm trying to fix here:

* The calculation of what features are enabled is quite complicated and
  effectively a random mishmash of `||` conditionals with hierarchies
  that don't make any sense beyond "this is just required to get things
  to pass".

* There is no means of per-test configuration. For example
  `canonicalize-nans.wast` had hardcoded logic in `tests/wast.rs` that
  it needed a different setting turned on in `Config`.

* There was no easy means to write tests for Wasmtime which take a union
  of a number of proposals together without having lots of sub-folders
  that may not make sense.

* Tests that require a particular proposal had to have duplicate logic
  for Winch as it doesn't support the full suite of features of all
  proposals that Cranelift does.

The new system implemented in this commit takes a leaf out of the
`disas` tests. There is a new `TestConfig` structure in the
`tests/wast.rs` harness which is decoded from each test (leading `;;!`
comments) which enables specifying, in each test, what's required. This
encompasses many wasm proposals but additionally captures other behavior
like nan-canonicalization. This means that all test files in
`misc_testsuite/**/*.wast` are now manually annotated with what wasm
features they require and what's needed to run. This makes per-test
configuration much easier, per-config-setting much easier, and blanket
ignore-by-proposal for Winch much easier as well.

For spec tests we can't modify the contents of the upstream `*.wast`
files. To handle this they're handled specially where `TestConfig` is
manually created and manipulated for each spec proposal and the main
test suite itself. This enables per-proposal configuration that doesn't
leak into any others and makes it more obvious what proposals are doing
what.
@alexcrichton alexcrichton requested a review from a team as a code owner November 5, 2024 18:31
@alexcrichton alexcrichton requested review from pchickey and fitzgen and removed request for a team November 5, 2024 18:31
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Very nice!

@fitzgen fitzgen added this pull request to the merge queue Nov 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 5, 2024
@alexcrichton alexcrichton added this pull request to the merge queue Nov 5, 2024
Merged via the queue into bytecodealliance:main with commit 60fc557 Nov 5, 2024
40 checks passed
@alexcrichton alexcrichton deleted the refactor-wast branch November 5, 2024 21:42
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.

2 participants