@@ -1531,12 +1531,14 @@ mod tests {
15311531 TempDir ( ret)
15321532 }
15331533
1534- // Several test fail on windows if the user does not have permission to create symlinks (the
1535- // `SeCreateSymbolicLinkPrivilege`). Instead of disabling these test on Windows, use this
1536- // function to test whether we have permission, and return otherwise. This way, we still don't
1537- // run these tests most of the time, but at least we do if the user has the right permissions.
1538- #[ cfg( windows) ]
1534+ // Several test fail on windows if the user does not have permission to
1535+ // create symlinks (the `SeCreateSymbolicLinkPrivilege`). Instead of
1536+ // disabling these test on Windows, use this function to test whether we
1537+ // have permission, and return otherwise. This way, we still don't run these
1538+ // tests most of the time, but at least we do if the user has the right
1539+ // permissions.
15391540 pub fn got_symlink_permission ( tmpdir : & TempDir ) -> bool {
1541+ if cfg ! ( unix) { return true }
15401542 let link = tmpdir. join ( "some_hopefully_unique_link_name" ) ;
15411543
15421544 match symlink_file ( r"nonexisting_target" , link) {
@@ -1549,9 +1551,6 @@ mod tests {
15491551 }
15501552 }
15511553 }
1552- #[ cfg( not( windows) ) ]
1553- #[ allow( unused_variables) ]
1554- pub fn got_symlink_permission ( tmpdir : & TempDir ) -> bool { true }
15551554
15561555 #[ test]
15571556 fn file_test_io_smoke_test ( ) {
@@ -2052,10 +2051,11 @@ mod tests {
20522051 let tmpdir = tmpdir ( ) ;
20532052 if !got_symlink_permission ( & tmpdir) { return } ;
20542053
2055- // Use a relative path for testing. Symlinks get normalized by Windows, so we may not get
2056- // the same path back for absolute paths
2054+ // Use a relative path for testing. Symlinks get normalized by Windows,
2055+ // so we may not get the same path back for absolute paths
20572056 check ! ( symlink_file( & "foo" , & tmpdir. join( "bar" ) ) ) ;
2058- assert_eq ! ( check!( fs:: read_link( & tmpdir. join( "bar" ) ) ) . to_str( ) . unwrap( ) , "foo" ) ;
2057+ assert_eq ! ( check!( fs:: read_link( & tmpdir. join( "bar" ) ) ) . to_str( ) . unwrap( ) ,
2058+ "foo" ) ;
20592059 }
20602060
20612061 #[ test]
@@ -2423,7 +2423,8 @@ mod tests {
24232423
24242424 check ! ( symlink_junction( & target, & junction) ) ;
24252425 check ! ( fs:: create_dir_all( & b) ) ;
2426- // the junction itself is not a directory, but `is_dir()` on a Path follows links
2426+ // the junction itself is not a directory, but `is_dir()` on a Path
2427+ // follows links
24272428 assert ! ( junction. is_dir( ) ) ;
24282429 assert ! ( b. exists( ) ) ;
24292430
0 commit comments