Skip to content

Commit df11070

Browse files
committed
Auto merge of #4990 - Eh2406:Zno-index-update, r=alexcrichton
add a -Z no-index-update for crater and benchmarking This is a fix for #3479
2 parents b23ebe2 + ba05437 commit df11070

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/cargo/core/features.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ pub struct CliUnstable {
233233
pub print_im_a_teapot: bool,
234234
pub unstable_options: bool,
235235
pub offline: bool,
236+
pub no_index_update: bool,
236237
}
237238

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

src/cargo/sources/registry/remote.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
156156
if self.config.cli_unstable().offline {
157157
return Ok(());
158158
}
159+
if self.config.cli_unstable().no_index_update {
160+
return Ok(());
161+
}
159162

160163
// Ensure that we'll actually be able to acquire an HTTP handle later on
161164
// once we start trying to download crates. This will weed out any

tests/generate-lockfile.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,31 @@ fn adding_and_removing_packages() {
7474
assert_eq!(lock1, lock4);
7575
}
7676

77+
#[test]
78+
fn no_index_update() {
79+
use cargotest::ChannelChanger;
80+
let p = project("foo")
81+
.file("Cargo.toml", r#"
82+
[package]
83+
name = "foo"
84+
authors = []
85+
version = "0.0.1"
86+
87+
[dependencies]
88+
serde = "1.0"
89+
"#)
90+
.file("src/main.rs", "fn main() {}")
91+
.build();
92+
93+
assert_that(p.cargo("generate-lockfile"),
94+
execs().with_status(0).with_stdout("")
95+
.with_stderr_contains(" Updating registry `https://github.com/rust-lang/crates.io-index`"));
96+
97+
assert_that(p.cargo("generate-lockfile").masquerade_as_nightly_cargo().arg("-Zno-index-update"),
98+
execs().with_status(0).with_stdout("")
99+
.with_stderr_does_not_contain(" Updating registry `https://github.com/rust-lang/crates.io-index`"));
100+
}
101+
77102
#[test]
78103
fn preserve_metadata() {
79104
let p = project("foo")

0 commit comments

Comments
 (0)