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

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