Skip to content

Commit

Permalink
Auto merge of #4990 - Eh2406:Zno-index-update, r=alexcrichton
Browse files Browse the repository at this point in the history
add a -Z no-index-update for crater and benchmarking

This is a fix for #3479
  • Loading branch information
bors committed Jan 31, 2018
2 parents b23ebe2 + ba05437 commit df11070
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ pub struct CliUnstable {
pub print_im_a_teapot: bool,
pub unstable_options: bool,
pub offline: bool,
pub no_index_update: bool,
}

impl CliUnstable {
Expand Down Expand Up @@ -264,6 +265,7 @@ impl CliUnstable {
"print-im-a-teapot" => self.print_im_a_teapot = parse_bool(v)?,
"unstable-options" => self.unstable_options = true,
"offline" => self.offline = true,
"no-index-update" => self.no_index_update = true,
_ => bail!("unknown `-Z` flag specified: {}", k),
}

Expand Down
3 changes: 3 additions & 0 deletions src/cargo/sources/registry/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
if self.config.cli_unstable().offline {
return Ok(());
}
if self.config.cli_unstable().no_index_update {
return Ok(());
}

// Ensure that we'll actually be able to acquire an HTTP handle later on
// once we start trying to download crates. This will weed out any
Expand Down
25 changes: 25 additions & 0 deletions tests/generate-lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@ fn adding_and_removing_packages() {
assert_eq!(lock1, lock4);
}

#[test]
fn no_index_update() {
use cargotest::ChannelChanger;
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
authors = []
version = "0.0.1"
[dependencies]
serde = "1.0"
"#)
.file("src/main.rs", "fn main() {}")
.build();

assert_that(p.cargo("generate-lockfile"),
execs().with_status(0).with_stdout("")
.with_stderr_contains(" Updating registry `https://github.com/rust-lang/crates.io-index`"));

assert_that(p.cargo("generate-lockfile").masquerade_as_nightly_cargo().arg("-Zno-index-update"),
execs().with_status(0).with_stdout("")
.with_stderr_does_not_contain(" Updating registry `https://github.com/rust-lang/crates.io-index`"));
}

#[test]
fn preserve_metadata() {
let p = project("foo")
Expand Down

0 comments on commit df11070

Please sign in to comment.