From 9f384abdac012eb8cea9b1824431dd79c34364be Mon Sep 17 00:00:00 2001 From: Sam Reis Date: Mon, 12 Feb 2018 13:39:37 +1100 Subject: [PATCH] parse workspace manifests without member list fixes #16 --- src/parsers/manifest.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/parsers/manifest.rs b/src/parsers/manifest.rs index 0b4b969..c3a7b24 100644 --- a/src/parsers/manifest.rs +++ b/src/parsers/manifest.rs @@ -27,6 +27,7 @@ struct CargoTomlPackage { #[derive(Serialize, Deserialize, Debug)] struct CargoTomlWorkspace { + #[serde(default)] members: Vec } @@ -115,3 +116,34 @@ pub fn parse_manifest_toml(input: &str) -> Result { Err(format_err!("neither workspace nor package found in manifest")) } } + +#[cfg(test)] +mod tests { + use models::crates::CrateManifest; + use super::parse_manifest_toml; + + #[test] + fn parse_workspace_without_members_declaration() { + let toml = r#"[package] +name = "symbolic" + +[workspace] + +[dependencies] +symbolic-common = { version = "2.0.6", path = "common" } +"#; + + let manifest = parse_manifest_toml(toml).unwrap(); + + match manifest { + CrateManifest::Mixed { name, deps, members } => { + assert_eq!(name.as_ref(), "symbolic"); + assert_eq!(deps.main.len(), 1); + assert_eq!(deps.dev.len(), 0); + assert_eq!(deps.build.len(), 0); + assert_eq!(members.len(), 0); + }, + _ => panic!("expected mixed manifest") + } + } +}