diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 9fd87e119906e..0a5d1153d860c 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1,24 +1,7 @@ use rand::RngCore; -#[cfg(any( - windows, - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "illumos", - target_vendor = "apple", -))] use crate::assert_matches::assert_matches; -#[cfg(any( - windows, - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "illumos", - target_vendor = "apple", -))] -use crate::fs::TryLockError; -use crate::fs::{self, File, FileTimes, OpenOptions}; +use crate::fs::{self, File, FileTimes, OpenOptions, TryLockError}; use crate::io::prelude::*; use crate::io::{BorrowedBuf, ErrorKind, SeekFrom}; use crate::mem::MaybeUninit; @@ -222,15 +205,22 @@ fn file_test_io_seek_and_write() { } #[test] -#[cfg(any( - windows, - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "solaris", - target_os = "illumos", - target_vendor = "apple", -))] +#[cfg_attr( + not(any( + windows, + target_os = "aix", + target_os = "cygwin", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris", + target_vendor = "apple", + )), + should_panic +)] fn file_lock_multiple_shared() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_lock_multiple_shared_test.txt"); @@ -247,15 +237,22 @@ fn file_lock_multiple_shared() { } #[test] -#[cfg(any( - windows, - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "solaris", - target_os = "illumos", - target_vendor = "apple", -))] +#[cfg_attr( + not(any( + windows, + target_os = "aix", + target_os = "cygwin", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris", + target_vendor = "apple", + )), + should_panic +)] fn file_lock_blocking() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_lock_blocking_test.txt"); @@ -273,15 +270,22 @@ fn file_lock_blocking() { } #[test] -#[cfg(any( - windows, - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "solaris", - target_os = "illumos", - target_vendor = "apple", -))] +#[cfg_attr( + not(any( + windows, + target_os = "aix", + target_os = "cygwin", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris", + target_vendor = "apple", + )), + should_panic +)] fn file_lock_drop() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_lock_dup_test.txt"); @@ -296,15 +300,22 @@ fn file_lock_drop() { } #[test] -#[cfg(any( - windows, - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "solaris", - target_os = "illumos", - target_vendor = "apple", -))] +#[cfg_attr( + not(any( + windows, + target_os = "aix", + target_os = "cygwin", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris", + target_vendor = "apple", + )), + should_panic +)] fn file_lock_dup() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_lock_dup_test.txt"); @@ -1252,7 +1263,7 @@ fn readlink_not_symlink() { } #[test] -#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks +#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")] fn links_work() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -1748,7 +1759,7 @@ fn metadata_access_times() { /// Test creating hard links to symlinks. #[test] -#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks +#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")] fn symlink_hard_link() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) {