From a09712e0d2e2a17c6d11377e9d14e080b75ac952 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 14 Jan 2023 12:36:56 +0000 Subject: [PATCH] Use fs::remove_dir_all instead of cargo clean --- build_system/tests.rs | 17 +++++++---------- build_system/utils.rs | 5 ++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/build_system/tests.rs b/build_system/tests.rs index 4d638a4eced1..4203a3859e1a 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -119,7 +119,7 @@ const fn jit_bin(config: &'static str, source: &'static str, args: &'static str) const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ TestCase::custom("test.rust-random/rand", &|runner| { - spawn_and_wait(RAND.clean(&runner.target_compiler.cargo, &runner.dirs)); + RAND.clean(&runner.dirs); if runner.is_native { eprintln!("[TEST] rust-random/rand"); @@ -134,11 +134,11 @@ const fn jit_bin(config: &'static str, source: &'static str, args: &'static str) } }), TestCase::custom("test.simple-raytracer", &|runner| { - spawn_and_wait(SIMPLE_RAYTRACER.clean(&runner.host_compiler.cargo, &runner.dirs)); + SIMPLE_RAYTRACER.clean(&runner.dirs); spawn_and_wait(SIMPLE_RAYTRACER.build(&runner.target_compiler, &runner.dirs)); }), TestCase::custom("test.libcore", &|runner| { - spawn_and_wait(LIBCORE_TESTS.clean(&runner.host_compiler.cargo, &runner.dirs)); + LIBCORE_TESTS.clean(&runner.dirs); if runner.is_native { spawn_and_wait(LIBCORE_TESTS.test(&runner.target_compiler, &runner.dirs)); @@ -150,7 +150,7 @@ const fn jit_bin(config: &'static str, source: &'static str, args: &'static str) } }), TestCase::custom("test.regex-shootout-regex-dna", &|runner| { - spawn_and_wait(REGEX.clean(&runner.target_compiler.cargo, &runner.dirs)); + REGEX.clean(&runner.dirs); // newer aho_corasick versions throw a deprecation warning let lint_rust_flags = format!("{} --cap-lints warn", runner.target_compiler.rustflags); @@ -194,7 +194,7 @@ const fn jit_bin(config: &'static str, source: &'static str, args: &'static str) } }), TestCase::custom("test.regex", &|runner| { - spawn_and_wait(REGEX.clean(&runner.host_compiler.cargo, &runner.dirs)); + REGEX.clean(&runner.dirs); // newer aho_corasick versions throw a deprecation warning let lint_rust_flags = format!("{} --cap-lints warn", runner.target_compiler.rustflags); @@ -221,7 +221,7 @@ const fn jit_bin(config: &'static str, source: &'static str, args: &'static str) } }), TestCase::custom("test.portable-simd", &|runner| { - spawn_and_wait(PORTABLE_SIMD.clean(&runner.host_compiler.cargo, &runner.dirs)); + PORTABLE_SIMD.clean(&runner.dirs); let mut build_cmd = PORTABLE_SIMD.build(&runner.target_compiler, &runner.dirs); build_cmd.arg("--all-targets"); @@ -293,7 +293,6 @@ struct TestRunner { is_native: bool, jit_supported: bool, dirs: Dirs, - host_compiler: Compiler, target_compiler: Compiler, } @@ -303,8 +302,6 @@ pub fn new(dirs: Dirs, host_triple: String, target_triple: String) -> Self { let jit_supported = is_native && host_triple.contains("x86_64") && !host_triple.contains("windows"); - let host_compiler = Compiler::clif_with_triple(&dirs, host_triple); - let mut target_compiler = Compiler::clif_with_triple(&dirs, target_triple); if !is_native { target_compiler.set_cross_linker_and_runner(); @@ -323,7 +320,7 @@ pub fn new(dirs: Dirs, host_triple: String, target_triple: String) -> Self { target_compiler.rustflags.push_str(" -Clink-arg=-undefined -Clink-arg=dynamic_lookup"); } - Self { is_native, jit_supported, dirs, host_compiler, target_compiler } + Self { is_native, jit_supported, dirs, target_compiler } } pub fn run_testsuite(&self, tests: &[TestCase]) { diff --git a/build_system/utils.rs b/build_system/utils.rs index f2b1fecedc16..935177a00ba8 100644 --- a/build_system/utils.rs +++ b/build_system/utils.rs @@ -146,9 +146,8 @@ pub(crate) fn fetch(&self, cargo: impl AsRef, dirs: &Dirs) -> Command { cmd } - #[must_use] - pub(crate) fn clean(&self, cargo: &Path, dirs: &Dirs) -> Command { - self.base_cmd("clean", cargo, dirs) + pub(crate) fn clean(&self, dirs: &Dirs) { + let _ = fs::remove_dir_all(self.target_dir(dirs)); } #[must_use]