Skip to content

Commit d5621be

Browse files
committed
Auto merge of #7446 - alexcrichton:quiet-output, r=Eh2406
Improve test output with `--quiet` We had a few locations where the shell was written to raw instead of through the test harness or through other captured mechanisms. This updates the test suite so testing Cargo with `--quiet` provides a nice and clean report of tests executed.
2 parents a82037b + 7606f79 commit d5621be

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/cargo/util/network.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ where
9292
}
9393
}
9494
}
95+
9596
#[test]
9697
fn with_retry_repeats_the_call_then_works() {
98+
use crate::core::Shell;
99+
97100
//Error HTTP codes (5xx) are considered maybe_spurious and will prompt retry
98101
let error1 = HttpNot200 {
99102
code: 501,
@@ -107,12 +110,15 @@ fn with_retry_repeats_the_call_then_works() {
107110
.into();
108111
let mut results: Vec<CargoResult<()>> = vec![Ok(()), Err(error1), Err(error2)];
109112
let config = Config::default().unwrap();
113+
*config.shell() = Shell::from_write(Box::new(Vec::new()));
110114
let result = with_retry(&config, || results.pop().unwrap());
111115
assert_eq!(result.unwrap(), ())
112116
}
113117

114118
#[test]
115119
fn with_retry_finds_nested_spurious_errors() {
120+
use crate::core::Shell;
121+
116122
//Error HTTP codes (5xx) are considered maybe_spurious and will prompt retry
117123
//String error messages are not considered spurious
118124
let error1 = failure::Error::from(HttpNot200 {
@@ -127,6 +133,7 @@ fn with_retry_finds_nested_spurious_errors() {
127133
let error2 = failure::Error::from(error2.context("A second chained error"));
128134
let mut results: Vec<CargoResult<()>> = vec![Ok(()), Err(error1), Err(error2)];
129135
let config = Config::default().unwrap();
136+
*config.shell() = Shell::from_write(Box::new(Vec::new()));
130137
let result = with_retry(&config, || results.pop().unwrap());
131138
assert_eq!(result.unwrap(), ())
132139
}

tests/testsuite/member_errors.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ fn member_manifest_version_error() {
143143

144144
// Prevent this test from accessing the network by setting up .cargo/config.
145145
registry::init();
146-
let config = Config::new(Shell::new(), cargo_home(), cargo_home());
146+
let config = Config::new(
147+
Shell::from_write(Box::new(Vec::new())),
148+
cargo_home(),
149+
cargo_home(),
150+
);
147151
let ws = Workspace::new(&p.root().join("Cargo.toml"), &config).unwrap();
148152
let compile_options = CompileOptions::new(&config, CompileMode::Build).unwrap();
149153
let member_bar = ws.members().find(|m| &*m.name() == "bar").unwrap();

tests/testsuite/new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fn finds_author_git() {
264264

265265
#[cargo_test]
266266
fn finds_local_author_git() {
267-
git_process("init").exec().unwrap();
267+
git_process("init").exec_with_output().unwrap();
268268
git_process("config --global user.name foo").exec().unwrap();
269269
git_process("config --global user.email foo@bar")
270270
.exec()

tests/testsuite/search.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ fn not_update() {
107107
use cargo::util::Config;
108108

109109
let sid = SourceId::for_registry(&registry_url()).unwrap();
110-
let cfg = Config::new(Shell::new(), paths::root(), paths::home().join(".cargo"));
110+
let cfg = Config::new(
111+
Shell::from_write(Box::new(Vec::new())),
112+
paths::root(),
113+
paths::home().join(".cargo"),
114+
);
111115
let lock = cfg.acquire_package_cache_lock().unwrap();
112116
let mut regsrc = RegistrySource::remote(sid, &HashSet::new(), &cfg);
113117
regsrc.update().unwrap();

0 commit comments

Comments
 (0)