Updating based on code review
authorPelepeichenko Alexander <chabapok@gmail.com>
Mon, 8 Jan 2018 18:22:12 +0000 (20:22 +0200)
committerPelepeichenko Alexander <chabapok@gmail.com>
Mon, 8 Jan 2018 21:08:48 +0000 (23:08 +0200)
src/cargo/core/resolver/mod.rs
src/cargo/sources/git/source.rs
tests/build.rs
tests/git.rs

index e59c735990cd53287df423b0620c9b9afa5c8abe..02a26a9f79cda77fbef8eb2fd2c7682ae65c999a 100644 (file)
@@ -889,8 +889,10 @@ fn activation_error(cx: &Context,
 
     if let Some(config) = config {
         if config.cli_unstable().offline {
-            msg.push_str("\nperhaps an error occurred because you are using \
-                              the offline mode");
+            msg.push_str("\nAs a reminder, you're using offline mode (-Z offline) \
+            which can sometimes cause surprising resolution failures, \
+            if this error is too confusing you may with to retry \
+            without the offline flag.");
         }
     }
 
index 3862266de5743e4a8fec552726f38fed1a0ef9ca..0ec9c1697782e9923bd071c9fb5ca13b2c95157f 100644 (file)
@@ -152,7 +152,8 @@ impl<'cfg> Source for GitSource<'cfg> {
         let db_path = lock.parent().join("db").join(&self.ident);
 
         if self.config.cli_unstable().offline && !db_path.exists() {
-            bail!("can't checkout from '{}': you are in the offline mode", self.remote.url());
+            bail!("can't checkout from '{}': you are in the offline mode (-Z offline)",
+                self.remote.url());
         }
 
         // Resolve our reference to an actual revision, and check if the
index bf4348b8520d92607a1a29395731e1fee1eb1ab9..1ca01cabffe901f8fccd44eb9da30b4147b6fa91 100644 (file)
@@ -897,13 +897,10 @@ fn cargo_compile_with_downloaded_dependency_with_offline() {
 
     assert_that(p2.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
                 execs().with_status(0)
-                    .with_stderr_does_not_contain("Updating registry")
-                    .with_stderr_does_not_contain("Downloading")
                     .with_stderr(format!("\
 [COMPILING] present_dep v1.2.3
-[COMPILING] bar v0.1.0 ({url})
-[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
-                                         url = p2.url())));
+[COMPILING] bar v0.1.0 ([..])
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")));
 
 }
 
@@ -923,13 +920,14 @@ fn cargo_compile_offline_not_try_update() {
 
     assert_that(p.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
                 execs().with_status(101)
-                    .with_stderr_does_not_contain("Updating registry")
-                    .with_stderr_does_not_contain("Downloading")
                     .with_stderr("\
 error: no matching package named `not_cached_dep` found (required by `bar`)
 location searched: registry `[..]`
 version required: ^1.2.5
-perhaps an error occurred because you are using the offline mode"));
+As a reminder, you're using offline mode (-Z offline) \
+which can sometimes cause surprising resolution failures, \
+if this error is too confusing you may with to retry \
+without the offline flag."));
 }
 
 #[test]
@@ -987,16 +985,15 @@ fn main(){
 }")
         .build();
 
-    assert_that(p2.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
+    assert_that(p2.cargo("run").masquerade_as_nightly_cargo().arg("-Zoffline"),
                 execs().with_status(0)
                     .with_stderr(format!("\
 [COMPILING] present_dep v1.2.3
 [COMPILING] foo v0.1.0 ({url})
-[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
-                                         url = p2.url())));
-
-    assert_that(process(&p2.bin("foo")),
-                execs().with_status(0).with_stdout("1.2.3"));
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
+     Running `[..]`", url = p2.url()))
+                    .with_stdout("1.2.3")
+    );
 }
 
 #[test]
@@ -1033,13 +1030,14 @@ fn compile_offline_while_transitive_dep_not_cached() {
 
     assert_that(p.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
         execs().with_status(101)
-            .with_stderr_does_not_contain("Updating registry")
-            .with_stderr_does_not_contain("Downloading")
             .with_stderr("\
 error: no matching package named `bar` found (required by `foo`)
 location searched: registry `[..]`
 version required: = 1.0.0
-perhaps an error occurred because you are using the offline mode"));
+As a reminder, you're using offline mode (-Z offline) \
+which can sometimes cause surprising resolution failures, \
+if this error is too confusing you may with to retry \
+without the offline flag."));
 }
 
 #[test]
index 8c9edf75f57e21a366476ff3314f730a423060f8..a6ccfcdf1d3f7555413ede92d0fe43a6eb567e91 100644 (file)
@@ -97,7 +97,6 @@ fn cargo_compile_forbird_git_httpsrepo_offline() {
 
     assert_that(p.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
                 execs().with_status(101).
-                    with_stderr_does_not_contain("[UPDATING] git repository [..]").
                     with_stderr("\
 error: failed to load source for a dependency on `dep1`
 
@@ -105,7 +104,7 @@ Caused by:
   Unable to update https://github.com/some_user/dep1.git
 
 Caused by:
-  can't checkout from 'https://github.com/some_user/dep1.git': you are in the offline mode"));
+  can't checkout from 'https://github.com/some_user/dep1.git': you are in the offline mode (-Z offline)"));
 }