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
12 changes: 6 additions & 6 deletions src/cargo/ops/cargo_read_manifest.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::collections::HashSet;
use std::collections::{HashMap, HashSet};
use std::fs::{self, File};
use std::io::prelude::*;
use std::io;
use std::path::{Path, PathBuf};

use core::{Package,Manifest,SourceId};
use core::{Package, Manifest, SourceId, PackageId};
use util::{self, CargoResult, human, Config, ChainError};
use util::important_paths::find_project_manifest_exact;
use util::toml::{Layout, project_layout};
Expand Down Expand Up @@ -35,7 +35,7 @@ pub fn read_package(path: &Path, source_id: &SourceId, config: &Config)

pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
-> CargoResult<Vec<Package>> {
let mut all_packages = HashSet::new();
let mut all_packages = HashMap::new();
let mut visited = HashSet::<PathBuf>::new();

trace!("looking for root package: {}, source_id={}", path.display(), source_id);
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
if all_packages.is_empty() {
Err(human(format!("Could not find Cargo.toml in `{}`", path.display())))
} else {
Ok(all_packages.into_iter().collect())
Ok(all_packages.into_iter().map(|(_, v)| v).collect())
}
}

Expand Down Expand Up @@ -103,7 +103,7 @@ fn has_manifest(path: &Path) -> bool {
}

fn read_nested_packages(path: &Path,
all_packages: &mut HashSet<Package>,
all_packages: &mut HashMap<PackageId, Package>,
source_id: &SourceId,
config: &Config,
visited: &mut HashSet<PathBuf>) -> CargoResult<()> {
Expand All @@ -112,7 +112,7 @@ fn read_nested_packages(path: &Path,
let manifest = try!(find_project_manifest_exact(path, "Cargo.toml"));

let (pkg, nested) = try!(read_package(&manifest, source_id, config));
all_packages.insert(pkg);
all_packages.insert(pkg.package_id().clone(), pkg);

// Registry sources are not allowed to have `path=` dependencies because
// they're all translated to actual registry dependencies.
Expand Down
41 changes: 41 additions & 0 deletions tests/test_cargo_compile_path_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,3 +793,44 @@ test!(custom_target_no_rebuild {
{compiling} b v0.5.0 ([..])
", compiling = COMPILING)));
});

test!(override_and_depend {
let p = project("foo")
.file("a/a1/Cargo.toml", r#"
[project]
name = "a1"
version = "0.5.0"
authors = []
[dependencies]
a2 = { path = "../a2" }
"#)
.file("a/a1/src/lib.rs", "")
.file("a/a2/Cargo.toml", r#"
[project]
name = "a2"
version = "0.5.0"
authors = []
"#)
.file("a/a2/src/lib.rs", "")
.file("b/Cargo.toml", r#"
[project]
name = "b"
version = "0.5.0"
authors = []
[dependencies]
a1 = { path = "../a/a1" }
a2 = { path = "../a/a2" }
"#)
.file("b/src/lib.rs", "")
.file("b/.cargo/config", r#"
paths = ["../a"]
"#);
p.build();
assert_that(p.cargo("build").cwd(p.root().join("b")),
execs().with_status(0)
.with_stdout(&format!("\
{compiling} a2 v0.5.0 ([..])
{compiling} a1 v0.5.0 ([..])
{compiling} b v0.5.0 ([..])
", compiling = COMPILING)));
});