]> git.proxmox.com Git - cargo.git/commitdiff
Improve test output with `--quiet`
authorAlex Crichton <alex@alexcrichton.com>
Thu, 26 Sep 2019 18:21:54 +0000 (11:21 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 26 Sep 2019 18:32:29 +0000 (11:32 -0700)
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.

src/cargo/util/network.rs
tests/testsuite/member_errors.rs
tests/testsuite/new.rs
tests/testsuite/search.rs

index c451c400877a47a0b1b3b99731b55b71ef3cd082..a927e9e044f42dc4c92d6c5a32509171c5da9a3d 100644 (file)
@@ -92,8 +92,11 @@ where
         }
     }
 }
+
 #[test]
 fn with_retry_repeats_the_call_then_works() {
+    use crate::core::Shell;
+
     //Error HTTP codes (5xx) are considered maybe_spurious and will prompt retry
     let error1 = HttpNot200 {
         code: 501,
@@ -107,12 +110,15 @@ fn with_retry_repeats_the_call_then_works() {
     .into();
     let mut results: Vec<CargoResult<()>> = vec![Ok(()), Err(error1), Err(error2)];
     let config = Config::default().unwrap();
+    *config.shell() = Shell::from_write(Box::new(Vec::new()));
     let result = with_retry(&config, || results.pop().unwrap());
     assert_eq!(result.unwrap(), ())
 }
 
 #[test]
 fn with_retry_finds_nested_spurious_errors() {
+    use crate::core::Shell;
+
     //Error HTTP codes (5xx) are considered maybe_spurious and will prompt retry
     //String error messages are not considered spurious
     let error1 = failure::Error::from(HttpNot200 {
@@ -127,6 +133,7 @@ fn with_retry_finds_nested_spurious_errors() {
     let error2 = failure::Error::from(error2.context("A second chained error"));
     let mut results: Vec<CargoResult<()>> = vec![Ok(()), Err(error1), Err(error2)];
     let config = Config::default().unwrap();
+    *config.shell() = Shell::from_write(Box::new(Vec::new()));
     let result = with_retry(&config, || results.pop().unwrap());
     assert_eq!(result.unwrap(), ())
 }
index 09e7a7961b57c68b148c1fe0a3d61e8a921ae39d..e1d855bd0d6d17f1b424c3439c4fd2454b19710c 100644 (file)
@@ -143,7 +143,11 @@ fn member_manifest_version_error() {
 
     // Prevent this test from accessing the network by setting up .cargo/config.
     registry::init();
-    let config = Config::new(Shell::new(), cargo_home(), cargo_home());
+    let config = Config::new(
+        Shell::from_write(Box::new(Vec::new())),
+        cargo_home(),
+        cargo_home(),
+    );
     let ws = Workspace::new(&p.root().join("Cargo.toml"), &config).unwrap();
     let compile_options = CompileOptions::new(&config, CompileMode::Build).unwrap();
     let member_bar = ws.members().find(|m| &*m.name() == "bar").unwrap();
index 08894c9395173632c6c97145f05605d0b7acf113..345a2531034426cd9933e774c2e609241b3be3e4 100644 (file)
@@ -264,7 +264,7 @@ fn finds_author_git() {
 
 #[cargo_test]
 fn finds_local_author_git() {
-    git_process("init").exec().unwrap();
+    git_process("init").exec_with_output().unwrap();
     git_process("config --global user.name foo").exec().unwrap();
     git_process("config --global user.email foo@bar")
         .exec()
index cc464cc7b18dab9c145f1b8cc326ce206718c16e..f70857dcd13028fe9dc0b927e9e2b0bd67b01d6a 100644 (file)
@@ -107,7 +107,11 @@ fn not_update() {
     use cargo::util::Config;
 
     let sid = SourceId::for_registry(&registry_url()).unwrap();
-    let cfg = Config::new(Shell::new(), paths::root(), paths::home().join(".cargo"));
+    let cfg = Config::new(
+        Shell::from_write(Box::new(Vec::new())),
+        paths::root(),
+        paths::home().join(".cargo"),
+    );
     let lock = cfg.acquire_package_cache_lock().unwrap();
     let mut regsrc = RegistrySource::remote(sid, &HashSet::new(), &cfg);
     regsrc.update().unwrap();