Auto merge of #3545 - RalfJung:miri-run, r=RalfJung
./miri run: support -v flag to print what it is doing
This commit is contained in:
commit
692b769d61
@ -162,7 +162,7 @@ pub fn exec(self) -> Result<()> {
|
||||
Command::Build { flags } => Self::build(flags),
|
||||
Command::Check { flags } => Self::check(flags),
|
||||
Command::Test { bless, flags } => Self::test(bless, flags),
|
||||
Command::Run { dep, flags } => Self::run(dep, flags),
|
||||
Command::Run { dep, verbose, flags } => Self::run(dep, verbose, flags),
|
||||
Command::Fmt { flags } => Self::fmt(flags),
|
||||
Command::Clippy { flags } => Self::clippy(flags),
|
||||
Command::Cargo { flags } => Self::cargo(flags),
|
||||
@ -495,7 +495,7 @@ fn test(bless: bool, flags: Vec<OsString>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run(dep: bool, mut flags: Vec<OsString>) -> Result<()> {
|
||||
fn run(dep: bool, verbose: bool, mut flags: Vec<OsString>) -> Result<()> {
|
||||
let mut e = MiriEnv::new()?;
|
||||
// Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
|
||||
// that we set the MIRI_SYSROOT up the right way. We must make sure that
|
||||
@ -522,7 +522,7 @@ fn run(dep: bool, mut flags: Vec<OsString>) -> Result<()> {
|
||||
}
|
||||
|
||||
// Prepare a sysroot, and add it to the flags.
|
||||
let miri_sysroot = e.build_miri_sysroot(/* quiet */ true)?;
|
||||
let miri_sysroot = e.build_miri_sysroot(/* quiet */ !verbose)?;
|
||||
flags.push("--sysroot".into());
|
||||
flags.push(miri_sysroot.into());
|
||||
|
||||
@ -532,17 +532,20 @@ fn run(dep: bool, mut flags: Vec<OsString>) -> Result<()> {
|
||||
let miri_flags = flagsplit(&miri_flags);
|
||||
let toolchain = &e.toolchain;
|
||||
let extra_flags = &e.cargo_extra_flags;
|
||||
if dep {
|
||||
let quiet_flag = if verbose { None } else { Some("--quiet") };
|
||||
let mut cmd = if dep {
|
||||
cmd!(
|
||||
e.sh,
|
||||
"cargo +{toolchain} --quiet test {extra_flags...} --manifest-path {miri_manifest} --test ui -- --miri-run-dep-mode {miri_flags...} {flags...}"
|
||||
).quiet().run()?;
|
||||
"cargo +{toolchain} {quiet_flag...} test {extra_flags...} --manifest-path {miri_manifest} --test ui -- --miri-run-dep-mode {miri_flags...} {flags...}"
|
||||
)
|
||||
} else {
|
||||
cmd!(
|
||||
e.sh,
|
||||
"cargo +{toolchain} --quiet run {extra_flags...} --manifest-path {miri_manifest} -- {miri_flags...} {flags...}"
|
||||
).quiet().run()?;
|
||||
}
|
||||
"cargo +{toolchain} {quiet_flag...} run {extra_flags...} --manifest-path {miri_manifest} -- {miri_flags...} {flags...}"
|
||||
)
|
||||
};
|
||||
cmd.set_quiet(!verbose);
|
||||
cmd.run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ pub enum Command {
|
||||
/// (Also respects MIRIFLAGS environment variable.)
|
||||
Run {
|
||||
dep: bool,
|
||||
verbose: bool,
|
||||
/// Flags that are passed through to `miri`.
|
||||
flags: Vec<OsString>,
|
||||
},
|
||||
@ -90,7 +91,7 @@ pub enum Command {
|
||||
Build miri, set up a sysroot and then run the test suite. <flags> are passed
|
||||
to the final `cargo test` invocation.
|
||||
|
||||
./miri run [--dep] <flags>:
|
||||
./miri run [--dep] [-v|--verbose] <flags>:
|
||||
Build miri, set up a sysroot and then run the driver with the given <flags>.
|
||||
(Also respects MIRIFLAGS environment variable.)
|
||||
|
||||
@ -132,10 +133,10 @@ pub enum Command {
|
||||
rustc commit. The fetched commit is stored in the `rust-version` file, so the
|
||||
next `./miri toolchain` will install the rustc that just got pulled.
|
||||
|
||||
./miri rustc-push <github user> <branch>:
|
||||
./miri rustc-push <github user> [<branch>]:
|
||||
Push Miri changes back to the rustc repo. This will pull a copy of the rustc
|
||||
history into the Miri repo, unless you set the RUSTC_GIT env var to an existing
|
||||
clone of the rustc repo.
|
||||
clone of the rustc repo. The branch defaults to `miri-sync`.
|
||||
|
||||
ENVIRONMENT VARIABLES
|
||||
|
||||
@ -162,12 +163,18 @@ fn main() -> Result<()> {
|
||||
Command::Test { bless, flags: args.collect() }
|
||||
}
|
||||
Some("run") => {
|
||||
let dep = args.peek().is_some_and(|a| a.to_str() == Some("--dep"));
|
||||
if dep {
|
||||
// Consume the flag.
|
||||
let mut dep = false;
|
||||
let mut verbose = false;
|
||||
while let Some(arg) = args.peek().and_then(|a| a.to_str()) {
|
||||
match arg {
|
||||
"--dep" => dep = true,
|
||||
"-v" | "--verbose" => verbose = true,
|
||||
_ => break, // not for us
|
||||
}
|
||||
// Consume the flag, look at the next one.
|
||||
args.next().unwrap();
|
||||
}
|
||||
Command::Run { dep, flags: args.collect() }
|
||||
Command::Run { dep, verbose, flags: args.collect() }
|
||||
}
|
||||
Some("fmt") => Command::Fmt { flags: args.collect() },
|
||||
Some("clippy") => Command::Clippy { flags: args.collect() },
|
||||
@ -187,17 +194,12 @@ fn main() -> Result<()> {
|
||||
let github_user = args
|
||||
.next()
|
||||
.ok_or_else(|| {
|
||||
anyhow!("Missing first argument for `./miri rustc-push GITHUB_USER BRANCH`")
|
||||
})?
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
let branch = args
|
||||
.next()
|
||||
.ok_or_else(|| {
|
||||
anyhow!("Missing second argument for `./miri rustc-push GITHUB_USER BRANCH`")
|
||||
anyhow!("Missing first argument for `./miri rustc-push GITHUB_USER [BRANCH]`")
|
||||
})?
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
let branch =
|
||||
args.next().unwrap_or_else(|| "miri-sync".into()).to_string_lossy().into_owned();
|
||||
if args.next().is_some() {
|
||||
bail!("Too many arguments for `./miri rustc-push GITHUB_USER BRANCH`");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user