@@ -1913,77 +1913,3 @@ fn test_hidden_file_truncation() {
1913
1913
let metadata = file. metadata ( ) . unwrap ( ) ;
1914
1914
assert_eq ! ( metadata. len( ) , 0 ) ;
1915
1915
}
1916
-
1917
- // See https://github.com/rust-lang/rust/pull/131072 for more details about why
1918
- // these two tests are disabled under Windows 7 here.
1919
- #[ cfg( windows) ]
1920
- #[ test]
1921
- #[ cfg_attr( target_vendor = "win7" , ignore = "Unsupported under Windows 7." ) ]
1922
- fn test_rename_file_over_open_file ( ) {
1923
- // Make sure that std::fs::rename works if the target file is already opened with FILE_SHARE_DELETE. See #123985.
1924
- let tmpdir = tmpdir ( ) ;
1925
-
1926
- // Create source with test data to read.
1927
- let source_path = tmpdir. join ( "source_file.txt" ) ;
1928
- fs:: write ( & source_path, b"source hello world" ) . unwrap ( ) ;
1929
-
1930
- // Create target file with test data to read;
1931
- let target_path = tmpdir. join ( "target_file.txt" ) ;
1932
- fs:: write ( & target_path, b"target hello world" ) . unwrap ( ) ;
1933
-
1934
- // Open target file
1935
- let target_file = fs:: File :: open ( & target_path) . unwrap ( ) ;
1936
-
1937
- // Rename source
1938
- fs:: rename ( source_path, & target_path) . unwrap ( ) ;
1939
-
1940
- core:: mem:: drop ( target_file) ;
1941
- assert_eq ! ( fs:: read( target_path) . unwrap( ) , b"source hello world" ) ;
1942
- }
1943
-
1944
- #[ test]
1945
- #[ cfg( windows) ]
1946
- #[ cfg_attr( target_vendor = "win7" , ignore = "Unsupported under Windows 7." ) ]
1947
- fn test_rename_directory_to_non_empty_directory ( ) {
1948
- // Renaming a directory over a non-empty existing directory should fail on Windows.
1949
- let tmpdir: TempDir = tmpdir ( ) ;
1950
-
1951
- let source_path = tmpdir. join ( "source_directory" ) ;
1952
- let target_path = tmpdir. join ( "target_directory" ) ;
1953
-
1954
- fs:: create_dir ( & source_path) . unwrap ( ) ;
1955
- fs:: create_dir ( & target_path) . unwrap ( ) ;
1956
-
1957
- fs:: write ( target_path. join ( "target_file.txt" ) , b"target hello world" ) . unwrap ( ) ;
1958
-
1959
- error ! ( fs:: rename( source_path, target_path) , 145 ) ; // ERROR_DIR_NOT_EMPTY
1960
- }
1961
-
1962
- #[ test]
1963
- fn test_rename_symlink ( ) {
1964
- let tmpdir = tmpdir ( ) ;
1965
- let original = tmpdir. join ( "original" ) ;
1966
- let dest = tmpdir. join ( "dest" ) ;
1967
- let not_exist = Path :: new ( "does not exist" ) ;
1968
-
1969
- symlink_file ( not_exist, & original) . unwrap ( ) ;
1970
- fs:: rename ( & original, & dest) . unwrap ( ) ;
1971
- // Make sure that renaming `original` to `dest` preserves the symlink.
1972
- assert_eq ! ( fs:: read_link( & dest) . unwrap( ) . as_path( ) , not_exist) ;
1973
- }
1974
-
1975
- #[ test]
1976
- #[ cfg( windows) ]
1977
- fn test_rename_junction ( ) {
1978
- let tmpdir = tmpdir ( ) ;
1979
- let original = tmpdir. join ( "original" ) ;
1980
- let dest = tmpdir. join ( "dest" ) ;
1981
- let not_exist = Path :: new ( "does not exist" ) ;
1982
-
1983
- junction_point ( & not_exist, & original) . unwrap ( ) ;
1984
- fs:: rename ( & original, & dest) . unwrap ( ) ;
1985
-
1986
- // Make sure that renaming `original` to `dest` preserves the junction point.
1987
- // Junction links are always absolute so we just check the file name is correct.
1988
- assert_eq ! ( fs:: read_link( & dest) . unwrap( ) . file_name( ) , Some ( not_exist. as_os_str( ) ) ) ;
1989
- }
0 commit comments