]> git.lizzy.rs Git - rust.git/commitdiff
Deprecate `#[ignore(cfg(...))]`
authorSteven Fackler <sfackler@gmail.com>
Mon, 4 Aug 2014 00:41:58 +0000 (17:41 -0700)
committerSteven Fackler <sfackler@gmail.com>
Wed, 24 Sep 2014 06:49:20 +0000 (23:49 -0700)
Replace `#[ignore(cfg(a, b))]` with `#[cfg_attr(all(a, b), ignore)]`

17 files changed:
src/doc/guide-testing.md
src/libnative/io/file_unix.rs
src/libnum/complex.rs
src/librustuv/net.rs
src/libserialize/json.rs
src/libstd/dynamic_lib.rs
src/libstd/io/net/pipe.rs
src/libstd/io/net/tcp.rs
src/libstd/io/net/udp.rs
src/libstd/num/f32.rs
src/libstd/num/f64.rs
src/libsync/deque.rs
src/libsyntax/test.rs
src/libtest/lib.rs
src/libtime/lib.rs
src/test/run-pass/cfg_attr.rs
src/test/run-pass/tcp-connect-timeouts.rs

index 6fb198fbd2ba4053aa3a809cfe1f6cca975732bc..07813855d9b9bb1e95a61bd7301f84c14c3927aa 100644 (file)
@@ -72,8 +72,8 @@ is not used.
 Tests that should not be run can be annotated with the `ignore`
 attribute. The existence of these tests will be noted in the test
 runner output, but the test will not be run. Tests can also be ignored
-by configuration so, for example, to ignore a test on windows you can
-write `#[ignore(cfg(target_os = "win32"))]`.
+by configuration using the `cfg_attr` attribute so, for example, to ignore a
+test on windows you can write `#[cfg_attr(windows, ignore)]`.
 
 Tests that are intended to fail can be annotated with the
 `should_fail` attribute. The test will be run, and if it causes its
index 3c49e1c40d63cc72eb0a1dfd286c894c6ac43c43..97d48df600ee4f1bc1d9b3d50560a752e46f6e35 100644 (file)
@@ -506,7 +506,7 @@ mod tests {
     use std::os;
     use std::rt::rtio::{RtioFileStream, SeekSet};
 
-    #[ignore(cfg(target_os = "freebsd"))] // hmm, maybe pipes have a tiny buffer
+    #[cfg_attr(target_os = "freebsd", ignore)] // hmm, maybe pipes have a tiny buffer
     #[test]
     fn test_file_desc() {
         // Run this test with some pipes so we don't have to mess around with
index 24c99a38bd91a0497a0044491e5bbeccde9c740c..0e70527cdca7965cc827e4e2fa368b7cc492dbc0 100644 (file)
@@ -219,7 +219,7 @@ fn test(c : Complex64, r : f64, i: f64) {
     }
 
     #[test]
-    #[ignore(cfg(target_arch = "x86"))]
+    #[cfg_attr(target_arch = "x86", ignore)]
     // FIXME #7158: (maybe?) currently failing on x86.
     fn test_norm() {
         fn test(c: Complex64, ns: f64) {
index d572d8ce58a53ef1b153b1c0de792587ac605140..3531d162db08115968eae31dde7f78cdd2c946cf 100644 (file)
@@ -1085,7 +1085,7 @@ fn test_read_read_read() {
     }
 
     #[test]
-    #[ignore(cfg(windows))] // FIXME(#10102) server never sees second packet
+    #[cfg_attr(windows, ignore)] // FIXME(#10102) server never sees second packet
     fn test_udp_twice() {
         let server_addr = ::next_test_ip4();
         let client_addr = ::next_test_ip4();
index 14274ef9f9b04f09ed76fe2f1c68e885b70bfc19..7cb448cf15c3abea0131f0bafde90853c29e7a11 100644 (file)
@@ -3352,7 +3352,7 @@ fn assert_stream_equal(src: &str,
         }
     }
     #[test]
-    #[ignore(cfg(target_word_size = "32"))] // FIXME(#14064)
+    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
     fn test_streaming_parser() {
         assert_stream_equal(
             r#"{ "foo":"bar", "array" : [0, 1, 2, 3, 4, 5], "idents":[null,true,false]}"#,
@@ -3388,7 +3388,7 @@ fn last_event(src: &str) -> JsonEvent {
     }
 
     #[test]
-    #[ignore(cfg(target_word_size = "32"))] // FIXME(#14064)
+    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
     fn test_read_object_streaming() {
         assert_eq!(last_event("{ "),      Error(SyntaxError(EOFWhileParsingObject, 1, 3)));
         assert_eq!(last_event("{1"),      Error(SyntaxError(KeyMustBeAString,      1, 2)));
@@ -3461,7 +3461,7 @@ fn test_read_object_streaming() {
         );
     }
     #[test]
-    #[ignore(cfg(target_word_size = "32"))] // FIXME(#14064)
+    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
     fn test_read_list_streaming() {
         assert_stream_equal(
             "[]",
index e8d570f30e614a808c845c456eed44376ec2fe99..a88448f47e0c6e9c62f3bfdc1e783242cba51ca4 100644 (file)
@@ -162,8 +162,7 @@ mod test {
     use mem;
 
     #[test]
-    #[ignore(cfg(windows))] // FIXME #8818
-    #[ignore(cfg(target_os="android"))] // FIXME(#10379)
+    #[cfg_attr(any(windows, target_os = "android"), ignore)] // FIXME #8818, #10379
     fn test_loading_cosine() {
         // The math library does not need to be loaded since it is already
         // statically linked in
index bdd58b07d8615bcb6015dd7ed481834af0f03cb3..9faa018237245c5e651409c1a9715523e625a412 100644 (file)
@@ -320,7 +320,7 @@ pub fn smalltest(server: proc(UnixStream):Send, client: proc(UnixStream):Send) {
         }, proc(_client) {
             // drop the client
         })
-    } #[ignore(cfg(windows))]) // FIXME(#12516)
+    } #[cfg_attr(windows, ignore)]) // FIXME(#12516)
 
     iotest!(fn write_begone() {
         smalltest(proc(mut server) {
index d787f0e98541c703c81bb914a5a17005b72f69b9..65d8f1c9c776458c4dbfa98dbd254d31ba4a256f 100644 (file)
@@ -533,7 +533,7 @@ mod test {
             Ok(..) => fail!(),
             Err(e) => assert_eq!(e.kind, PermissionDenied),
         }
-    } #[ignore(cfg(windows))] #[ignore(cfg(target_os = "android"))])
+    } #[cfg_attr(any(windows, target_os = "android"), ignore)])
 
     iotest!(fn connect_error() {
         match TcpStream::connect("0.0.0.0", 1) {
index 6689615f01b222bae527fd9dbc50ac68de611c3a..9718ceb1185551123692a928337841ffa91a91f1 100644 (file)
@@ -273,7 +273,7 @@ mod test {
             Ok(..) => fail!(),
             Err(e) => assert_eq!(e.kind, PermissionDenied),
         }
-    } #[ignore(cfg(windows))] #[ignore(cfg(target_os = "android"))])
+    } #[cfg_attr(any(windows, target_os = "android"), ignore)])
 
     iotest!(fn socket_smoke_test_ip4() {
         let server_ip = next_test_ip4();
index d91f5579c0d7a77162d922c0d9c030fc98020255..b2a9f1b7b20d338211899ab8d796d59bd2741d77 100644 (file)
@@ -766,7 +766,7 @@ fn test_frexp() {
         assert_eq!((-0f32).frexp(), (-0f32, 0));
     }
 
-    #[test] #[ignore(cfg(windows))] // FIXME #8755
+    #[test] #[cfg_attr(windows, ignore)] // FIXME #8755
     fn test_frexp_nowin() {
         let inf: f32 = Float::infinity();
         let neg_inf: f32 = Float::neg_infinity();
index d8d118a6721d9a3f8166eefb69a7060a1bc80311..6fe9fcad2aad7c177a8db243ad603d967e0ab6a2 100644 (file)
@@ -768,7 +768,7 @@ fn test_frexp() {
         assert_eq!((-0f64).frexp(), (-0f64, 0));
     }
 
-    #[test] #[ignore(cfg(windows))] // FIXME #8755
+    #[test] #[cfg_attr(windows, ignore)] // FIXME #8755
     fn test_frexp_nowin() {
         let inf: f64 = Float::infinity();
         let neg_inf: f64 = Float::neg_infinity();
index 6204b54fba4be48bb9799c5886d88adf27a8a3a5..15c0c14b28a86d587f75d2c48c9550f2d944237f 100644 (file)
@@ -600,7 +600,7 @@ fn stress() {
     }
 
     #[test]
-    #[ignore(cfg(windows))] // apparently windows scheduling is weird?
+    #[cfg_attr(windows, ignore)] // apparently windows scheduling is weird?
     fn no_starvation() {
         static AMT: int = 10000;
         static NTHREADS: int = 4;
index f0e697127149f3ab924631837432d2f663df94ce..b6e3023d2ae3a944f67733ec0cf8df62f4d28c5c 100644 (file)
@@ -339,6 +339,12 @@ fn is_ignored(cx: &TestCtxt, i: &ast::Item) -> bool {
         // check ignore(cfg(foo, bar))
         attr.check_name("ignore") && match attr.meta_item_list() {
             Some(ref cfgs) => {
+                if cfgs.iter().any(|cfg| cfg.check_name("cfg")) {
+                    cx.sess.span_warn(attr.span,
+                            "The use of cfg filters in #[ignore] is \
+                             deprecated. Use #[cfg_attr(<cfg pattern>, \
+                             ignore)] instead.");
+                }
                 attr::test_cfg(cx.config.as_slice(), cfgs.iter())
             }
             None => true
index 43a1899f45e0861285431e437212ac19d7dc6890..04489d780278dbc3245afbe71078a5676072ba9b 100644 (file)
@@ -356,8 +356,7 @@ fn usage(binary: &str) {
     #[ignore]      - When applied to a function which is already attributed as a
                      test, then the test runner will ignore these tests during
                      normal test runs. Running with --ignored will run these
-                     tests. This may also be written as #[ignore(cfg(...))] to
-                     ignore the test on certain configurations.",
+                     tests.",
              usage = getopts::usage(message.as_slice(),
                                     optgroups().as_slice()));
 }
index abf6fc5f2558cfb660bdf64797b106e981ec43d2..9cec71104d403f3efe66f7784dabfb37f7e4070f 100644 (file)
@@ -1564,7 +1564,7 @@ fn test_timespec_sub() {
     }
 
     #[test]
-    #[ignore(cfg(target_os = "android"))] // FIXME #10958
+    #[cfg_attr(target_os = "android", ignore)] // FIXME #10958
     fn run_tests() {
         // The tests race on tzset. So instead of having many independent
         // tests, we will just call the functions now.
index 4f579cd75fee3c7d6b6b179cc2fe5dd2f4dcc8a3..15d3f4a04d57ae6bb1e4186d884ed6a1f29c7605 100644 (file)
@@ -44,6 +44,9 @@
 #[cfg_attr(any(notset, not(any(set1, notset))), deriving(Show))]
 struct ComplexNot(NotShowable);
 
+#[cfg_attr(any(target_endian = "little", target_endian = "big"), deriving(Show))]
+struct KeyValue;
+
 fn is_show<T: Show>() {}
 
 fn main() {
@@ -52,4 +55,5 @@ fn main() {
     is_show::<AllSet1Set2>();
     is_show::<AnySet1Notset>();
     is_show::<Complex>();
+    is_show::<KeyValue>();
 }
index c1d93033ab6fea9ef85430d51f413c7e30c91402..00906004dbfb0cc06cb27d85ef1037ee511f7dc4 100644 (file)
@@ -80,7 +80,7 @@ fn f() $b
         }
     }
     fail!("never timed out!");
-} #[ignore(cfg(target_os = "freebsd"))])
+} #[cfg_attr(target_os = "freebsd", ignore)])
 
 iotest!(fn timeout_success() {
     let addr = next_test_ip4();