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 wast subcommand to the CLI #2096

Merged
merged 10 commits into from
Mar 12, 2025
Merged

Conversation

alexcrichton
Copy link
Member

I was duly inspired by #2093 to not only add such a subcommand but also restructure the test suite. I've long felt that the current test suite is a bit of a pain especially around per-test configuration since right now it's all configured in tests/roundtrip.rs and it's also not obvious how much configuration applies to each test. With the concept of a wast subcomand I realized that we could migrate all tests to tests/cli/* which easily afforts per-test configuration, yay!

This commit thusly migrates tests/roundtrip.rs to wasm-tools wast and then moves all tests into the tests/cli/* directory. Tests aren't really cleaned up at this time but it should be much easier in the future to clean things up as needed.

This commit migrates the `tests/roundtrip.rs` file to a `wast`
subcommand of the CLI. This does not actually run tests in terms of
executing WebAssembly but it works as a way to parse the test and
validate, so everything short of runtime execution and related errors.
With the addition of the `wast` subcommand in the previous commit
there's no longer any need to have `tests/local/*`. Additionally it's
now much easier to perform per-test configuration since the flags for
the test are in the test itself.
Similarly to the previous commit of moving towards `wasm-tools wast`
this commit migrates the spec test infrastructure to using this as well.
Spec tests are now run by:

* A script, `ci/generate-spec-tests.rs`, generates files in
  `tests/cli/spec/*.wast` to run each spec test.
* Each test lists the features needed to be enabled for the test to run.
* The tests are then naturally run during the `--test cli` test suite run.

New automation is added to ensure that the version in-tree is up-to-date
to ensure we don't creep in too many files by accident.
@alexcrichton
Copy link
Member Author

I still want to put some finishing touches on this in terms of documentation, but in terms of review it should otherwise be good to go

@alexcrichton
Copy link
Member Author

documented now 👍

@alexcrichton alexcrichton requested a review from fitzgen March 12, 2025 18:44
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.

Nice!! This should also fix the issue of BLESS=1 and running a particular test, right?

Comment on lines +90 to +97
macro_rules! adjust {
($e:expr) => {{
let mut e = wast::Error::from($e);
e.set_path(test);
e.set_text(contents);
e
}};
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems like it could just be a closure, and doesn't actually need to be a macro?

Copy link
Member

Choose a reason for hiding this comment

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

Oh I guess because it is generic over the type of $e it can't be a closure. blech.

@alexcrichton
Copy link
Member Author

This should also fix the issue of BLESS=1 and running a particular test, right?

You mean where you run one test, set BLESS=1, and all of tests/snapshots is deleted? If so, yes!

@alexcrichton alexcrichton added this pull request to the merge queue Mar 12, 2025
Merged via the queue into bytecodealliance:main with commit 03ac8ab Mar 12, 2025
32 checks passed
@alexcrichton alexcrichton deleted the wast branch March 12, 2025 22:36
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