@@ -1531,12 +1531,14 @@ mod tests {
1531
1531
TempDir ( ret)
1532
1532
}
1533
1533
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.
1539
1540
pub fn got_symlink_permission ( tmpdir : & TempDir ) -> bool {
1541
+ if cfg ! ( unix) { return true }
1540
1542
let link = tmpdir. join ( "some_hopefully_unique_link_name" ) ;
1541
1543
1542
1544
match symlink_file ( r"nonexisting_target" , link) {
@@ -1549,9 +1551,6 @@ mod tests {
1549
1551
}
1550
1552
}
1551
1553
}
1552
- #[ cfg( not( windows) ) ]
1553
- #[ allow( unused_variables) ]
1554
- pub fn got_symlink_permission ( tmpdir : & TempDir ) -> bool { true }
1555
1554
1556
1555
#[ test]
1557
1556
fn file_test_io_smoke_test ( ) {
@@ -2052,10 +2051,11 @@ mod tests {
2052
2051
let tmpdir = tmpdir ( ) ;
2053
2052
if !got_symlink_permission ( & tmpdir) { return } ;
2054
2053
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
2057
2056
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" ) ;
2059
2059
}
2060
2060
2061
2061
#[ test]
@@ -2423,7 +2423,8 @@ mod tests {
2423
2423
2424
2424
check ! ( symlink_junction( & target, & junction) ) ;
2425
2425
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
2427
2428
assert ! ( junction. is_dir( ) ) ;
2428
2429
assert ! ( b. exists( ) ) ;
2429
2430
0 commit comments