Skip to content

Commit 4ab3218

Browse files
committed
adjust for MIRI_LIB_SRC env var
1 parent 1443055 commit 4ab3218

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

run-test.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1513
CRATE=${1:-}
1614
if [[ -z "$CRATE" ]]; then
@@ -19,21 +17,22 @@ if [[ -z "$CRATE" ]]; then
1917
fi
2018
shift
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
2826
fi
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
3332
rm -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
3736
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 "$@"

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2021-12-24
1+
nightly-2021-12-25

0 commit comments

Comments
 (0)