Skip to content

Commit 4b9c5d6

Browse files
committed
Allow --cfg on rustpkg test
Closes #10238
1 parent 72e432d commit 4b9c5d6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/librustpkg/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ pub fn flags_forbidden_for_cmd(flags: &RustcFlags,
252252
return true;
253253
}
254254

255-
if !cfgs.is_empty() && cmd != "build" && cmd != "install" {
256-
println("The --cfg option can only be used with the build or install commands.");
255+
if !cfgs.is_empty() && cmd != "build" && cmd != "install" && cmd != "test" {
256+
println("The --cfg option can only be used with the build, test, or install commands.");
257257
return true;
258258
}
259259

src/librustpkg/tests.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,19 @@ fn test_rustpkg_test_failure_exit_status() {
20982098
}
20992099
}
21002100
2101+
#[test]
2102+
fn test_rustpkg_test_cfg() {
2103+
let foo_id = PkgId::new("foo");
2104+
let foo_workspace = create_local_package(&foo_id);
2105+
let foo_workspace = foo_workspace.path();
2106+
writeFile(&foo_workspace.join_many(["src", "foo-0.1", "test.rs"]),
2107+
"#[test] #[cfg(not(foobar))] fn f() { assert!('a' != 'a'); }");
2108+
let output = command_line_test([~"test", ~"--cfg", ~"foobar", ~"foo"],
2109+
foo_workspace);
2110+
let output_str = str::from_utf8(output.output);
2111+
assert!(output_str.contains("0 passed; 0 failed; 0 ignored; 0 measured"));
2112+
}
2113+
21012114
#[test]
21022115
fn test_rebuild_when_needed() {
21032116
let foo_id = PkgId::new("foo");

0 commit comments

Comments
 (0)