Skip to content

Commit 131c3e2

Browse files
committed
tests(resolver): Add integration test for -Z minimal-versions
1 parent 115d356 commit 131c3e2

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/cargo/core/resolver/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ impl<'a> RegistryQueryer<'a> {
816816
// Higher version ordered first.
817817
cmp.reverse()
818818
}
819-
},
819+
}
820820
_ => previous_cmp,
821821
}
822822
});

tests/testsuite/generate_lockfile.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,38 @@ fn cargo_update_generate_lockfile() {
250250
assert_that(p.cargo("update"), execs().with_status(0).with_stdout(""));
251251
assert_that(&lockfile, existing_file());
252252
}
253+
254+
// Ensure that the "-Z minimal-versions" CLI option works and the minimal
255+
// version of a dependency ends up in the lock file.
256+
#[test]
257+
fn install_minimal_version() {
258+
Package::new("dep", "1.0.0").publish();
259+
Package::new("dep", "1.1.0").publish();
260+
261+
let p = project("foo")
262+
.file(
263+
"Cargo.toml",
264+
r#"
265+
[package]
266+
name = "foo"
267+
authors = []
268+
version = "0.0.1"
269+
270+
[dependencies]
271+
dep = "1.0"
272+
"#,
273+
)
274+
.file("src/main.rs", "fn main() {}")
275+
.build();
276+
277+
assert_that(
278+
p.cargo("generate-lockfile")
279+
.masquerade_as_nightly_cargo()
280+
.arg("-Zminimal-versions"),
281+
execs().with_status(0),
282+
);
283+
284+
let lock = p.read_lockfile();
285+
286+
assert!(lock.contains("dep 1.0.0"));
287+
}

0 commit comments

Comments
 (0)