@@ -7,10 +7,8 @@ set -euo pipefail
7
7
# # Usage:
8
8
# # ./run-test.sh CRATE_NAME CARGO_TEST_ARGS
9
9
# # 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`.
14
12
15
13
CRATE=${1:- }
16
14
if [[ -z " $CRATE " ]]; then
@@ -19,21 +17,22 @@ if [[ -z "$CRATE" ]]; then
19
17
fi
20
18
shift
21
19
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."
27
25
exit 1
28
26
fi
29
27
# 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
31
30
32
31
# update symlink
33
32
rm -f lib$CRATE
34
- ln -s " $RUST_SRC " /library /$CRATE lib$CRATE
33
+ ln -s " $MIRI_LIB_SRC " /$CRATE lib$CRATE
35
34
36
35
# run test
37
36
cd ${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