-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #31360 - pitdicker:fs_tests_cleanup, r=alexcrichton
- use `symlink_file` and `symlink_dir` instead of the old `soft_link` - create a junction instead of a directory symlink for testing recursive_rmdir (as it causes the same troubles, but can be created by users without `SeCreateSymbolicLinkPrivilege`) - `remove_dir_all` was unable to remove directory symlinks and junctions - only run tests that create symlinks if we have the right permissions. - rename `Path2` to `Path` - remove the global `#[allow(deprecated)]` and outdated comments - After factoring out `create_junction()` from the test `directory_junctions_are_directories` and removing needlessly complex code, what I was left with was: ``` #[test] #[cfg(windows)] fn directory_junctions_are_directories() { use sys::fs::create_junction; let tmpdir = tmpdir(); let foo = tmpdir.join("foo"); let bar = tmpdir.join("bar"); fs::create_dir(&foo).unwrap(); check!(create_junction(&foo, &bar)); assert!(bar.metadata().unwrap().is_dir()); } ``` It test whether a junction is a directory instead of a reparse point. But it actually test the target of the junction (which is a directory if it exists) instead of the junction itself, which should always be a symlink. So this test is invalid, and I expect it only exists because the author was suprised by it. So I removed it. Some things that do not yet work right: - relative symlinks do not accept forward slashes - the conversion of paths for `create_junction` is hacky - `remove_dir_all` now messes with the internal data of `FileAttr` to be able to remove symlinks. We should add some method like `is_symlink_dir()` to it, so code outside the standard library can see the difference between file and directory symlinks too.
- Loading branch information
Showing
3 changed files
with
192 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.