Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 692b769

Browse files
committed
Auto merge of rust-lang#3545 - RalfJung:miri-run, r=RalfJung
./miri run: support -v flag to print what it is doing
2 parents dcf956c + eaf30ce commit 692b769

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

src/tools/miri/miri-script/src/commands.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Command {
162162
Command::Build { flags } => Self::build(flags),
163163
Command::Check { flags } => Self::check(flags),
164164
Command::Test { bless, flags } => Self::test(bless, flags),
165-
Command::Run { dep, flags } => Self::run(dep, flags),
165+
Command::Run { dep, verbose, flags } => Self::run(dep, verbose, flags),
166166
Command::Fmt { flags } => Self::fmt(flags),
167167
Command::Clippy { flags } => Self::clippy(flags),
168168
Command::Cargo { flags } => Self::cargo(flags),
@@ -495,7 +495,7 @@ impl Command {
495495
Ok(())
496496
}
497497

498-
fn run(dep: bool, mut flags: Vec<OsString>) -> Result<()> {
498+
fn run(dep: bool, verbose: bool, mut flags: Vec<OsString>) -> Result<()> {
499499
let mut e = MiriEnv::new()?;
500500
// Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
501501
// that we set the MIRI_SYSROOT up the right way. We must make sure that
@@ -522,7 +522,7 @@ impl Command {
522522
}
523523

524524
// Prepare a sysroot, and add it to the flags.
525-
let miri_sysroot = e.build_miri_sysroot(/* quiet */ true)?;
525+
let miri_sysroot = e.build_miri_sysroot(/* quiet */ !verbose)?;
526526
flags.push("--sysroot".into());
527527
flags.push(miri_sysroot.into());
528528

@@ -532,17 +532,20 @@ impl Command {
532532
let miri_flags = flagsplit(&miri_flags);
533533
let toolchain = &e.toolchain;
534534
let extra_flags = &e.cargo_extra_flags;
535-
if dep {
535+
let quiet_flag = if verbose { None } else { Some("--quiet") };
536+
let mut cmd = if dep {
536537
cmd!(
537538
e.sh,
538-
"cargo +{toolchain} --quiet test {extra_flags...} --manifest-path {miri_manifest} --test ui -- --miri-run-dep-mode {miri_flags...} {flags...}"
539-
).quiet().run()?;
539+
"cargo +{toolchain} {quiet_flag...} test {extra_flags...} --manifest-path {miri_manifest} --test ui -- --miri-run-dep-mode {miri_flags...} {flags...}"
540+
)
540541
} else {
541542
cmd!(
542543
e.sh,
543-
"cargo +{toolchain} --quiet run {extra_flags...} --manifest-path {miri_manifest} -- {miri_flags...} {flags...}"
544-
).quiet().run()?;
545-
}
544+
"cargo +{toolchain} {quiet_flag...} run {extra_flags...} --manifest-path {miri_manifest} -- {miri_flags...} {flags...}"
545+
)
546+
};
547+
cmd.set_quiet(!verbose);
548+
cmd.run()?;
546549
Ok(())
547550
}
548551

src/tools/miri/miri-script/src/main.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub enum Command {
3838
/// (Also respects MIRIFLAGS environment variable.)
3939
Run {
4040
dep: bool,
41+
verbose: bool,
4142
/// Flags that are passed through to `miri`.
4243
flags: Vec<OsString>,
4344
},
@@ -90,7 +91,7 @@ Just check miri. <flags> are passed to `cargo check`.
9091
Build miri, set up a sysroot and then run the test suite. <flags> are passed
9192
to the final `cargo test` invocation.
9293
93-
./miri run [--dep] <flags>:
94+
./miri run [--dep] [-v|--verbose] <flags>:
9495
Build miri, set up a sysroot and then run the driver with the given <flags>.
9596
(Also respects MIRIFLAGS environment variable.)
9697
@@ -132,10 +133,10 @@ Pull and merge Miri changes from the rustc repo. Defaults to fetching the latest
132133
rustc commit. The fetched commit is stored in the `rust-version` file, so the
133134
next `./miri toolchain` will install the rustc that just got pulled.
134135
135-
./miri rustc-push <github user> <branch>:
136+
./miri rustc-push <github user> [<branch>]:
136137
Push Miri changes back to the rustc repo. This will pull a copy of the rustc
137138
history into the Miri repo, unless you set the RUSTC_GIT env var to an existing
138-
clone of the rustc repo.
139+
clone of the rustc repo. The branch defaults to `miri-sync`.
139140
140141
ENVIRONMENT VARIABLES
141142
@@ -162,12 +163,18 @@ fn main() -> Result<()> {
162163
Command::Test { bless, flags: args.collect() }
163164
}
164165
Some("run") => {
165-
let dep = args.peek().is_some_and(|a| a.to_str() == Some("--dep"));
166-
if dep {
167-
// Consume the flag.
166+
let mut dep = false;
167+
let mut verbose = false;
168+
while let Some(arg) = args.peek().and_then(|a| a.to_str()) {
169+
match arg {
170+
"--dep" => dep = true,
171+
"-v" | "--verbose" => verbose = true,
172+
_ => break, // not for us
173+
}
174+
// Consume the flag, look at the next one.
168175
args.next().unwrap();
169176
}
170-
Command::Run { dep, flags: args.collect() }
177+
Command::Run { dep, verbose, flags: args.collect() }
171178
}
172179
Some("fmt") => Command::Fmt { flags: args.collect() },
173180
Some("clippy") => Command::Clippy { flags: args.collect() },
@@ -187,17 +194,12 @@ fn main() -> Result<()> {
187194
let github_user = args
188195
.next()
189196
.ok_or_else(|| {
190-
anyhow!("Missing first argument for `./miri rustc-push GITHUB_USER BRANCH`")
191-
})?
192-
.to_string_lossy()
193-
.into_owned();
194-
let branch = args
195-
.next()
196-
.ok_or_else(|| {
197-
anyhow!("Missing second argument for `./miri rustc-push GITHUB_USER BRANCH`")
197+
anyhow!("Missing first argument for `./miri rustc-push GITHUB_USER [BRANCH]`")
198198
})?
199199
.to_string_lossy()
200200
.into_owned();
201+
let branch =
202+
args.next().unwrap_or_else(|| "miri-sync".into()).to_string_lossy().into_owned();
201203
if args.next().is_some() {
202204
bail!("Too many arguments for `./miri rustc-push GITHUB_USER BRANCH`");
203205
}

0 commit comments

Comments
 (0)