Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,7 @@ impl<'test> TestCx<'test> {

let tmpdir = cwd.join(self.output_base_name());
if tmpdir.exists() {
self.aggressive_rm_rf(&tmpdir).unwrap();
fs::remove_dir_all(&tmpdir).unwrap();
}
create_dir_all(&tmpdir).unwrap();

Expand Down Expand Up @@ -3404,29 +3404,6 @@ impl<'test> TestCx<'test> {
}
}

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)
}
})?;
Comment on lines -3414 to -3424
Copy link
Member Author

@jieyouxu jieyouxu Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: cc #128562 (comment) for why this is wrong with respect to Windows symlinks.

}
}
fs::remove_dir(path)
}

fn run_rmake_v2_test(&self) {
// For `run-make` V2, we need to perform 2 steps to build and run a `run-make` V2 recipe
// (`rmake.rs`) to run the actual tests. The support library is already built as a tool rust
Expand Down Expand Up @@ -3475,7 +3452,7 @@ impl<'test> TestCx<'test> {
// This setup intentionally diverges from legacy Makefile run-make tests.
let base_dir = self.output_base_name();
if base_dir.exists() {
self.aggressive_rm_rf(&base_dir).unwrap();
fs::remove_dir_all(&base_dir).unwrap();
}
let rmake_out_dir = base_dir.join("rmake_out");
create_dir_all(&rmake_out_dir).unwrap();
Expand Down
Loading