Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustpkg/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
13 changes: 13 additions & 0 deletions src/librustpkg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down