Check for the existence of Cargo.toml when reading packages.

Fixes #82.
This commit is contained in:
Huon Wilson 2014-06-28 19:25:32 +10:00
parent 97d1d358af
commit c0865e85e3
2 changed files with 26 additions and 2 deletions

View File

@ -1,7 +1,7 @@
use std::io::File;
use util;
use core::{Package,Manifest,SourceId};
use util::{CargoResult, human};
use util::{CargoResult, human, important_paths};
pub fn read_manifest(contents: &[u8], source_id: &SourceId)
-> CargoResult<(Manifest, Vec<Path>)>
@ -24,7 +24,8 @@ pub fn read_package(path: &Path, source_id: &SourceId)
pub fn read_packages(path: &Path, source_id: &SourceId)
-> CargoResult<Vec<Package>>
{
let (pkg, nested) = try!(read_package(&path.join("Cargo.toml"), source_id));
let manifest = try!(important_paths::find_project_manifest_exact(path, "Cargo.toml"));
let (pkg, nested) = try!(read_package(&manifest, source_id));
let mut ret = vec!(pkg);
for p in nested.iter() {

View File

@ -354,3 +354,26 @@ test!(nested_deps_recompile {
FRESH, bar.display(),
COMPILING, p.root().display())));
})
test!(error_message_for_missing_manifest {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[dependencies.bar]
path = "src/bar"
"#)
.file("src/bar/not-a-manifest", "");
assert_that(p.cargo_process("cargo-build"),
execs()
.with_status(101)
.with_stderr(format!("Could not find `Cargo.toml` in `{}`\n",
p.root().join_many(&["src", "bar"]).display())));
})