From b83ef97efb5d8d2a0d15f3dcd84f3f5d65a98193 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Tue, 30 Jan 2018 23:09:13 -0500 Subject: [PATCH 1/2] add a -Z no-index-update for crater and benchmarking --- src/cargo/core/features.rs | 2 ++ src/cargo/sources/registry/remote.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index 3add03fcc38..414e6a4a8b6 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -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 { @@ -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), } diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index f21e54fa58e..5ffabb9d5b5 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -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 From ba054375543aef7e248556e383a66ee31a544ce2 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Wed, 31 Jan 2018 16:12:19 -0500 Subject: [PATCH 2/2] add a test --- tests/generate-lockfile.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/generate-lockfile.rs b/tests/generate-lockfile.rs index 56f85301871..2a6459602a9 100644 --- a/tests/generate-lockfile.rs +++ b/tests/generate-lockfile.rs @@ -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")