diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index b784bdb713941..16cc1d2a565de 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -16,7 +16,7 @@ indexmap = "2.0.0" miropt-test-tools = { path = "../miropt-test-tools" } build_helper = { path = "../../build_helper" } tracing = "0.1" -tracing-subscriber = { version = "0.3.3", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] } +tracing-subscriber = { version = "0.3.3", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec"] } regex = "1.0" semver = { version = "1.0.23", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 6a4f0b96bb4de..108fde1c89955 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2809,29 +2809,6 @@ impl<'test> TestCx<'test> { println!("init_incremental_test: incremental_dir={}", incremental_dir.display()); } } - - 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) - } } struct ProcArgs { diff --git a/src/tools/compiletest/src/runtest/run_make.rs b/src/tools/compiletest/src/runtest/run_make.rs index 85ade5b727a3b..ee7aed2a39c15 100644 --- a/src/tools/compiletest/src/runtest/run_make.rs +++ b/src/tools/compiletest/src/runtest/run_make.rs @@ -2,6 +2,8 @@ use std::path::Path; use std::process::{Command, Output, Stdio}; use std::{env, fs}; +use build_helper::fs::{ignore_not_found, recursive_remove}; + use super::{ProcRes, TestCx, disable_error_reporting}; use crate::util::{copy_dir_all, dylib_env_var}; @@ -27,9 +29,8 @@ impl TestCx<'_> { // are hopefully going away, it seems safer to leave this perilous code // as-is until it can all be deleted. let tmpdir = cwd.join(self.output_base_name()); - if tmpdir.exists() { - self.aggressive_rm_rf(&tmpdir).unwrap(); - } + ignore_not_found(|| recursive_remove(&tmpdir)).unwrap(); + fs::create_dir_all(&tmpdir).unwrap(); let host = &self.config.host; @@ -218,9 +219,8 @@ impl TestCx<'_> { // // This setup intentionally diverges from legacy Makefile run-make tests. let base_dir = self.output_base_dir(); - if base_dir.exists() { - self.aggressive_rm_rf(&base_dir).unwrap(); - } + ignore_not_found(|| recursive_remove(&base_dir)).unwrap(); + let rmake_out_dir = base_dir.join("rmake_out"); fs::create_dir_all(&rmake_out_dir).unwrap();