Running Miri quietly

Hi! I'm building an interpreter following Crafting Interpreters, and the book provides a test tool that checks whether the given interpreter returns the desired result.
Currently, I'm running the test tool with a binary built with cargo build, but additionally I'd like to test if my implementation contains any UB using Miri since it has a lot of unsafe code😅
However, running the test tool with Miri fails because Miri emits build messages, which confuses the tool.
Is there any way to suppress such messages in Miri like the --quiet option?

For example, cargo has --quiet which supresses the build log:

~/rlox$ cargo +nightly --quiet run -- test/empty_file.lox

But running cargo miri with --quiet does not suppress the log:

~/rlox$ cargo +nightly --quiet miri run -- test/empty_file.lox 
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
    <build log continues...>

Note that cargo --quiet miri run tells cargo to be --quiet, but not miri. If you want miri to be --quiet, you would want to use cargo miri --quiet run.

The reason that it works like this is that cargo [tool] actually delegates to the cargo-tool executable. (This is why you can cargo install cargo-tool to add extra tools as subcommands.) Miri functions the same way, but also involves basically calling back into cargo to perform the actual build. If cargo-miri doesn't see the --quiet, it can't possibly know to tell the cargo it spawns to be --quiet.

(cargo-miri is basically just a wrapper around installing miri prerequisites and calling cargo with some extra flags and $env:RUSTC_WRAPPER set to miri, though that's overly simplified.)

Though with that said I don't actually know if cargo-miri supports a --quiet flag anywhere, I just know that you're telling the wrong part of the pipeline to be --quiet.

1 Like

Thank you for the info!
Running cargo +nightly miri run --quiet did the trick.

For those who are wondering how to run test suites provided by the book:

$ MIRIFLAGS='-Zmiri-disable-isolation' dart tool/bin/test.dart TEST_NAME_HERE -i cargo -a +nightly -a miri -a run -a --quiet -a --

Note that the tests will be very slow.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.