I would like to use a different runner for tests. It would be really convenient to test Wasm files. I would imagine something like this to work:
runner = "default_runner"
runner = "test_runer"
default_runner is always used, even when running
cargo test. Is there maybe a workaround for this? A different cfg that could be used?
I don't think there is. In a wrapper around the runner maybe you could check if the wasm file exists in the
test directory of the build dir and then dispatch to the right runner?
Thanks for the suggestion, this sounds like an ok tradeoff for now. I just can't find a
test sub-directory in the build one. When I run
cargo test the .wasm file is generated in the deps folder:
I'm just worried when the runner is used outside of the cargo structure that relaying on such a common name as
deps may create an issue. I think I will combine it with detecting a cargo set environment variable, like
$CARGO_MANIFEST_DIR to harden a bit the detection.
Are there any other cargo commands that generate their builds inside of the
deps directory, like
cargo run --example?
cargo xxx? Just to check if I'm missing an obvious case where this approach would fail?
cargo bench uses the same build directory. So you also need to check for a
cargo test --example <name> can't be covered with this approach, because it will end up in the examples build directory.