Skip to content

Commit

Permalink
Auto merge of #9438 - ehuss:report-subcommand, r=alexcrichton
Browse files Browse the repository at this point in the history
Add `report` subcommand.

This renames the `cargo describe-future-incompatibilities` subcommand to `cargo report future-incompatibilities`. The intent here is to have a general `report` subcommand that can be used for other reports in the future. This helps avoid the proliferation of top-level subcommands, and to help keep the CLI a little more organized.
  • Loading branch information
bors committed May 3, 2021
2 parents db741ac + ff49b82 commit 1228f49
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/bin/cargo/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub fn builtin() -> Vec<App> {
check::cli(),
clean::cli(),
config::cli(),
describe_future_incompatibilities::cli(),
doc::cli(),
fetch::cli(),
fix::cli(),
Expand All @@ -25,6 +24,7 @@ pub fn builtin() -> Vec<App> {
pkgid::cli(),
publish::cli(),
read_manifest::cli(),
report::cli(),
run::cli(),
rustc::cli(),
rustdoc::cli(),
Expand All @@ -47,7 +47,6 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> Cli
"check" => check::exec,
"clean" => clean::exec,
"config" => config::exec,
"describe-future-incompatibilities" => describe_future_incompatibilities::exec,
"doc" => doc::exec,
"fetch" => fetch::exec,
"fix" => fix::exec,
Expand All @@ -65,6 +64,7 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> Cli
"pkgid" => pkgid::exec,
"publish" => publish::exec,
"read-manifest" => read_manifest::exec,
"report" => report::exec,
"run" => run::exec,
"rustc" => rustc::exec,
"rustdoc" => rustdoc::exec,
Expand All @@ -87,7 +87,6 @@ pub mod build;
pub mod check;
pub mod clean;
pub mod config;
pub mod describe_future_incompatibilities;
pub mod doc;
pub mod fetch;
pub mod fix;
Expand All @@ -106,6 +105,7 @@ pub mod package;
pub mod pkgid;
pub mod publish;
pub mod read_manifest;
pub mod report;
pub mod run;
pub mod rustc;
pub mod rustdoc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,35 @@ use cargo::drop_eprint;
use std::io::Read;

pub fn cli() -> App {
subcommand("describe-future-incompatibilities")
.arg(
opt(
"id",
"identifier of the report [generated by a Cargo command invocation",
)
.value_name("id")
.required(true),
subcommand("report")
.about("Generate and display various kinds of reports")
.after_help("Run `cargo help report` for more detailed information.\n")
.setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
subcommand("future-incompatibilities")
.about("Reports any crates which will eventually stop compiling")
.arg(
opt(
"id",
"identifier of the report generated by a Cargo command invocation",
)
.value_name("id")
.required(true),
),
)
.about("Reports any crates which will eventually stop compiling")
}

pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
if !config.nightly_features_allowed {
return Err(anyhow!(
"`cargo describe-future-incompatibilities` can only be used on the nightly channel"
)
.into());
return Err(anyhow!("`cargo report` can only be used on the nightly channel").into());
}
match args.subcommand() {
("future-incompatibilities", Some(args)) => report_future_incompatibilies(config, args),
(cmd, _) => panic!("unexpected command `{}`", cmd),
}
}

fn report_future_incompatibilies(config: &Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let report_file = ws.target_dir().open_ro(
FUTURE_INCOMPAT_FILE,
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,11 +887,11 @@ impl<'cfg> DrainState<'cfg> {
if cx.bcx.build_config.future_incompat_report {
drop_eprint!(cx.bcx.config, "{}", full_report);
drop(cx.bcx.config.shell().note(
&format!("this report can be shown with `cargo describe-future-incompatibilities -Z future-incompat-report --id {}`", id)
&format!("this report can be shown with `cargo report future-incompatibilities -Z future-incompat-report --id {}`", id)
));
} else {
drop(cx.bcx.config.shell().note(
&format!("to see what the problems were, use the option `--future-incompat-report`, or run `cargo describe-future-incompatibilities --id {}`", id)
&format!("to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id {}`", id)
));
}
}
Expand Down
12 changes: 5 additions & 7 deletions tests/testsuite/future_incompat_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ fn gate_future_incompat_report() {
.with_status(101)
.run();

p.cargo("describe-future-incompatibilities --id foo")
.with_stderr_contains(
"error: `cargo describe-future-incompatibilities` can only be used on the nightly channel"
)
p.cargo("report future-incompatibilities --id foo")
.with_stderr_contains("error: `cargo report` can only be used on the nightly channel")
.with_status(101)
.run();
}
Expand Down Expand Up @@ -134,7 +132,7 @@ fn test_multi_crate() {
.with_stderr_does_not_contain("[..]triggers[..]")
.run();

p.cargo("describe-future-incompatibilities -Z future-incompat-report --id bad-id")
p.cargo("report future-incompatibilities -Z future-incompat-report --id bad-id")
.masquerade_as_nightly_cargo()
.with_stderr_contains("error: Expected an id of [..]")
.with_stderr_does_not_contain("[..]triggers[..]")
Expand All @@ -157,7 +155,7 @@ fn test_multi_crate() {
.unwrap();

// Extract the 'id' from the stdout. We are looking
// for the id in a line of the form "run `cargo describe-future-incompatibilities --id yZ7S`"
// for the id in a line of the form "run `cargo report future-incompatibilities --id yZ7S`"
// which is generated by Cargo to tell the user what command to run
// This is just to test that passing the id suppresses the warning mesasge. Any users needing
// access to the report from a shell script should use the `--future-incompat-report` flag
Expand All @@ -172,7 +170,7 @@ fn test_multi_crate() {
// Strip off the trailing '`' included in the output
let id: String = id.chars().take_while(|c| *c != '`').collect();

p.cargo(&format!("describe-future-incompatibilities -Z future-incompat-report --id {}", id))
p.cargo(&format!("report future-incompatibilities -Z future-incompat-report --id {}", id))
.masquerade_as_nightly_cargo()
.with_stderr_contains("The crate `first-dep v0.0.1` currently triggers the following future incompatibility lints:")
.with_stderr_contains("The crate `second-dep v0.0.2` currently triggers the following future incompatibility lints:")
Expand Down

0 comments on commit 1228f49

Please sign in to comment.