Skip to content

Commit b0bdbcc

Browse files
committed
Auto merge of #3531 - narpfel:quiet-sysroot, r=RalfJung
Don’t print `Preparing a sysroot` when `-q`/`--quiet` is passed Resolves #3530. This also fixes a typo in `cargo miri --help` that I found while trying to run the `--print-sysroot` example.
2 parents 1c7e827 + a2b3211 commit b0bdbcc

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/tools/miri/cargo-miri/src/phases.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Examples:
2828
cargo miri run
2929
cargo miri test -- test-suite-filter
3030
31-
cargo miri setup --print sysroot
31+
cargo miri setup --print-sysroot
3232
This will print the path to the generated sysroot (and nothing else) on stdout.
3333
stderr will still contain progress information about how the build is doing.
3434
@@ -87,6 +87,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
8787
),
8888
};
8989
let verbose = num_arg_flag("-v");
90+
let quiet = has_arg_flag("-q") || has_arg_flag("--quiet");
9091

9192
// Determine the involved architectures.
9293
let rustc_version = VersionMeta::for_command(miri_for_host()).unwrap_or_else(|err| {
@@ -110,7 +111,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
110111
}
111112

112113
// We always setup.
113-
let miri_sysroot = setup(&subcommand, target, &rustc_version, verbose);
114+
let miri_sysroot = setup(&subcommand, target, &rustc_version, verbose, quiet);
114115

115116
// Invoke actual cargo for the job, but with different flags.
116117
// We re-use `cargo test` and `cargo run`, which makes target and binary handling very easy but

src/tools/miri/cargo-miri/src/setup.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn setup(
1919
target: &str,
2020
rustc_version: &VersionMeta,
2121
verbose: usize,
22+
quiet: bool,
2223
) -> PathBuf {
2324
let only_setup = matches!(subcommand, MiriCommand::Setup);
2425
let ask_user = !only_setup;
@@ -119,6 +120,9 @@ pub fn setup(
119120
for _ in 0..verbose {
120121
command.arg("-v");
121122
}
123+
if quiet {
124+
command.arg("--quiet");
125+
}
122126
} else {
123127
// Suppress output.
124128
command.stdout(process::Stdio::null());
@@ -134,7 +138,7 @@ pub fn setup(
134138
let rustflags = &["-Cdebug-assertions=off", "-Coverflow-checks=on"];
135139

136140
// Do the build.
137-
if print_sysroot {
141+
if print_sysroot || quiet {
138142
// Be silent.
139143
} else {
140144
let mut msg = String::new();
@@ -169,7 +173,7 @@ pub fn setup(
169173
)
170174
}
171175
});
172-
if print_sysroot {
176+
if print_sysroot || quiet {
173177
// Be silent.
174178
} else if only_setup {
175179
eprintln!("A sysroot for Miri is now available in `{}`.", sysroot_dir.display());

src/tools/miri/test-cargo-miri/run-test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ def normalize_stdout(str):
3434
str = re.sub("finished in \\d+\\.\\d\\ds", "finished in $TIME", str) # the time keeps changing, obviously
3535
return str
3636

37-
def normalize_stderr(str):
38-
str = re.sub("Preparing a sysroot for Miri \\(target: [a-z0-9_-]+\\)\\.\\.\\. done\n", "", str) # remove leading cargo-miri setup output
39-
return str
40-
4137
def check_output(actual, path, name):
4238
if os.environ.get("RUSTC_BLESS", "0") != "0":
4339
# Write the output only if bless is set
@@ -69,7 +65,7 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env=None):
6965
)
7066
(stdout, stderr) = p.communicate(input=stdin)
7167
stdout = normalize_stdout(stdout.decode("UTF-8"))
72-
stderr = normalize_stderr(stderr.decode("UTF-8"))
68+
stderr = stderr.decode("UTF-8")
7369

7470
stdout_matches = check_output(stdout, stdout_ref, "stdout")
7571
stderr_matches = check_output(stderr, stderr_ref, "stderr")

0 commit comments

Comments
 (0)