I'm compiling Rust to .wasm, and neither cargo test
(with integration tests) nor cargo run --example
work as expected. I think the problem is the same in both cases: cargo
is trying to execute the .wasm
file directly, but it's not an executable as far as my operating system is concerned.
- Is there a way to change how
cargo
runs binaries? There are ways to changerustc
andrustdoc
through configuration and env vars, but I don't see anything similar for the test runner. - I suppose I could build the tests and examples with the native target, and explicitly set the target for
.wasm
when I want that -- or vice versa (which is sort of the case now, as I have set the default target in.cargo/config.toml
towasm32-wasi
). - Assuming I can't change the test runner, and I don't want to have to remember to set the target appropriately at some point in the process, is there a way to change the target for compiling integration test and example source files? Some invocation of the
cfg
and/orcfg_attr
attributes, for instance?