test_rust.sh 1.0 KB

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. # Test all Rust crates
  3. set -e
  4. export LSAN_OPTIONS=suppressions=${abs_top_srcdir:-../../..}/src/test/rust_supp.txt
  5. # When testing Cargo we pass a number of very specific linker flags down
  6. # through Cargo. We do not, however, want these flags to affect things like
  7. # build scripts, only the tests that we're compiling. To ensure this happens
  8. # we unconditionally pass `--target` into Cargo, ensuring that `RUSTFLAGS` in
  9. # the environment won't make their way into build scripts.
  10. rustc_host=$(rustc -vV | grep host | sed 's/host: //')
  11. for cargo_toml_dir in "${abs_top_srcdir:-../../..}"/src/rust/*; do
  12. if [ -e "${cargo_toml_dir}/Cargo.toml" ]; then
  13. cd "${abs_top_builddir:-../../..}/src/rust" && \
  14. CARGO_TARGET_DIR="${abs_top_builddir:-../../..}/src/rust/target" \
  15. "${CARGO:-cargo}" test ${CARGO_ONLINE-"--frozen"} \
  16. --features "test_linking_hack" \
  17. --target $rustc_host \
  18. ${EXTRA_CARGO_OPTIONS} \
  19. --manifest-path "${cargo_toml_dir}/Cargo.toml" || exitcode=1
  20. fi
  21. done
  22. exit $exitcode