None => None,
};
let vers = vers.as_ref().map(|s| &**s);
- let dep = Dependency::parse_no_deprecated(name, vers, source.source_id())?;
+ let dep = Dependency::parse_no_deprecated(
+ name,
+ Some(vers.unwrap_or("*")),
+ source.source_id(),
+ )?;
let deps = source.query_vec(&dep)?;
match deps.iter().map(|p| p.package_id()).max() {
Some(pkgid) => {
#[test]
fn pick_max_version() {
- pkg("foo", "0.0.1");
- pkg("foo", "0.0.2");
+ pkg("foo", "0.1.0");
+ pkg("foo", "0.2.0");
+ pkg("foo", "0.2.1");
+ pkg("foo", "0.2.1-pre.1");
+ pkg("foo", "0.3.0-pre.2");
assert_that(
cargo_process("install").arg("foo"),
execs().with_status(0).with_stderr(&format!(
"\
[UPDATING] registry `[..]`
-[DOWNLOADING] foo v0.0.2 (registry [..])
-[INSTALLING] foo v0.0.2
-[COMPILING] foo v0.0.2
+[DOWNLOADING] foo v0.2.1 (registry [..])
+[INSTALLING] foo v0.2.1
+[COMPILING] foo v0.2.1
[FINISHED] release [optimized] target(s) in [..]
[INSTALLING] {home}[..]bin[..]foo[..]
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
execs().with_status(0).with_stderr("[FINISHED] [..]"),
);
}
+
+#[test]
+fn replace_prerelease() {
+ Package::new("bar", "1.1.0-pre.1").publish();
+ let p = project("foo")
+ .file(
+ "Cargo.toml",
+ r#"
+ [workspace]
+ members = ["foo"]
+
+ [patch.crates-io]
+ bar = { path = "./bar" }
+ "#,
+ )
+ .file(
+ "foo/Cargo.toml",
+ r#"
+ [project]
+ name = "foo"
+ version = "0.5.0"
+ authors = []
+
+ [dependencies]
+ bar = "1.1.0-pre.1"
+ "#,
+ )
+ .file(
+ "foo/src/main.rs",
+ "
+ extern crate bar;
+ fn main() { bar::bar() }
+ ",
+ )
+ .file(
+ "bar/Cargo.toml",
+ r#"
+ [project]
+ name = "bar"
+ version = "1.1.0-pre.1"
+ authors = []
+ [workspace]
+ "#,
+ )
+ .file("bar/src/lib.rs", "pub fn bar() {}")
+ .build();
+
+ assert_that(p.cargo("build"), execs().with_status(0));
+}