compiletest: `aggressive_rm_rf` might not be aggressive enough
| fn aggressive_rm_rf(&self, path: &Path) -> io::Result<()> { | |
| for e in path.read_dir()? { | |
| let entry = e?; | |
| let path = entry.path(); | |
| if entry.file_type()?.is_dir() { | |
| self.aggressive_rm_rf(&path)?; | |
| } else { | |
| // Remove readonly files as well on windows (by default we can't) | |
| fs::remove_file(&path).or_else(|e| { | |
| if cfg!(windows) && e.kind() == io::ErrorKind::PermissionDenied { | |
| let mut meta = entry.metadata()?.permissions(); | |
| meta.set_readonly(false); | |
| fs::set_permissions(&path, meta)?; | |
| fs::remove_file(&path) | |
| } else { | |
| Err(e) | |
| } | |
| })?; | |
| } | |
| } | |
| fs::remove_dir(path) | |
| } |
aggressive_rm_rf seems to only account for read-only files in Windows (and tries really hard to rm -rf), but does not try as hard on Linux or macOS or other non-Windows platforms. This can pose issues to tests that modifies file or folder permissions in one way or another that could cause fs::remove_file to fail, which can lead to artifacts lingering around and cause tests results to not be reproducible.