feat: Restructure mutest-driver and cargo-mutest CLIs#7
Merged
Conversation
zalanlevai
force-pushed
the
cli-restructure
branch
2 times, most recently
from
June 30, 2026 23:00
e82dde0 to
90f13ce
Compare
zalanlevai
force-pushed
the
cli-restructure
branch
from
July 1, 2026 03:06
a53ad39 to
aa1be5b
Compare
This change replaces the `build` and `print` subcommands with a a more flexible `--emit=[info|metadata|test-bin...]` option, which controls both which outputs are generated, and when the compilation can be stopped, i.e., once all emission goals are met. This change also removes the `--no-write-json flag` from mutest-driver, which is now represented by a lack of `--emit=metadata`.
zalanlevai
force-pushed
the
cli-restructure
branch
from
July 1, 2026 03:07
aa1be5b to
3d73b88
Compare
zalanlevai
force-pushed
the
cli-restructure
branch
5 times, most recently
from
July 6, 2026 15:17
6d961e8 to
beced43
Compare
This change moves the various Cargo and mutest-driver global arguments in cargo-mutest under the `run` subcommand. This allows us to introduce other subcommands, such as `inspect` to run the inspector on a previous run, by removing Cargo and mutest-driver-specific options from the global argument namespace. It also removes the requirement for Cargo and compilation options to be provided before the `run` subcommand and evaluation options after it, simplifying usage. This change required changing the `--print` evaluation option to `--eval-print` to avoid collision with the `--print` generation option.
When originally implementing mutest-driver based on clippy-driver, we carried over the behavior that turned the `SYSROOT` environment variable into a `--sysroot` argument. This feature is only needed for using clippy during Rust bootstrapping, and is not relevant to us. Furthermore, the sysroot fallback behavior actually caused issues in certain cases, because it included the sysroot according to rustc from PATH. This change removes this faulty, unused behavior entirely. The sysroot can still be overridden using the standard `--sysroot` argument, just like with rustc.
This change removes the difference in argument handling behavior when the first argument is a path to rustc, as is the case when being invoked by Cargo through RUSTC_WRAPPER / RUSTC_WORKSPACE_WRAPPER. This ensures that mutest-driver provides a rustc-compatible interface regardless of whether it is invoked as a rustc-wrapper or not.
Showing mutest-driver information rather than generic rustc information for these flags does not break rustc compatibility, but greatly simplifies basic usage and the discovery of usage in practice.
Previously, we used to fall back to a rustc invocation if the crate was not part of the Cargo primary package (the set of packages selected by a Cargo invocation), even for non-Cargo invocations. This change ensures that we only expect CARGO_PRIMARY_PACKAGE if we are invoked by Cargo in the first place, otherwise defaulting to invoking mutest-rs behavior.
This change adds fallback behavior for when `--crate-type` is not explicitly provided as a rustc argument, falling back to the `#![crate_type = "..."]` crate root attributes. These attributes are parsed as part of the pseudo-pass for getting the compiler-parsed compiler config. This change also disables mutations for proc-macro crates, falling back to a rustc invocation instead.
zalanlevai
force-pushed
the
cli-restructure
branch
from
July 7, 2026 16:34
84a0144 to
5d05ff6
Compare
zalanlevai
marked this pull request as ready for review
July 7, 2026 17:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR restructures the mutest-driver and cargo-mutest CLIs with the following goals in mind:
build,print) from mutest-driver to create a simpler interface more similar to rustc-driver. Replace the subcommands with a more flexible--emit=[info|metadata|test-bin...]option, which controls both which outputs are generated, and when the compilation can be stopped, i.e., once all emission goals are met. This change also removes the--no-write-jsonflag from mutest-driver, which is now represented by a lack of--emit=metadata.run,build,print) under a singlerunsubcommand. Replace theprintsubcommand with the--no-buildflag (corresponds to--emit=infoin mutest-driver), and thebuildsubcommand with the--no-evalflag (corresponds to--emit=info,test-binin mutest-driver). This simplifies argument ordering: because there are now no global arguments, all arguments follow the subcommand, e.g.,cargo mutest run -p package --print=mutations --isolate=all.--printoption to--eval-printto avoid collision with the compilation--printoption.jsonoptions with the newmetadatanaming in--emit:--no-write-jsonto--no-emit-metadatain cargo-mutest, which now controls JSON metadata emission through the exclusion of the--emit=metadataoption. Otherjsonoptions have also been renamed to usemetadatainstead, such as--json-out-root-dirbecoming--metadata-out-root-dir.CARGO_VERBOSITYenvironment variable.These changes prepare cargo-mutest to be more than just a Cargo-compatible wrapper around mutest-driver, and for cargo-mutest to have more subcommands in the future. They also improve the standalone usage of mutest-driver from build systems other than Cargo.