Skip to content

Commit 65cca7c

Browse files
committed
Deprecate #[ignore(cfg(...))]
Replace `#[ignore(cfg(a, b))]` with `#[cfg_attr(all(a, b), ignore)]`
1 parent e520bb1 commit 65cca7c

File tree

17 files changed

+28
-20
lines changed

17 files changed

+28
-20
lines changed

src/doc/guide-testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ is not used.
7272
Tests that should not be run can be annotated with the `ignore`
7373
attribute. The existence of these tests will be noted in the test
7474
runner output, but the test will not be run. Tests can also be ignored
75-
by configuration so, for example, to ignore a test on windows you can
76-
write `#[ignore(cfg(target_os = "win32"))]`.
75+
by configuration using the `cfg_attr` attribute so, for example, to ignore a
76+
test on windows you can write `#[cfg_attr(windows, ignore)]`.
7777

7878
Tests that are intended to fail can be annotated with the
7979
`should_fail` attribute. The test will be run, and if it causes its

src/libnative/io/file_unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ mod tests {
506506
use std::os;
507507
use std::rt::rtio::{RtioFileStream, SeekSet};
508508

509-
#[ignore(cfg(target_os = "freebsd"))] // hmm, maybe pipes have a tiny buffer
509+
#[cfg_attr(target_os = "freebsd", ignore)] // hmm, maybe pipes have a tiny buffer
510510
#[test]
511511
fn test_file_desc() {
512512
// Run this test with some pipes so we don't have to mess around with

src/libnum/complex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ mod test {
219219
}
220220

221221
#[test]
222-
#[ignore(cfg(target_arch = "x86"))]
222+
#[cfg_attr(target_arch = "x86", ignore)]
223223
// FIXME #7158: (maybe?) currently failing on x86.
224224
fn test_norm() {
225225
fn test(c: Complex64, ns: f64) {

src/librustuv/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ mod test {
10851085
}
10861086

10871087
#[test]
1088-
#[ignore(cfg(windows))] // FIXME(#10102) server never sees second packet
1088+
#[cfg_attr(windows, ignore)] // FIXME(#10102) server never sees second packet
10891089
fn test_udp_twice() {
10901090
let server_addr = ::next_test_ip4();
10911091
let client_addr = ::next_test_ip4();

src/libserialize/json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,7 +3352,7 @@ mod tests {
33523352
}
33533353
}
33543354
#[test]
3355-
#[ignore(cfg(target_word_size = "32"))] // FIXME(#14064)
3355+
#[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
33563356
fn test_streaming_parser() {
33573357
assert_stream_equal(
33583358
r#"{ "foo":"bar", "array" : [0, 1, 2, 3, 4, 5], "idents":[null,true,false]}"#,
@@ -3388,7 +3388,7 @@ mod tests {
33883388
}
33893389

33903390
#[test]
3391-
#[ignore(cfg(target_word_size = "32"))] // FIXME(#14064)
3391+
#[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
33923392
fn test_read_object_streaming() {
33933393
assert_eq!(last_event("{ "), Error(SyntaxError(EOFWhileParsingObject, 1, 3)));
33943394
assert_eq!(last_event("{1"), Error(SyntaxError(KeyMustBeAString, 1, 2)));
@@ -3461,7 +3461,7 @@ mod tests {
34613461
);
34623462
}
34633463
#[test]
3464-
#[ignore(cfg(target_word_size = "32"))] // FIXME(#14064)
3464+
#[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
34653465
fn test_read_list_streaming() {
34663466
assert_stream_equal(
34673467
"[]",

src/libstd/dynamic_lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ mod test {
162162
use mem;
163163

164164
#[test]
165-
#[ignore(cfg(windows))] // FIXME #8818
166-
#[ignore(cfg(target_os="android"))] // FIXME(#10379)
165+
#[cfg_attr(any(windows, target_os = "android"), ignore)] // FIXME #8818, #10379
167166
fn test_loading_cosine() {
168167
// The math library does not need to be loaded since it is already
169168
// statically linked in

src/libstd/io/net/pipe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ mod tests {
320320
}, proc(_client) {
321321
// drop the client
322322
})
323-
} #[ignore(cfg(windows))]) // FIXME(#12516)
323+
} #[cfg_attr(windows, ignore)]) // FIXME(#12516)
324324

325325
iotest!(fn write_begone() {
326326
smalltest(proc(mut server) {

src/libstd/io/net/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ mod test {
533533
Ok(..) => fail!(),
534534
Err(e) => assert_eq!(e.kind, PermissionDenied),
535535
}
536-
} #[ignore(cfg(windows))] #[ignore(cfg(target_os = "android"))])
536+
} #[cfg_attr(any(windows, target_os = "android"), ignore)])
537537

538538
iotest!(fn connect_error() {
539539
match TcpStream::connect("0.0.0.0", 1) {

src/libstd/io/net/udp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ mod test {
273273
Ok(..) => fail!(),
274274
Err(e) => assert_eq!(e.kind, PermissionDenied),
275275
}
276-
} #[ignore(cfg(windows))] #[ignore(cfg(target_os = "android"))])
276+
} #[cfg_attr(any(windows, target_os = "android"), ignore)])
277277

278278
iotest!(fn socket_smoke_test_ip4() {
279279
let server_ip = next_test_ip4();

src/libstd/num/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ mod tests {
766766
assert_eq!((-0f32).frexp(), (-0f32, 0));
767767
}
768768

769-
#[test] #[ignore(cfg(windows))] // FIXME #8755
769+
#[test] #[cfg_attr(windows, ignore)] // FIXME #8755
770770
fn test_frexp_nowin() {
771771
let inf: f32 = Float::infinity();
772772
let neg_inf: f32 = Float::neg_infinity();

src/libstd/num/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ mod tests {
768768
assert_eq!((-0f64).frexp(), (-0f64, 0));
769769
}
770770

771-
#[test] #[ignore(cfg(windows))] // FIXME #8755
771+
#[test] #[cfg_attr(windows, ignore)] // FIXME #8755
772772
fn test_frexp_nowin() {
773773
let inf: f64 = Float::infinity();
774774
let neg_inf: f64 = Float::neg_infinity();

src/libsync/deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ mod tests {
600600
}
601601

602602
#[test]
603-
#[ignore(cfg(windows))] // apparently windows scheduling is weird?
603+
#[cfg_attr(windows, ignore)] // apparently windows scheduling is weird?
604604
fn no_starvation() {
605605
static AMT: int = 10000;
606606
static NTHREADS: int = 4;

src/libsyntax/test.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ fn is_ignored(cx: &TestCtxt, i: &ast::Item) -> bool {
339339
// check ignore(cfg(foo, bar))
340340
attr.check_name("ignore") && match attr.meta_item_list() {
341341
Some(ref cfgs) => {
342+
if cfgs.iter().any(|cfg| cfg.check_name("cfg")) {
343+
cx.sess.span_warn(attr.span,
344+
"The use of cfg filters in #[ignore] is \
345+
deprecated. Use #[cfg_attr(<cfg pattern>, \
346+
ignore)] instead.");
347+
}
342348
attr::test_cfg(cx.config.as_slice(), cfgs.iter())
343349
}
344350
None => true

src/libtest/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,7 @@ Test Attributes:
356356
#[ignore] - When applied to a function which is already attributed as a
357357
test, then the test runner will ignore these tests during
358358
normal test runs. Running with --ignored will run these
359-
tests. This may also be written as #[ignore(cfg(...))] to
360-
ignore the test on certain configurations.",
359+
tests.",
361360
usage = getopts::usage(message.as_slice(),
362361
optgroups().as_slice()));
363362
}

src/libtime/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ mod tests {
15641564
}
15651565

15661566
#[test]
1567-
#[ignore(cfg(target_os = "android"))] // FIXME #10958
1567+
#[cfg_attr(target_os = "android", ignore)] // FIXME #10958
15681568
fn run_tests() {
15691569
// The tests race on tzset. So instead of having many independent
15701570
// tests, we will just call the functions now.

src/test/run-pass/cfg_attr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ struct Complex;
4444
#[cfg_attr(any(notset, not(any(set1, notset))), deriving(Show))]
4545
struct ComplexNot(NotShowable);
4646

47+
#[cfg_attr(any(target_endian = "little", target_endian = "big"), deriving(Show))]
48+
struct KeyValue;
49+
4750
fn is_show<T: Show>() {}
4851

4952
fn main() {
@@ -52,4 +55,5 @@ fn main() {
5255
is_show::<AllSet1Set2>();
5356
is_show::<AnySet1Notset>();
5457
is_show::<Complex>();
58+
is_show::<KeyValue>();
5559
}

src/test/run-pass/tcp-connect-timeouts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ iotest!(fn eventual_timeout() {
8080
}
8181
}
8282
fail!("never timed out!");
83-
} #[ignore(cfg(target_os = "freebsd"))])
83+
} #[cfg_attr(target_os = "freebsd", ignore)])
8484

8585
iotest!(fn timeout_success() {
8686
let addr = next_test_ip4();

0 commit comments

Comments
 (0)