From 822feaa5eb68ea172b17e29fda982f840ddf2f20 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 6 Jul 2023 08:55:46 +0000 Subject: [PATCH 1/4] Stop parsing ui_test annotations in `run-dep` mode --- src/tools/miri/Cargo.lock | 4 ++-- src/tools/miri/Cargo.toml | 2 +- src/tools/miri/tests/compiletest.rs | 21 ++++++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/tools/miri/Cargo.lock b/src/tools/miri/Cargo.lock index edb3ee48a4e..4232d7fda78 100644 --- a/src/tools/miri/Cargo.lock +++ b/src/tools/miri/Cargo.lock @@ -842,9 +842,9 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.11.6" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a2e70adc9d18b9b4dd80ea57aeec447103c6fbb354a07c080adad451c645e1" +checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c" dependencies = [ "bstr", "cargo-platform", diff --git a/src/tools/miri/Cargo.toml b/src/tools/miri/Cargo.toml index 50864334fc5..a625e1696e1 100644 --- a/src/tools/miri/Cargo.toml +++ b/src/tools/miri/Cargo.toml @@ -36,7 +36,7 @@ libloading = "0.7" [dev-dependencies] colored = "2" -ui_test = "0.11.6" +ui_test = "0.11.7" rustc_version = "0.4" # Features chosen to match those required by env_logger, to avoid rebuilds regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] } diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index 73671e716ef..a2262222f49 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -274,13 +274,20 @@ fn main() -> Result<()> { fn run_dep_mode(target: String, mut args: impl Iterator) -> Result<()> { let path = args.next().expect("./miri run-dep must be followed by a file name"); let mut config = test_config(&target, "", Mode::Yolo, /* with dependencies */ true); - config.program.args.remove(0); // remove the `--error-format=json` argument - config.program.args.push("--color".into()); - config.program.args.push("always".into()); - let mut cmd = ui_test::test_command(config, Path::new(&path))?; - // Separate the arguments to the `cargo miri` invocation from - // the arguments to the interpreted prog - cmd.arg("--"); + config.program.args.clear(); // We want to give the user full control over flags + config.build_dependencies_and_link_them()?; + + if let Ok(extra_flags) = env::var("MIRIFLAGS") { + for flag in extra_flags.split_whitespace() { + config.program.args.push(flag.into()); + } + } + let mut cmd = config.program.build(&config.out_dir); + + cmd.arg("--color").arg("always"); + cmd.arg(path); + cmd.args(args); + println!("Running {cmd:?}"); if cmd.spawn()?.wait()?.success() { Ok(()) } else { std::process::exit(1) } } From 813b56b5ab4a3f5ad84b377ed0ff09504907eaaf Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 7 Jul 2023 13:41:06 +0000 Subject: [PATCH 2/4] Silence all the boilerplate around `./miri run` and `./miri run-dep` --- src/tools/miri/miri | 1 + src/tools/miri/tests/compiletest.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/miri b/src/tools/miri/miri index 3ab7cc25dec..ace3d17ae2a 100755 --- a/src/tools/miri/miri +++ b/src/tools/miri/miri @@ -325,6 +325,7 @@ run|run-dep) MIRIFLAGS="$MIRIFLAGS --target $MIRI_TEST_TARGET" fi + CARGO="$CARGO --quiet" # First build and get a sysroot. $CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml find_sysroot diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index a2262222f49..120d5b9fc65 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -288,6 +288,5 @@ fn run_dep_mode(target: String, mut args: impl Iterator) -> Res cmd.arg(path); cmd.args(args); - println!("Running {cmd:?}"); if cmd.spawn()?.wait()?.success() { Ok(()) } else { std::process::exit(1) } } From 48fe0dfe48cc2689adbadec7c639a7b73309d2d5 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 7 Jul 2023 13:41:32 +0000 Subject: [PATCH 3/4] Remove a now-useless flag --- src/tools/miri/tests/compiletest.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index 120d5b9fc65..e4b8da1228f 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -284,7 +284,6 @@ fn run_dep_mode(target: String, mut args: impl Iterator) -> Res } let mut cmd = config.program.build(&config.out_dir); - cmd.arg("--color").arg("always"); cmd.arg(path); cmd.args(args); From c6f5b5f557e9df51822c27c82543ca371224ac6d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 7 Jul 2023 13:42:38 +0000 Subject: [PATCH 4/4] MIRIFLAGS are already passed in the `./miri` wrapper --- src/tools/miri/tests/compiletest.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index e4b8da1228f..2f3f51101b6 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -277,11 +277,6 @@ fn run_dep_mode(target: String, mut args: impl Iterator) -> Res config.program.args.clear(); // We want to give the user full control over flags config.build_dependencies_and_link_them()?; - if let Ok(extra_flags) = env::var("MIRIFLAGS") { - for flag in extra_flags.split_whitespace() { - config.program.args.push(flag.into()); - } - } let mut cmd = config.program.build(&config.out_dir); cmd.arg(path);