@@ -7,10 +7,8 @@ set -euo pipefail
77# # Usage:
88# # ./run-test.sh CRATE_NAME CARGO_TEST_ARGS
99# # Environment variables:
10- # # RUST_SRC: The path to the Rust source directory (containing `src`).
11- # # Defaults to `$(rustc --print sysroot)/lib/rustlib/src/rust` or
12- # # `$(rustc --print sysroot)/../../..`, which ever exists. (The former
13- # # works for distributed toolchains, the latter for locally built ones.)
10+ # # MIRI_LIB_SRC: The path to the Rust library directory (`library`).
11+ # # Defaults to `$(rustc --print sysroot)/lib/rustlib/src/rust/library`.
1412
1513CRATE=${1:- }
1614if [[ -z " $CRATE " ]]; then
@@ -19,21 +17,22 @@ if [[ -z "$CRATE" ]]; then
1917fi
2018shift
2119
22- DEFAULT_RUST_SRC= $( rustc --print sysroot ) /lib/rustlib/src/rust
23- RUST_SRC =${RUST_SRC :- $DEFAULT_RUST_SRC }
24- if ! test -f " $RUST_SRC /Cargo.lock " ; then
25- echo " Rust source dir ($RUST_SRC ) does not contain a Cargo.lock file ."
26- echo " Set RUST_SRC to the Rust source directory, or install the rust-src component."
20+ # compute the library directory (and export for Miri)
21+ MIRI_LIB_SRC =${MIRI_LIB_SRC :- $(rustc --print sysroot) / lib / rustlib / src / rust / library }
22+ if ! test -d " $MIRI_LIB_SRC /core " ; then
23+ echo " Rust source dir ($MIRI_LIB_SRC ) does not contain a 'core' subdirectory ."
24+ echo " Set MIRI_LIB_SRC to the Rust source directory, or install the rust-src component."
2725 exit 1
2826fi
2927# macOS does not have a useful readlink/realpath so we have to use Python instead...
30- RUST_SRC=$( python -c ' import os, sys; print(os.path.realpath(sys.argv[1]))' " $RUST_SRC " )
28+ MIRI_LIB_SRC=$( python -c ' import os, sys; print(os.path.realpath(sys.argv[1]))' " $MIRI_LIB_SRC " )
29+ export MIRI_LIB_SRC
3130
3231# update symlink
3332rm -f lib$CRATE
34- ln -s " $RUST_SRC " /library /$CRATE lib$CRATE
33+ ln -s " $MIRI_LIB_SRC " /$CRATE lib$CRATE
3534
3635# run test
3736cd ${CRATE} _miri_test
38- XARGO_RUST_SRC= " $RUST_SRC /library " cargo miri setup
39- MIRI_SYSROOT= ~ /.cache/miri/HOST cargo miri test " $@ "
37+ cargo miri setup
38+ cargo miri test " $@ "
0 commit comments