test(std/wasi): build testdata resources offline #6695
Closed
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 changes up how the std/wasi test suite is built a little bit.
The build script is extrapolated to a standalone Python script. Went with Python here just because it's what I would do if the testdata directory was a standalone repository (an eventual side goal). Less friction when running the tests against other runtimes and it's what WebAssembly uses to build its own spec tests.
Tests are built ahead of time and checked in, this is because the Rust the toolchain used to build tests for a specific ABI snapshot is not necessarily the same toolchain that Deno uses so the CI isn't a suitable environment to build them on in the long run.
The motivation for this is that I'm hitting the ceiling of Rust being helpful in writing integration tests, while the assertions provided are nice and all it's difficult to get at certain syscalls so some parts just don't have any coverage. We can't even call UNIX extensions like read_at because WASI is not UNIX so I want to introduce an additional layer of tests written in C. Once we introduce C tests we hit the toolchain issue again, the toolchain installed on CI is not the one that's required for libc-wasi so it gets convoluted to set up the CI for both the native target and wasm32-wasi and overall it is just easier and cleaner to pre-bake the testdata and check it in.
A nice side effect is that a test run now takes 2 seconds, instead of the 47 seconds it takes to build and run the tests (on my machine, CI is probably significantly faster overall).