tests(resolver): Add integration test for -Z minimal-versions
authorKlaus Purer <klaus.purer@gmail.com>
Fri, 23 Mar 2018 18:58:56 +0000 (19:58 +0100)
committerKlaus Purer <klaus.purer@gmail.com>
Fri, 23 Mar 2018 18:58:56 +0000 (19:58 +0100)
src/cargo/core/resolver/mod.rs
tests/testsuite/generate_lockfile.rs

index ec5f376debe0474d2f882f9cb4d29400959dbf86..0e266ecf2a38dc993cc630571195f561c3bcd7a6 100644 (file)
@@ -816,7 +816,7 @@ impl<'a> RegistryQueryer<'a> {
                         // Higher version ordered first.
                         cmp.reverse()
                     }
-                },
+                }
                 _ => previous_cmp,
             }
         });
index 6018904f03fab97c09e20282b7d9996103416e29..69476315ff81e0f03237a61e48e620fbdf720d35 100644 (file)
@@ -250,3 +250,38 @@ fn cargo_update_generate_lockfile() {
     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"));
+}