assert_that(p.cargo("update"), execs().with_status(0).with_stdout(""));
assert_that(&lockfile, existing_file());
}
+
+// Ensure that the "-Z minimal-versions" CLI option works and the minimal
+// version of a dependency ends up in the lock file.
+#[test]
+fn install_minimal_version() {
+ Package::new("dep", "1.0.0").publish();
+ Package::new("dep", "1.1.0").publish();
+
+ let p = project("foo")
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ authors = []
+ version = "0.0.1"
+
+ [dependencies]
+ dep = "1.0"
+ "#,
+ )
+ .file("src/main.rs", "fn main() {}")
+ .build();
+
+ assert_that(
+ p.cargo("generate-lockfile")
+ .masquerade_as_nightly_cargo()
+ .arg("-Zminimal-versions"),
+ execs().with_status(0),
+ );
+
+ let lock = p.read_lockfile();
+
+ assert!(lock.contains("dep 1.0.0"));
+}