@@ -50,6 +50,7 @@ endgroup
5050# - MIR_OPT: if non-empty, re-run test `pass` tests with mir-opt-level=4
5151# - MANY_SEEDS: if set to N, run the "many-seeds" tests N times
5252# - TEST_BENCH: if non-empty, check that the benchmarks all build
53+ # - CARGO_MIRI_ENV: if non-empty, set some env vars and config to potentially confuse cargo-miri
5354function run_tests {
5455 if [ -n " ${MIRI_TEST_TARGET-} " ]; then
5556 begingroup " Testing foreign architecture $MIRI_TEST_TARGET "
@@ -94,14 +95,16 @@ function run_tests {
9495 PYTHON=python
9596 fi
9697 # Some environment setup that attempts to confuse the heck out of cargo-miri.
97- if [ " $HOST_TARGET " = x86_64-unknown-linux-gnu ]; then
98- # These act up on Windows (`which miri` produces a filename that does not exist?!?),
99- # so let's do this only on Linux. Also makes sure things work without these set.
100- export RUSTC=$( which rustc) # Produces a warning unless we also set MIRI
98+ if [ -n " ${CARGO_MIRI_ENV-} " ]; then
99+ # These act up on Windows (`which miri` produces a filename that does not exist?!?).
100+ # RUSTC is the main thing to set (it changes the first argument our wrapper will see).
101+ # Unless MIRI is also set, that produces a warning.
102+ export RUSTC=$( which rustc)
101103 export MIRI=$( rustc +miri --print sysroot) /bin/miri
104+ # We entirely ignore other wrappers.
105+ mkdir -p .cargo
106+ echo ' build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
102107 fi
103- mkdir -p .cargo
104- echo ' build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
105108 # Run the actual test
106109 ${PYTHON} test-cargo-miri/run-test.py
107110 # Clean up
@@ -133,7 +136,7 @@ function run_tests_minimal {
133136case $HOST_TARGET in
134137 x86_64-unknown-linux-gnu)
135138 # Host
136- GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 run_tests
139+ GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
137140 # Extra tier 1
138141 MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
139142 MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests
@@ -154,9 +157,9 @@ case $HOST_TARGET in
154157 ;;
155158 x86_64-apple-darwin)
156159 # Host
157- GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 run_tests
160+ GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
158161 # Extra tier 1
159- MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
162+ MIRI_TEST_TARGET=x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
160163 # Extra tier 2
161164 MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture
162165 ;;
0 commit comments