jiff/scripts/test-wasm
Andrew Gallant fa62c4fbd7 scripts: fix test-wasm
I'm not sure why this used to work, but now it matches CI and actually
works.
2025-03-06 16:05:00 -05:00

29 lines
870 B
Bash
Executable file

#!/bin/sh
set -e
# cd to the directory containing this crate's Cargo.toml so that we don't need
# to pass --manifest-path to every `cargo` command.
cd "$(dirname "$0")/.."
if [ $# = 0 ]; then
echo "Usage: ./test-wasm <cargo command>" >&2
echo "Example: ./test-wasm cargo test --lib -- --nocapture" >&2
exit 1
fi
if ! command -V rustup &> /dev/null; then
echo 'please install rustup' >&2
exit 1
fi
if ! rustup target list | grep installed | grep -q wasm32-wasip1; then
echo 'please run `rustup target add wasm32-wasip1` first' >&2
exit 1
fi
export WASMTIME_BACKTRACE_DETAILS=1
export CARGO_BUILD_TARGET=wasm32-wasip1
# Not sure exactly why this is needed, but without it,
# `insta` tries to run `cargo`, and wasip1 doesn't like that.
export INSTA_WORKSPACE_ROOT="$PWD"
export CARGO_TARGET_WASM32_WASIP1_RUNNER="wasmtime run --dir / -S inherit-env"
"$@"