Skip to content
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
17 changes: 12 additions & 5 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ impl<'cfg> Workspace<'cfg> {
/// if some other transient error happens.
fn find_root(&mut self, manifest_path: &Path)
-> CargoResult<Option<PathBuf>> {
fn read_root_pointer(member_manifest: &Path, root_link: &str) -> CargoResult<PathBuf> {
let path = member_manifest.parent().unwrap()
.join(root_link)
.join("Cargo.toml");
debug!("find_root - pointer {}", path.display());
return Ok(paths::normalize_path(&path))
};

{
let current = self.packages.load(&manifest_path)?;
match *current.workspace_config() {
Expand All @@ -238,11 +246,7 @@ impl<'cfg> Workspace<'cfg> {
return Ok(Some(manifest_path.to_path_buf()))
}
WorkspaceConfig::Member { root: Some(ref path_to_root) } => {
let path = manifest_path.parent().unwrap()
.join(path_to_root)
.join("Cargo.toml");
debug!("find_root - pointer {}", path.display());
return Ok(Some(paths::normalize_path(&path)))
return Ok(Some(read_root_pointer(manifest_path, path_to_root)?))
}
WorkspaceConfig::Member { root: None } => {}
}
Expand All @@ -258,6 +262,9 @@ impl<'cfg> Workspace<'cfg> {
debug!("find_root - found");
return Ok(Some(manifest))
}
WorkspaceConfig::Member { root: Some(ref path_to_root) } => {
return Ok(Some(read_root_pointer(&manifest, path_to_root)?))
}
WorkspaceConfig::Member { .. } => {}
}
}
Expand Down
7 changes: 3 additions & 4 deletions tests/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,8 +1227,7 @@ fn test_path_dependency_under_member() {

assert_that(p.cargo("build").cwd(p.root().join("foo/bar")),
execs().with_status(0));
// Ideally, `foo/bar` should be a member of the workspace,
// because it is hierarchically under the workspace member.
assert_that(&p.root().join("foo/bar/Cargo.lock"), existing_file());
assert_that(&p.root().join("foo/bar/target"), existing_dir());

assert_that(&p.root().join("foo/bar/Cargo.lock"), is_not(existing_file()));
assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir()));
}