Warn about missing [[lib]] and [[bin]] sections

Closes #120
This commit is contained in:
Alex Crichton 2014-07-05 17:10:23 -07:00
parent 6248ebe5b2
commit 03ccdd8169
3 changed files with 24 additions and 0 deletions

View File

@ -30,6 +30,10 @@ pub fn to_manifest(contents: &[u8],
Some(ref toml) => add_unused_keys(&mut manifest, toml, "".to_string()),
None => {}
}
if manifest.get_targets().len() == 0 {
return Err(human(format!("either a [[lib]] or [[bin]] section must \
be present")))
}
return Ok((manifest, paths));
fn add_unused_keys(m: &mut Manifest, toml: &toml::Value, key: String) {

View File

@ -766,3 +766,19 @@ test!(ignore_broken_symlinks {
process(p.bin("foo")),
execs().with_stdout("i am foo\n"));
})
test!(missing_lib_and_bin {
let mut p = project("foo");
p = p
.file("Cargo.toml", r#"
[package]
name = "test"
version = "0.0.0"
authors = []
"#);
assert_that(p.cargo_process("cargo-build"),
execs().with_status(101)
.with_stderr("either a [[lib]] or [[bin]] section \
must be present\n"));
})

View File

@ -493,6 +493,10 @@ test!(error_message_for_missing_manifest {
[dependencies.bar]
path = "src/bar"
[[lib]]
name = "foo"
"#)
.file("src/bar/not-a-manifest", "");