test_rust.sh 1.1 KB

12345678910111213141516171819202122232425262728
  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. # shellcheck disable=SC2086
  14. cd "${abs_top_builddir:-../../..}/src/rust" && \
  15. CARGO_TARGET_DIR="${abs_top_builddir:-../../..}/src/rust/target" \
  16. "${CARGO:-cargo}" test "${CARGO_ONLINE-'--frozen'}" \
  17. --features "test_linking_hack" \
  18. --target "$rustc_host" \
  19. ${EXTRA_CARGO_OPTIONS} \
  20. --manifest-path "${cargo_toml_dir}/Cargo.toml" || exitcode=1
  21. fi
  22. done
  23. exit $exitcode