Open webmaster128 opened 4 years ago
Thanks to @hjorthjort we found a way to pass and empty argc
and argv
.
Passing tests:
$ wasmer run target/wasm32-unknown-unknown/debug/serde_json_wasm-c815590b4f16f3c6.wasm -- 0 0
main([I32(0), I32(0)]) returned [I32(0)]
Tests with failures:
$ wasmer run target/wasm32-unknown-unknown/debug/serde_json_wasm-c815590b4f16f3c6.wasm -- 0 0
Error: RuntimeError: Caught exception of type "Unreachable".
It would be cool if we could compile our unit tests to Wasm and run them in a Wasm runner, such as Wasmer. This ensures that architecture-specific code behaves correctly, such
usize
being 32 bit instead of 64 bit.Unit tests can be compiled to Wasm using
cargo build --tests --target wasm32-unknown-unknown
. This gives us a test binary liketarget/wasm32-unknown-unknown/debug/serde_json_wasm-0930ffa5c8b80699.wasm
with a main function:I tried to run this with the Wasmer CLI but have no idea what to pass in the two arguments.
Edit: the full main function is
and std::rt::lang_start is defined here.