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
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
}
#[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) {
}
#[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();
}
}
#[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]}"#,
}
#[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)));
);
}
#[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(
"[]",
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
}, proc(_client) {
// drop the client
})
- } #[ignore(cfg(windows))]) // FIXME(#12516)
+ } #[cfg_attr(windows, ignore)]) // FIXME(#12516)
iotest!(fn write_begone() {
smalltest(proc(mut server) {
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) {
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();
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();
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();
}
#[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;
// 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
#[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()));
}
}
#[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.
#[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() {
is_show::<AllSet1Set2>();
is_show::<AnySet1Notset>();
is_show::<Complex>();
+ is_show::<KeyValue>();
}
}
}
fail!("never timed out!");
-} #[ignore(cfg(target_os = "freebsd"))])
+} #[cfg_attr(target_os = "freebsd", ignore)])
iotest!(fn timeout_success() {
let addr = next_test_ip4();