Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle updates to version requirements in lockfiles #990

Merged
merged 1 commit into from
Dec 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,18 @@ impl<'a> PackageRegistry<'a> {
// sure to lock to precisely the given package id.
//
// 2. We have a lock entry for this dependency, but it's from a
// different source than what's listed. In this case we must
// discard the locked version because the listed source must
// have changed.
// different source than what's listed, or the version
// requirement has changed. In this case we must discard the
// locked version because the dependency needs to be
// re-resolved.
//
// 3. We don't have a lock entry for this dependency, in which
// case it was likely an optional dependency which wasn't
// included previously so we just pass it through anyway.
Some(&(_, ref deps)) => {
match deps.iter().find(|d| d.get_name() == dep.get_name()) {
Some(lock) => {
if lock.get_source_id() == dep.get_source_id() {
if dep.matches_id(lock) {
dep.lock_to(lock)
} else {
dep
Expand Down
59 changes: 59 additions & 0 deletions tests/test_cargo_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,62 @@ test!(bad_license_file {
.with_stderr("\
the license file `foo` does not exist"));
})

test!(updating_a_dep {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.0.1"
authors = []

[dependencies.a]
path = "a"
"#)
.file("src/main.rs", "fn main() {}")
.file("a/Cargo.toml", r#"
[project]
name = "a"
version = "0.0.1"
authors = []

[dependencies]
bar = "*"
"#)
.file("a/src/lib.rs", "");
p.build();

r::mock_pkg("bar", "0.0.1", &[]);

assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(format!("\
{updating} registry `[..]`
{downloading} bar v0.0.1 (registry file://[..])
{compiling} bar v0.0.1 (registry file://[..])
{compiling} a v0.0.1 ({dir})
{compiling} foo v0.0.1 ({dir})
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url()).as_slice()));

File::create(&p.root().join("a/Cargo.toml")).write_str(r#"
[project]
name = "a"
version = "0.0.1"
authors = []

[dependencies]
bar = "0.1.0"
"#).unwrap();
r::mock_pkg("bar", "0.1.0", &[]);

println!("second");
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(format!("\
{updating} registry `[..]`
{downloading} bar v0.1.0 (registry file://[..])
{compiling} bar v0.1.0 (registry file://[..])
{compiling} a v0.0.1 ({dir})
{compiling} foo v0.0.1 ({dir})
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url()).as_slice()));
})