From 67598654b4c1af39169c1c132d16fe19ae72225b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 14 Apr 2016 10:25:25 -0700 Subject: [PATCH] Don't print warnings when -q is passed Closes #2571 --- src/cargo/core/shell.rs | 5 ++++- tests/test_cargo_install.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 57876c97188..95750ef3480 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -100,7 +100,10 @@ impl MultiShell { } pub fn warn(&mut self, message: T) -> CargoResult<()> { - self.err().say_status("warning:", message, YELLOW, false) + match self.verbosity { + Quiet => Ok(()), + _ => self.err().say_status("warning:", message, YELLOW, false), + } } pub fn set_verbosity(&mut self, verbose: bool, quiet: bool) -> CargoResult<()> { diff --git a/tests/test_cargo_install.rs b/tests/test_cargo_install.rs index 59270d11771..31d9bf7fcd8 100644 --- a/tests/test_cargo_install.rs +++ b/tests/test_cargo_install.rs @@ -644,3 +644,18 @@ test!(git_with_lockfile { assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()), execs().with_status(0)); }); + +test!(q_silences_warnings { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("-q").arg("--path").arg(p.root()), + execs().with_status(0).with_stderr("")); +});