mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +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(),
|
check::cli(),
|
||||||
clean::cli(),
|
clean::cli(),
|
||||||
config::cli(),
|
config::cli(),
|
||||||
describe_future_incompatibilities::cli(),
|
|
||||||
doc::cli(),
|
doc::cli(),
|
||||||
fetch::cli(),
|
fetch::cli(),
|
||||||
fix::cli(),
|
fix::cli(),
|
||||||
@ -25,6 +24,7 @@ pub fn builtin() -> Vec<App> {
|
|||||||
pkgid::cli(),
|
pkgid::cli(),
|
||||||
publish::cli(),
|
publish::cli(),
|
||||||
read_manifest::cli(),
|
read_manifest::cli(),
|
||||||
|
report::cli(),
|
||||||
run::cli(),
|
run::cli(),
|
||||||
rustc::cli(),
|
rustc::cli(),
|
||||||
rustdoc::cli(),
|
rustdoc::cli(),
|
||||||
@ -47,7 +47,6 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> Cli
|
|||||||
"check" => check::exec,
|
"check" => check::exec,
|
||||||
"clean" => clean::exec,
|
"clean" => clean::exec,
|
||||||
"config" => config::exec,
|
"config" => config::exec,
|
||||||
"describe-future-incompatibilities" => describe_future_incompatibilities::exec,
|
|
||||||
"doc" => doc::exec,
|
"doc" => doc::exec,
|
||||||
"fetch" => fetch::exec,
|
"fetch" => fetch::exec,
|
||||||
"fix" => fix::exec,
|
"fix" => fix::exec,
|
||||||
@ -65,6 +64,7 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> Cli
|
|||||||
"pkgid" => pkgid::exec,
|
"pkgid" => pkgid::exec,
|
||||||
"publish" => publish::exec,
|
"publish" => publish::exec,
|
||||||
"read-manifest" => read_manifest::exec,
|
"read-manifest" => read_manifest::exec,
|
||||||
|
"report" => report::exec,
|
||||||
"run" => run::exec,
|
"run" => run::exec,
|
||||||
"rustc" => rustc::exec,
|
"rustc" => rustc::exec,
|
||||||
"rustdoc" => rustdoc::exec,
|
"rustdoc" => rustdoc::exec,
|
||||||
@ -87,7 +87,6 @@ pub mod build;
|
|||||||
pub mod check;
|
pub mod check;
|
||||||
pub mod clean;
|
pub mod clean;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod describe_future_incompatibilities;
|
|
||||||
pub mod doc;
|
pub mod doc;
|
||||||
pub mod fetch;
|
pub mod fetch;
|
||||||
pub mod fix;
|
pub mod fix;
|
||||||
@ -106,6 +105,7 @@ pub mod package;
|
|||||||
pub mod pkgid;
|
pub mod pkgid;
|
||||||
pub mod publish;
|
pub mod publish;
|
||||||
pub mod read_manifest;
|
pub mod read_manifest;
|
||||||
|
pub mod report;
|
||||||
pub mod run;
|
pub mod run;
|
||||||
pub mod rustc;
|
pub mod rustc;
|
||||||
pub mod rustdoc;
|
pub mod rustdoc;
|
||||||
|
@ -5,26 +5,35 @@ use cargo::drop_eprint;
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
pub fn cli() -> App {
|
pub fn cli() -> App {
|
||||||
subcommand("describe-future-incompatibilities")
|
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(
|
.arg(
|
||||||
opt(
|
opt(
|
||||||
"id",
|
"id",
|
||||||
"identifier of the report [generated by a Cargo command invocation",
|
"identifier of the report generated by a Cargo command invocation",
|
||||||
)
|
)
|
||||||
.value_name("id")
|
.value_name("id")
|
||||||
.required(true),
|
.required(true),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.about("Reports any crates which will eventually stop compiling")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
||||||
if !config.nightly_features_allowed {
|
if !config.nightly_features_allowed {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!("`cargo report` can only be used on the nightly channel").into());
|
||||||
"`cargo describe-future-incompatibilities` 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 ws = args.workspace(config)?;
|
||||||
let report_file = ws.target_dir().open_ro(
|
let report_file = ws.target_dir().open_ro(
|
||||||
FUTURE_INCOMPAT_FILE,
|
FUTURE_INCOMPAT_FILE,
|
@ -887,11 +887,11 @@ impl<'cfg> DrainState<'cfg> {
|
|||||||
if cx.bcx.build_config.future_incompat_report {
|
if cx.bcx.build_config.future_incompat_report {
|
||||||
drop_eprint!(cx.bcx.config, "{}", full_report);
|
drop_eprint!(cx.bcx.config, "{}", full_report);
|
||||||
drop(cx.bcx.config.shell().note(
|
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 {
|
} else {
|
||||||
drop(cx.bcx.config.shell().note(
|
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)
|
.with_status(101)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("describe-future-incompatibilities --id foo")
|
p.cargo("report future-incompatibilities --id foo")
|
||||||
.with_stderr_contains(
|
.with_stderr_contains("error: `cargo report` can only be used on the nightly channel")
|
||||||
"error: `cargo describe-future-incompatibilities` can only be used on the nightly channel"
|
|
||||||
)
|
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
@ -134,7 +132,7 @@ fn test_multi_crate() {
|
|||||||
.with_stderr_does_not_contain("[..]triggers[..]")
|
.with_stderr_does_not_contain("[..]triggers[..]")
|
||||||
.run();
|
.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()
|
.masquerade_as_nightly_cargo()
|
||||||
.with_stderr_contains("error: Expected an id of [..]")
|
.with_stderr_contains("error: Expected an id of [..]")
|
||||||
.with_stderr_does_not_contain("[..]triggers[..]")
|
.with_stderr_does_not_contain("[..]triggers[..]")
|
||||||
@ -157,7 +155,7 @@ fn test_multi_crate() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Extract the 'id' from the stdout. We are looking
|
// 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
|
// 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
|
// 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
|
// 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
|
// Strip off the trailing '`' included in the output
|
||||||
let id: String = id.chars().take_while(|c| *c != '`').collect();
|
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()
|
.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 `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:")
|
.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