Skip to content

compiletest: aggressive_rm_rf might not be aggressive enough #126334

Description

@jieyouxu

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.

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    A-compiletestArea: The compiletest test runner
    A-run-makeArea: port run-make Makefiles to rmake.rs
    on Jun 12, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 12, 2024
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 12, 2024
  4. added a commit that references this issue on Aug 21, 2024
    33dc313
  5. added a commit that references this issue on Aug 22, 2024
    114d6b0
  6. added a commit that references this issue on Aug 22, 2024
    dc10160
  7. jieyouxu commented on Aug 22, 2024

    @jieyouxu
    MemberAuthor

    Re-opening due to revert #129413.

  8. self-assigned this
    on Aug 22, 2024
  9. jieyouxu commented on Dec 22, 2024

    @jieyouxu
    MemberAuthor

    compiletest triage: ironically this is not aggressive enough for Windows platforms either. For example, Windows distinguishes between symlink-to-file versus symlink-to-directory, and you need to use the matching remove_file and remove_dir respectively.

  10. changed the title [-]compiletest: `aggressive_rm_rf` might not be aggressive enough on non-Windows platforms[/-] [+]compiletest: `aggressive_rm_rf` might not be aggressive enough[/+] on Dec 22, 2024
  11. added a commit that references this issue on Dec 23, 2024
    fde85a8
  12. added a commit that references this issue on Dec 23, 2024
    633411b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-compiletestArea: The compiletest test runnerA-run-makeArea: port run-make Makefiles to rmake.rsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions