Skip to content

Commit

Permalink
Auto merge of #2576 - alexcrichton:silence-warnings-with-q, r=brson
Browse files Browse the repository at this point in the history
Don't print warnings when -q is passed

Closes #2571
  • Loading branch information
bors committed Apr 21, 2016
2 parents bf3f531 + 6759865 commit e12d5ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cargo/core/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ impl MultiShell {
}

pub fn warn<T: fmt::Display>(&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, verbosity: Verbosity) {
Expand Down
15 changes: 15 additions & 0 deletions tests/test_cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(""));
});

0 comments on commit e12d5ad

Please sign in to comment.