mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Add report
subcommand.
This commit is contained in:
parent
6701e33f69
commit
ff49b829e6
@ -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(),
|
||||
@ -25,6 +24,7 @@ pub fn builtin() -> Vec<App> {
|
||||
pkgid::cli(),
|
||||
publish::cli(),
|
||||
read_manifest::cli(),
|
||||
report::cli(),
|
||||
run::cli(),
|
||||
rustc::cli(),
|
||||
rustdoc::cli(),
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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;
|
||||
@ -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;
|
||||
|
@ -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,
|
@ -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)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
@ -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[..]")
|
||||
@ -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
|
||||
@ -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:")
|
||||
|
Loading…
x
Reference in New Issue
Block a user