-
Notifications
You must be signed in to change notification settings - Fork 270
Cannot run simple unit test with default Rust template #672
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
Comments
This is similar to what I encountered in spinframework/spin-fileserver#15. Probably, we can use |
Given that all our Rust templates explicitly build to |
It sounds like we've converged on #672 (comment) as being the approved fix here? Shall we move into the Backlog? |
The default Rust template for a Spin application sets the default build target in
.cargo/config.toml
aswasm32-wasi
:This make sense in order to ensure
cargo build
creates a module that Spin can run, but this means that a simple unit test that purely wants to test some logic in the handler cannot be run:cargo test
, this fails because it would try to instantiate a Wasm binary and run the test:cargo wasi test
, this fails because of host imports that are not available in Wasmtime directly (but are in Spin):The workaround for this is to remove the default target in
.cargo/config.toml
and runcargo test
— assuming this only tests logic that does not have anything to do with Wasm or Spin functionality.Because in the default Rust template we have a build command that sets the target to
wasm32-wasi
, do we want to remove the default target in the Cargo configuration file so testing withcargo test
works for simple unit tests?The text was updated successfully, but these errors were encountered: