about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustpkg/context.rs4
-rw-r--r--src/librustpkg/tests.rs13
2 files changed, 15 insertions, 2 deletions
diff --git a/src/librustpkg/context.rs b/src/librustpkg/context.rs
index 0ae08731546..3856f7f424d 100644
--- a/src/librustpkg/context.rs
+++ b/src/librustpkg/context.rs
@@ -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;
     }
 
diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs
index 6555fb88c90..b45e4ff1755 100644
--- a/src/librustpkg/tests.rs
+++ b/src/librustpkg/tests.rs
@@ -2099,6 +2099,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");
     let foo_workspace = create_local_package(&foo_id);