Skip to content

Commit

Permalink
Don't print warnings when -q is passed
Browse files Browse the repository at this point in the history
Closes #2571
  • Loading branch information
alexcrichton committed Apr 14, 2016
1 parent 88e3081 commit 6759865
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, verbose: bool, quiet: bool) -> CargoResult<()> {
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 6759865

Please sign in to comment.