tests: add WASI integration test support via wasmtime#11717
Open
DePasqualeOrg wants to merge 1 commit intouutils:mainfrom
Open
tests: add WASI integration test support via wasmtime#11717DePasqualeOrg wants to merge 1 commit intouutils:mainfrom
DePasqualeOrg wants to merge 1 commit intouutils:mainfrom
Conversation
Add UUTESTS_WASM_RUNNER support to the test framework, enabling host-compiled integration tests to exercise a WASI binary through wasmtime. This runs ~1,230 existing tests across 26 tools without needing to compile the test harness for WASI.
This was referenced Apr 8, 2026
Contributor
|
Why do not just use #[cfg] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds WASI integration test support, enabling ~1,250 existing integration tests across 26 tools to run against the WASI binary via wasmtime.
The changes have gone through multiple rounds of review and refinement with Claude Code and Codex. I have tested them on macOS and Linux.
The test framework now supports a
UUTESTS_WASM_RUNNERenvironment variable. When set (e.g., towasmtime), the test harness wraps each command invocation through the runner instead of executing the binary directly. The host-compiled integration tests exercise the WASI binary end to end without needing to compile the test harness itself for WASI.Key changes:
tests/tests.rs: AllowUUTESTS_BINARY_PATHto be overridden by the environment, so tests can target a WASI binary instead of the host binarytests/uutests/src/lib/util.rs: WhenUUTESTS_WASM_RUNNERis set, wrap command invocation through the runner with--dir,--argv0, and--envflags to map the working directory, set the binary name, and forward environment variables to the WASI guesttests/uutests/src/lib/util.rs: Adjustusage_errorassertions to use the filename (from--argv0) instead of the full path when a WASM runner is active.github/workflows/wasi.yml: Add an integration test step that builds the WASI binary and runs tests through wasmtimetests/by-util/test_basenc.rs,test_comm.rs,test_od.rs,test_tr.rs,test_wc.rs: Add conditional expectations for error messages, formatting, and collation behavior that differ between host libc and wasi-libcTools tested (26)
base32, base64, basenc, basename, comm, cut, dirname, echo, expand, factor, false, fold, head, link, nl, numfmt, od, paste, printf, shuf, sum, tee, tr, true, truncate, unexpand, unlink, wc
Adding more tools
Tools not yet included in the integration test run are tracked in a TODO comment in
.github/workflows/wasi.yml. As WASI support is extended for these tools, they can be moved from the TODO list to the test list, with any necessary skips added for WASI-specific limitations.Skipped tests by category
Tests are skipped for documented WASI platform limitations:
/proc,/sys, or/devpaths that are not available inside the WASI sandbox (the guest root is mapped to the test's working directory)