Respect lock files in crates.io crates

Currently Cargo doesn't publish lock files in crates.io crates but we'll
eventually be doing so, so this changes Cargo to recognize `Cargo.lock` when
it's published to crates.io as use it as the basis for resolution during `cargo
install`.

cc #2263
This commit is contained in:
Alex Crichton 2018-02-27 07:50:05 -08:00
parent bb927ced11
commit 8b475c1085
2 changed files with 34 additions and 1 deletions

View file

@ -65,7 +65,7 @@ pub fn resolve_ws_precisely<'a>(ws: &Workspace<'a>,
Some(resolve) Some(resolve)
} else { } else {
None ops::load_pkg_lockfile(ws)?
}; };
let method = if all_features { let method = if all_features {

View file

@ -1011,3 +1011,36 @@ fn custom_target_dir_for_git_source() {
assert_that(&paths::root().join("target/release"), assert_that(&paths::root().join("target/release"),
existing_dir()); existing_dir());
} }
#[test]
fn install_respects_lock_file() {
Package::new("bar", "0.1.0").publish();
Package::new("bar", "0.1.1")
.file("src/lib.rs", "not rust")
.publish();
Package::new("foo", "0.1.0")
.dep("bar", "0.1")
.file("src/lib.rs", "")
.file("src/main.rs", "
extern crate foo;
extern crate bar;
fn main() {}
")
.file("Cargo.lock", r#"
[[package]]
name = "bar"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "foo"
version = "0.1.0"
dependencies = [
"bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
"#)
.publish();
assert_that(cargo_process("install").arg("foo"),
execs().with_status(0));
}