rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.71k stars 12.5k forks source link

run-make: fix `run_make_support::fs::create_symlink` API and audit symlink usages in rmake.rs tests #129389

Open jieyouxu opened 3 weeks ago

jieyouxu commented 3 weeks ago

I need to revisit run_make_support::fs::create_symlink because it's a wrong abstraction: there's a good reason why symlink_file/symlink_dir are different operations under std::os::windows::fs.

Furthermore, I need to double-check our symlink handling in rmake.rs tests. It's ok if symlinks are removed via fs::remove_dir_all because that has special handling for symlinks on Windows, but need to be extra careful if symlinks are attempted to be removed with fs::{remove_file, remove_dir} if the test can be run on Windows.

ChrisDenton commented 3 weeks ago

For convenience, there could be run_make_support::fs::remove_symlink that, on Windows, checks whether the symlink is a file or dir and uses the right remove function automagically.

Or the run-make remove_file function could lean in to people's expectations and test if the file is a is_symlink_dir and use the std remove_dir function.