From 805dfe4e7964da509ea6dbc733b40ffcca21d874 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 12 Apr 2016 14:55:19 -0700 Subject: [PATCH] Allow specifying -v multiple times This commit modifies the CLI interface to allow the verbose (-v) flag to be specified multiple times. This'll be used soon to have `-vv` indicate that more output should be generated than `-v` during a normal build. Currently this commit changes the behavior of whether warnings are printed to print warnings for the **entire DAG of dependencies** if `-vv` is specified. That is, `--cap-lints` is never passed nor is any warning from build scripts if `-vv` is specified. --- src/bin/bench.rs | 4 +-- src/bin/build.rs | 4 +-- src/bin/cargo.rs | 4 +-- src/bin/clean.rs | 4 +-- src/bin/doc.rs | 4 +-- src/bin/fetch.rs | 4 +-- src/bin/generate_lockfile.rs | 4 +-- src/bin/git_checkout.rs | 4 +-- src/bin/init.rs | 4 +-- src/bin/install.rs | 4 +-- src/bin/login.rs | 4 +-- src/bin/metadata.rs | 4 +-- src/bin/new.rs | 4 +-- src/bin/owner.rs | 4 +-- src/bin/package.rs | 4 +-- src/bin/pkgid.rs | 4 +-- src/bin/publish.rs | 4 +-- src/bin/run.rs | 4 +-- src/bin/rustc.rs | 4 +-- src/bin/rustdoc.rs | 4 +-- src/bin/search.rs | 4 +-- src/bin/test.rs | 4 +-- src/bin/uninstall.rs | 4 +-- src/bin/update.rs | 4 +-- src/bin/verify_project.rs | 4 +-- src/bin/yank.rs | 4 +-- src/cargo/ops/cargo_rustc/context.rs | 3 +- src/cargo/util/config.rs | 11 ++++++- tests/build-script.rs | 46 ++++++++++++++++++++++++---- tests/registry.rs | 25 +++++++++++++++ 30 files changed, 129 insertions(+), 60 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 3aff7fb1d81..fc412ef1aaa 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -11,7 +11,7 @@ pub struct Options { flag_no_default_features: bool, flag_target: Option, flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_lib: bool, @@ -42,7 +42,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to build benchmarks for - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/build.rs b/src/bin/build.rs index 5a66ca75496..25d69440edf 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -13,7 +13,7 @@ pub struct Options { flag_no_default_features: bool, flag_target: Option, flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_release: bool, @@ -44,7 +44,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to compile - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index d7bd169cd98..3142bdd0a9d 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -21,7 +21,7 @@ use cargo::util::process_builder::process; pub struct Flags { flag_list: bool, flag_version: bool, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_explain: Option, @@ -41,7 +41,7 @@ Options: -V, --version Print version info and exit --list List installed commands --explain CODE Run `rustc --explain CODE` - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/clean.rs b/src/bin/clean.rs index 5bcb10aeb25..af3968cf816 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -9,7 +9,7 @@ pub struct Options { flag_package: Vec, flag_target: Option, flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_release: bool, @@ -27,7 +27,7 @@ Options: --manifest-path PATH Path to the manifest to the package to clean --target TRIPLE Target triple to clean output for (default all) --release Whether or not to clean release artifacts - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/doc.rs b/src/bin/doc.rs index b7dbb1ade0c..37b5f60406d 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -12,7 +12,7 @@ pub struct Options { flag_no_deps: bool, flag_open: bool, flag_release: bool, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_package: Vec, @@ -39,7 +39,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to document - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/fetch.rs b/src/bin/fetch.rs index 1f32e874154..0d72fff44b5 100644 --- a/src/bin/fetch.rs +++ b/src/bin/fetch.rs @@ -5,7 +5,7 @@ use cargo::util::important_paths::find_root_manifest_for_wd; #[derive(RustcDecodable)] pub struct Options { flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, } @@ -19,7 +19,7 @@ Usage: Options: -h, --help Print this message --manifest-path PATH Path to the manifest to fetch dependencies for - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/generate_lockfile.rs b/src/bin/generate_lockfile.rs index 7e50eff265f..83b44d4eeef 100644 --- a/src/bin/generate_lockfile.rs +++ b/src/bin/generate_lockfile.rs @@ -7,7 +7,7 @@ use cargo::util::important_paths::find_root_manifest_for_wd; #[derive(RustcDecodable)] pub struct Options { flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, } @@ -21,7 +21,7 @@ Usage: Options: -h, --help Print this message --manifest-path PATH Path to the manifest to generate a lockfile for - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never "; diff --git a/src/bin/git_checkout.rs b/src/bin/git_checkout.rs index 8d3e29ac2eb..d3f49db6cde 100644 --- a/src/bin/git_checkout.rs +++ b/src/bin/git_checkout.rs @@ -6,7 +6,7 @@ use cargo::util::{Config, CliResult, CliError, human, ToUrl}; pub struct Options { flag_url: String, flag_reference: String, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, } @@ -20,7 +20,7 @@ Usage: Options: -h, --help Print this message - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never "; diff --git a/src/bin/init.rs b/src/bin/init.rs index 8856f8b3599..3f02f057f3a 100644 --- a/src/bin/init.rs +++ b/src/bin/init.rs @@ -5,7 +5,7 @@ use cargo::util::{CliResult, Config}; #[derive(RustcDecodable)] pub struct Options { - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_bin: bool, @@ -28,7 +28,7 @@ Options: control at all (none) overriding a global configuration. --bin Use a binary instead of a library template --name NAME Set the resulting package name - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never "; diff --git a/src/bin/install.rs b/src/bin/install.rs index 3f8d50baebe..5422375518f 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -10,7 +10,7 @@ pub struct Options { flag_debug: bool, flag_bin: Vec, flag_example: Vec, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_root: Option, @@ -53,7 +53,7 @@ Build and install options: --bin NAME Only install the binary NAME --example EXAMPLE Install the example EXAMPLE instead of binaries --root DIR Directory to install packages into - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet Less output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/login.rs b/src/bin/login.rs index bfb8418e40e..50d8249be7f 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -10,7 +10,7 @@ use cargo::util::{CliResult, Config, human, ChainError}; pub struct Options { flag_host: Option, arg_token: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, } @@ -24,7 +24,7 @@ Usage: Options: -h, --help Print this message --host HOST Host to set the token for - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/metadata.rs b/src/bin/metadata.rs index c8375d95c95..b959be2c0e3 100644 --- a/src/bin/metadata.rs +++ b/src/bin/metadata.rs @@ -16,7 +16,7 @@ pub struct Options { flag_no_default_features: bool, flag_no_deps: bool, flag_quiet: Option, - flag_verbose: Option, + flag_verbose: u32, } pub const USAGE: &'static str = " @@ -35,7 +35,7 @@ Options: --manifest-path PATH Path to the manifest --format-version VERSION Format version [default: 1] Valid values: 1 - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never "; diff --git a/src/bin/new.rs b/src/bin/new.rs index 340fab90b4e..70f9018e497 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -5,7 +5,7 @@ use cargo::util::{CliResult, Config}; #[derive(RustcDecodable)] pub struct Options { - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_bin: bool, @@ -28,7 +28,7 @@ Options: control at all (none) overriding a global configuration. --bin Use a binary instead of a library template --name NAME Set the resulting package name - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never "; diff --git a/src/bin/owner.rs b/src/bin/owner.rs index 33f49e51140..1eb02429576 100644 --- a/src/bin/owner.rs +++ b/src/bin/owner.rs @@ -8,7 +8,7 @@ pub struct Options { flag_add: Option>, flag_remove: Option>, flag_index: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_list: bool, @@ -27,7 +27,7 @@ Options: -l, --list List owners of a crate --index INDEX Registry index to modify owners for --token TOKEN API token to use when authenticating - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/package.rs b/src/bin/package.rs index be4a94cad6c..0336331a21b 100644 --- a/src/bin/package.rs +++ b/src/bin/package.rs @@ -4,7 +4,7 @@ use cargo::util::important_paths::find_root_manifest_for_wd; #[derive(RustcDecodable)] pub struct Options { - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_manifest_path: Option, @@ -27,7 +27,7 @@ Options: --no-metadata Ignore warnings about a lack of human-usable metadata --allow-dirty Allow dirty working directories to be packaged --manifest-path PATH Path to the manifest to compile - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/pkgid.rs b/src/bin/pkgid.rs index 68e53236f20..beff81e3db9 100644 --- a/src/bin/pkgid.rs +++ b/src/bin/pkgid.rs @@ -4,7 +4,7 @@ use cargo::util::important_paths::{find_root_manifest_for_wd}; #[derive(RustcDecodable)] pub struct Options { - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_manifest_path: Option, @@ -20,7 +20,7 @@ Usage: Options: -h, --help Print this message --manifest-path PATH Path to the manifest to the package to clean - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/publish.rs b/src/bin/publish.rs index 73466c27fbb..32b7f5e400c 100644 --- a/src/bin/publish.rs +++ b/src/bin/publish.rs @@ -7,7 +7,7 @@ pub struct Options { flag_host: Option, flag_token: Option, flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_no_verify: bool, @@ -27,7 +27,7 @@ Options: --no-verify Don't verify package tarball before publish --allow-dirty Allow publishing with a dirty source directory --manifest-path PATH Path to the manifest of the package to publish - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/run.rs b/src/bin/run.rs index 789c90e4c89..7515eba5b8e 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -11,7 +11,7 @@ pub struct Options { flag_no_default_features: bool, flag_target: Option, flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_release: bool, @@ -34,7 +34,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to execute - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 51fec6d8680..2c2e850539b 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -14,7 +14,7 @@ pub struct Options { flag_no_default_features: bool, flag_target: Option, flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_release: bool, @@ -47,7 +47,7 @@ Options: --no-default-features Do not compile default features for the package --target TRIPLE Target triple which compiles will be for --manifest-path PATH Path to the manifest to fetch dependencies for - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index ed53d769ba8..8ed63d991f9 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -11,7 +11,7 @@ pub struct Options { flag_manifest_path: Option, flag_no_default_features: bool, flag_open: bool, - flag_verbose: Option, + flag_verbose: u32, flag_release: bool, flag_quiet: Option, flag_color: Option, @@ -44,7 +44,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to document - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/search.rs b/src/bin/search.rs index 2eae9173c9c..4d1f1ea3bf1 100644 --- a/src/bin/search.rs +++ b/src/bin/search.rs @@ -6,7 +6,7 @@ use std::cmp; #[derive(RustcDecodable)] pub struct Options { flag_host: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_limit: Option, @@ -23,7 +23,7 @@ Usage: Options: -h, --help Print this message --host HOST Host of a registry to search in - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --limit LIMIT Limit the number of results (default: 10, max: 100) diff --git a/src/bin/test.rs b/src/bin/test.rs index 8f2d0feef25..2d4dca94313 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -18,7 +18,7 @@ pub struct Options { flag_example: Vec, flag_test: Vec, flag_bench: Vec, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_release: bool, @@ -47,7 +47,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to build tests for - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --no-fail-fast Run all tests regardless of failure diff --git a/src/bin/uninstall.rs b/src/bin/uninstall.rs index ace6a25007e..046997a44fb 100644 --- a/src/bin/uninstall.rs +++ b/src/bin/uninstall.rs @@ -5,7 +5,7 @@ use cargo::util::{CliResult, Config}; pub struct Options { flag_bin: Vec, flag_root: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, @@ -23,7 +23,7 @@ Options: -h, --help Print this message --root DIR Directory to uninstall packages from --bin NAME Only uninstall the binary NAME - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet Less output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/update.rs b/src/bin/update.rs index 77e4c470cc4..12d26883888 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -10,7 +10,7 @@ pub struct Options { flag_aggressive: bool, flag_precise: Option, flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, } @@ -27,7 +27,7 @@ Options: --aggressive Force updating all dependencies of as well --precise PRECISE Update a single dependency to exactly PRECISE --manifest-path PATH Path to the crate's manifest - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/bin/verify_project.rs b/src/bin/verify_project.rs index 7079a4a6e97..0ce407e08c4 100644 --- a/src/bin/verify_project.rs +++ b/src/bin/verify_project.rs @@ -13,7 +13,7 @@ pub type Error = HashMap; #[derive(RustcDecodable)] pub struct Flags { flag_manifest_path: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, } @@ -28,7 +28,7 @@ Usage: Options: -h, --help Print this message --manifest-path PATH Path to the manifest to verify - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never "; diff --git a/src/bin/yank.rs b/src/bin/yank.rs index 60718c7645d..a869f36fffc 100644 --- a/src/bin/yank.rs +++ b/src/bin/yank.rs @@ -7,7 +7,7 @@ pub struct Options { flag_token: Option, flag_vers: Option, flag_index: Option, - flag_verbose: Option, + flag_verbose: u32, flag_quiet: Option, flag_color: Option, flag_undo: bool, @@ -25,7 +25,7 @@ Options: --undo Undo a yank, putting a version back into the index --index INDEX Registry index to yank from --token TOKEN API token to use when authenticating - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 74e14cf3783..bf458bcbf5c 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -648,7 +648,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } pub fn show_warnings(&self, pkg: &PackageId) -> bool { - pkg == self.resolve.root() || pkg.source_id().is_path() + pkg == self.resolve.root() || pkg.source_id().is_path() || + self.config.extra_verbose() } } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 53ad520e609..2ca6a2001c0 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -31,6 +31,7 @@ pub struct Config { rustc: PathBuf, rustdoc: PathBuf, target_dir: RefCell>, + extra_verbose: Cell, } impl Config { @@ -47,6 +48,7 @@ impl Config { rustc: PathBuf::from("rustc"), rustdoc: PathBuf::from("rustdoc"), target_dir: RefCell::new(None), + extra_verbose: Cell::new(false), }; try!(cfg.scrape_tool_config()); @@ -287,9 +289,11 @@ impl Config { } pub fn configure_shell(&self, - verbose: Option, + verbose: u32, quiet: Option, color: &Option) -> CargoResult<()> { + let extra_verbose = verbose >= 2; + let verbose = if verbose == 0 {None} else {Some(true)}; let cfg_verbose = try!(self.get_bool("term.verbose")).map(|v| v.val); let cfg_color = try!(self.get_string("term.color")).map(|v| v.val); let color = color.as_ref().or(cfg_color.as_ref()); @@ -320,10 +324,15 @@ impl Config { self.shell().set_verbosity(verbosity); try!(self.shell().set_color_config(color.map(|s| &s[..]))); + self.extra_verbose.set(extra_verbose); Ok(()) } + pub fn extra_verbose(&self) -> bool { + self.extra_verbose.get() + } + fn load_values(&self) -> CargoResult<()> { let mut cfg = CV::Table(HashMap::new(), PathBuf::from(".")); diff --git a/tests/build-script.rs b/tests/build-script.rs index 1a5ef7c032e..f555c22a326 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -4,15 +4,10 @@ extern crate hamcrest; use std::fs::{self, File}; use std::io::prelude::*; -<<<<<<< 07c1d9900de40c59b898d08d64273447560ffbe3:tests/build-script.rs use cargotest::{rustc_host, is_nightly, sleep_ms}; use cargotest::support::{project, execs}; use cargotest::support::paths::CargoPathExt; -======= -use support::{project, execs}; -use support::paths::CargoPathExt; -use support::registry::Package; ->>>>>>> Forward warnings from build scripts:tests/test_cargo_compile_custom_build.rs +use cargotest::support::registry::Package; use hamcrest::{assert_that, existing_file, existing_dir}; #[test] @@ -2087,3 +2082,42 @@ fn warnings_hidden_for_upstream() { execs().with_status(0) .with_stderr("")); } + +#[test] +fn warnings_printed_on_vv() { + Package::new("bar", "0.1.0") + .file("build.rs", r#" + fn main() { + println!("cargo:warning=foo"); + println!("cargo:warning=bar"); + } + "#) + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + build = "build.rs" + "#) + .file("src/lib.rs", "") + .publish(); + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.5.0" + authors = [] + + [dependencies] + bar = "*" + "#) + .file("src/lib.rs", ""); + + assert_that(p.cargo_process("build").arg("-vv"), + execs().with_status(0) + .with_stderr("\ +warning: foo +warning: bar +")); +} diff --git a/tests/registry.rs b/tests/registry.rs index cb517c91c1b..83ddb6b7427 100644 --- a/tests/registry.rs +++ b/tests/registry.rs @@ -1045,3 +1045,28 @@ fn resolve_and_backtracking() { assert_that(p.cargo("build"), execs().with_status(0)); } + +#[test] +fn upstream_warnings_on_extra_verbose() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + foo = "*" + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + Package::new("foo", "0.1.0") + .file("src/lib.rs", "fn unused() {}") + .publish(); + + assert_that(p.cargo("build").arg("-vv"), + execs().with_status(0).with_stderr_contains("\ +[..] warning: function is never used[..] +")); +}