set -euo pipefail
topdir=$(dirname "$0")
cd "$topdir"
function banner {
echo "====== $* ======"
}
banner "Rust formatting"
if cargo +stable fmt -- --version > /dev/null ; then
if ! "$topdir/format-all.sh" --check ; then
echo "Formatting diffs detected! Run \"cargo fmt --all\" to correct."
exit 1
fi
else
echo "cargo-fmt not available; formatting not checked!"
echo
echo "If you are using rustup, rustfmt can be installed via"
echo "\"rustup component add --toolchain=stable rustfmt-preview\", or see"
echo "https://github.com/rust-lang-nursery/rustfmt for more information."
fi
banner "Rust release build"
cargo build --release
banner "Rust debug build"
cargo build
banner "Rust unit tests"
RUST_BACKTRACE=1 cargo test \
--package wasmtime \
--package wasmtime-wasi \
--package wasmtime-wasi-c \
--package wasmtime-wast \
--package wasmtime-debug \
--package wasmtime-environ \
--package wasmtime-runtime \
--package wasmtime-jit \
--package wasmtime-api \
--package wasmtime-interface-types \
--package wasmtime-obj \
RUST_BACKTRACE=1 cargo +nightly test \
--package wasmtime-rust
banner "Rust documentation: $topdir/target/doc/wasmtime/index.html"
cargo doc
banner "cargo fuzz check"
if rustup toolchain list | grep -q nightly; then
if cargo install --list | grep -q cargo-fuzz; then
echo "cargo-fuzz found"
else
echo "installing cargo-fuzz"
cargo +nightly install cargo-fuzz
fi
fuzz_module="1340712d77d3db3c79b4b0c1494df18615485480"
ASAN_OPTIONS=detect_leaks=0 \
cargo +nightly fuzz run compile \
"$topdir/fuzz/corpus/compile/$fuzz_module"
cargo +nightly test --package lightbeam
else
echo "nightly toolchain not found, skipping fuzz target integration test"
fi
banner "OK"