Skip to content

Commit 33dc313

Browse files
authored
Rollup merge of #129302 - jieyouxu:compiletest-RAGEY, r=compiler-errors
compiletest: use `std::fs::remove_dir_all` now that it is available It turns out `aggressive_rm_rf` is not sufficiently aggressive (RAGEY) on Windows and obviously handles Windows symlinks incorrectly. Instead of rolling our own version, let's use `std::fs::remove_dir_all` now that it's available (well, it's been available for a good while, but probably wasn't available when this helper was written). cc #129187 since basically this is failing due to similar problems. Blocker for #128562. Fixes #129155. Fixes #126334.
2 parents ade3325 + 75ed089 commit 33dc313

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

src/tools/compiletest/src/runtest.rs

+2-25
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,7 @@ impl<'test> TestCx<'test> {
32653265

32663266
let tmpdir = cwd.join(self.output_base_name());
32673267
if tmpdir.exists() {
3268-
self.aggressive_rm_rf(&tmpdir).unwrap();
3268+
fs::remove_dir_all(&tmpdir).unwrap();
32693269
}
32703270
create_dir_all(&tmpdir).unwrap();
32713271

@@ -3404,29 +3404,6 @@ impl<'test> TestCx<'test> {
34043404
}
34053405
}
34063406

3407-
fn aggressive_rm_rf(&self, path: &Path) -> io::Result<()> {
3408-
for e in path.read_dir()? {
3409-
let entry = e?;
3410-
let path = entry.path();
3411-
if entry.file_type()?.is_dir() {
3412-
self.aggressive_rm_rf(&path)?;
3413-
} else {
3414-
// Remove readonly files as well on windows (by default we can't)
3415-
fs::remove_file(&path).or_else(|e| {
3416-
if cfg!(windows) && e.kind() == io::ErrorKind::PermissionDenied {
3417-
let mut meta = entry.metadata()?.permissions();
3418-
meta.set_readonly(false);
3419-
fs::set_permissions(&path, meta)?;
3420-
fs::remove_file(&path)
3421-
} else {
3422-
Err(e)
3423-
}
3424-
})?;
3425-
}
3426-
}
3427-
fs::remove_dir(path)
3428-
}
3429-
34303407
fn run_rmake_v2_test(&self) {
34313408
// For `run-make` V2, we need to perform 2 steps to build and run a `run-make` V2 recipe
34323409
// (`rmake.rs`) to run the actual tests. The support library is already built as a tool rust
@@ -3475,7 +3452,7 @@ impl<'test> TestCx<'test> {
34753452
// This setup intentionally diverges from legacy Makefile run-make tests.
34763453
let base_dir = self.output_base_name();
34773454
if base_dir.exists() {
3478-
self.aggressive_rm_rf(&base_dir).unwrap();
3455+
fs::remove_dir_all(&base_dir).unwrap();
34793456
}
34803457
let rmake_out_dir = base_dir.join("rmake_out");
34813458
create_dir_all(&rmake_out_dir).unwrap();

0 commit comments

Comments
 (0)