From: Aleksey Kladov Date: Thu, 15 Dec 2016 17:27:48 +0000 (+0300) Subject: Don't ignore errors in workspace manifest X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~11^2~77^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6d7049218a3f04cf3063067c356ea178d813601c;p=cargo.git Don't ignore errors in workspace manifest --- diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index d0b0fdeec..c396755e8 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -242,8 +242,8 @@ impl<'cfg> Workspace<'cfg> { while let Some(path) = cur { let manifest = path.join("Cargo.toml"); debug!("find_root - trying {}", manifest.display()); - if let Ok(pkg) = self.packages.load(&manifest) { - match *pkg.workspace_config() { + if manifest.exists() { + match *self.packages.load(&manifest)?.workspace_config() { WorkspaceConfig::Root { .. } => { debug!("find_root - found"); return Ok(Some(manifest)) diff --git a/tests/workspaces.rs b/tests/workspaces.rs index 579dfa0db..8204e6c34 100644 --- a/tests/workspaces.rs +++ b/tests/workspaces.rs @@ -1055,3 +1055,22 @@ fn workspace_with_transitive_dev_deps() { assert_that(p.cargo("test").args(&["-p", "bar"]), execs().with_status(0)); } + +#[test] +fn error_if_parent_cargo_toml_is_invalid() { + let p = project("foo") + .file("Cargo.toml", "Totally not a TOML file") + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("bar/src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo("build").cwd(p.root().join("bar")), + execs().with_status(101) + .with_stderr_contains("\ +[ERROR] failed to parse manifest at `[..]`")); +}