parse workspace manifests without member list

fixes #16
This commit is contained in:
Sam Reis 2018-02-12 13:39:37 +11:00
parent b0b9f35957
commit 9f384abdac

View file

@ -27,6 +27,7 @@ struct CargoTomlPackage {
#[derive(Serialize, Deserialize, Debug)]
struct CargoTomlWorkspace {
#[serde(default)]
members: Vec<RelativePathBuf>
}
@ -115,3 +116,34 @@ pub fn parse_manifest_toml(input: &str) -> Result<CrateManifest, Error> {
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")
}
}
}