Skip to content

Commit

Permalink
Updating based on code review
Browse files Browse the repository at this point in the history
  • Loading branch information
chabapok committed Jan 8, 2018
1 parent ec5f78f commit 3ed3497
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 4 additions & 2 deletions src/cargo/core/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/cargo/sources/git/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 15 additions & 17 deletions tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 [..]")));

}

Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions tests/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,14 @@ 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`
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)"));
}


Expand Down

0 comments on commit 3ed3497

Please sign in to comment.