From 4b9c5d6878522a23d97db14ff85b6bdc6e2edd84 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 4 Nov 2013 20:33:42 -0800 Subject: [PATCH] Allow --cfg on rustpkg test Closes #10238 --- src/librustpkg/context.rs | 4 ++-- src/librustpkg/tests.rs | 13 +++++++++++++ 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 @@ -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");