Skip to content

Commit

Permalink
Auto merge of #3489 - matklad:rel-ws, r=alexcrichton
Browse files Browse the repository at this point in the history
Use canonical paths for checking equality
  • Loading branch information
bors committed Jan 10, 2017
2 parents 05f1ded + 083da14 commit 7060ca1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,16 @@ impl<'cfg> Workspace<'cfg> {
}

fn find_path_deps(&mut self, manifest_path: &Path) -> CargoResult<()> {
if self.members.iter().any(|p| p == manifest_path) {
let manifest_path = paths::normalize_path(manifest_path);
if self.members.iter().any(|p| p == &manifest_path) {
return Ok(())
}

debug!("find_members - {}", manifest_path.display());
self.members.push(manifest_path.to_path_buf());
self.members.push(manifest_path.clone());

let candidates = {
let pkg = match *self.packages.load(manifest_path)? {
let pkg = match *self.packages.load(&manifest_path)? {
MaybePackage::Package(ref p) => p,
MaybePackage::Virtual(_) => return Ok(()),
};
Expand Down
27 changes: 27 additions & 0 deletions tests/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,3 +1074,30 @@ fn error_if_parent_cargo_toml_is_invalid() {
.with_stderr_contains("\
[ERROR] failed to parse manifest at `[..]`"));
}

#[test]
fn relative_path_for_member_works() {
let p = project("foo")
.file("foo/Cargo.toml", r#"
[project]
name = "foo"
version = "0.1.0"
authors = []
[workspace]
members = ["../bar"]
"#)
.file("foo/src/main.rs", "fn main() {}")
.file("bar/Cargo.toml", r#"
[project]
name = "bar"
version = "0.1.0"
authors = []
workspace = "../foo"
"#)
.file("bar/src/main.rs", "fn main() {}");
p.build();

assert_that(p.cargo("build").cwd(p.root().join("foo")), execs().with_status(0));
assert_that(p.cargo("build").cwd(p.root().join("bar")), execs().with_status(0));
}

0 comments on commit 7060ca1

Please sign in to comment.