auto merge of #10282 : sfackler/rust/rustpkg-test-cfg, r=alexcrichton

Closes #10238
This commit is contained in:
bors 2013-11-05 00:07:20 -08:00
commit 379bda9e52
2 changed files with 15 additions and 2 deletions

View File

@ -252,8 +252,8 @@ pub fn flags_forbidden_for_cmd(flags: &RustcFlags,
return true;
}
if !cfgs.is_empty() && cmd != "build" && cmd != "install" {
println("The --cfg option can only be used with the build or install commands.");
if !cfgs.is_empty() && cmd != "build" && cmd != "install" && cmd != "test" {
println("The --cfg option can only be used with the build, test, or install commands.");
return true;
}

View File

@ -2098,6 +2098,19 @@ fn test_rustpkg_test_failure_exit_status() {
}
}
#[test]
fn test_rustpkg_test_cfg() {
let foo_id = PkgId::new("foo");
let foo_workspace = create_local_package(&foo_id);
let foo_workspace = foo_workspace.path();
writeFile(&foo_workspace.join_many(["src", "foo-0.1", "test.rs"]),
"#[test] #[cfg(not(foobar))] fn f() { assert!('a' != 'a'); }");
let output = command_line_test([~"test", ~"--cfg", ~"foobar", ~"foo"],
foo_workspace);
let output_str = str::from_utf8(output.output);
assert!(output_str.contains("0 passed; 0 failed; 0 ignored; 0 measured"));
}
#[test]
fn test_rebuild_when_needed() {
let foo_id = PkgId::new("foo");