fix ./miri run with MIRI_TEST_TARGET

This commit is contained in:
Ralf Jung 2022-07-03 08:35:44 -04:00
parent c6f44c1639
commit e71f8b0630
2 changed files with 17 additions and 13 deletions

View File

@ -418,9 +418,9 @@ Moreover, Miri recognizes some environment variables:
sysroot to use. Only set this if you do not want to use the automatically sysroot to use. Only set this if you do not want to use the automatically
created sysroot. (The `miri` driver sysroot is controlled via the `--sysroot` created sysroot. (The `miri` driver sysroot is controlled via the `--sysroot`
flag instead.) flag instead.)
* `MIRI_TEST_TARGET` (recognized by the test suite) indicates which target * `MIRI_TEST_TARGET` (recognized by the test suite and the `./miri` script) indicates which target
architecture to test against. `miri` and `cargo miri` accept the `--target` architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same
flag for the same purpose. purpose.
* `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's * `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's
sysroot is built without libstd. This allows testing and running no_std programs. sysroot is built without libstd. This allows testing and running no_std programs.
* `MIRI_BLESS` (recognized by the test suite) overwrite all `stderr` and `stdout` files * `MIRI_BLESS` (recognized by the test suite) overwrite all `stderr` and `stdout` files

24
miri
View File

@ -167,17 +167,21 @@ test|test-debug|bless|bless-debug)
$CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml "$@" $CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml "$@"
;; ;;
run|run-debug) run|run-debug)
# Scan for "--target" to set the "MIRI_TEST_TARGET" env var so # Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
# that we set the MIRI_SYSROOT up the right way. # that we set the MIRI_SYSROOT up the right way.
if [ -z "$MIRI_TEST_TARGET" ]; then FOUND_TARGET_OPT=0
for ARG in "$@"; do for ARG in "$@"; do
if [ "$LAST_ARG" = "--target" ]; then if [ "$LAST_ARG" = "--target" ]; then
# Found it! # Found it!
export MIRI_TEST_TARGET="$ARG" export MIRI_TEST_TARGET="$ARG"
break FOUND_TARGET_OPT=1
fi break
LAST_ARG="$ARG" fi
done LAST_ARG="$ARG"
done
if [ "$FOUND_TARGET_OPT" = "0" ] && [ -n "$MIRI_TEST_TARGET" ]; then
# Make sure Miri actually uses this target.
MIRIFLAGS="$MIRIFLAGS --target $MIRI_TEST_TARGET"
fi fi
# First build and get a sysroot. # First build and get a sysroot.
$CARGO build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml $CARGO build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml