diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 721200f77f3aa..f464a109e7711 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -23,7 +23,6 @@ use std::path::{Path, PathBuf}; pub use bstr; pub use gimli; -pub use glob; pub use object; pub use regex; pub use wasmparser; @@ -224,42 +223,6 @@ pub fn bin_name(name: &str) -> String { if is_windows() { format!("{name}.exe") } else { name.to_string() } } -/// Remove all dynamic libraries possessing a name starting with `paths`. -#[track_caller] -pub fn remove_dylibs(paths: &str) { - let paths = format!(r"{paths}*"); - remove_glob(dynamic_lib_name(&paths).as_str()); -} - -/// Remove all rust libraries possessing a name starting with `paths`. -#[track_caller] -pub fn remove_rlibs(paths: &str) { - let paths = format!(r"{paths}*"); - remove_glob(rust_lib_name(&paths).as_str()); -} - -#[track_caller] -fn remove_glob(paths: &str) { - let paths = glob::glob(paths).expect(format!("Glob expression {paths} is not valid.").as_str()); - paths - .filter_map(|entry| entry.ok()) - .filter(|entry| entry.as_path().is_file()) - .for_each(|file| fs_wrapper::remove_file(&file)); -} - -#[track_caller] -fn count_glob(paths: &str) -> usize { - let paths = glob::glob(paths).expect(format!("Glob expression {paths} is not valid.").as_str()); - paths.filter_map(|entry| entry.ok()).filter(|entry| entry.as_path().is_file()).count() -} - -/// Count the number of rust libraries possessing a name starting with `paths`. -#[track_caller] -pub fn count_rlibs(paths: &str) -> usize { - let paths = format!(r"{paths}*"); - count_glob(rust_lib_name(&paths).as_str()) -} - /// Return the current working directory. #[must_use] pub fn cwd() -> PathBuf { diff --git a/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs b/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs index 5f8c998874b65..766acfc00da53 100644 --- a/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs +++ b/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs @@ -5,9 +5,10 @@ // the lib crate-type flag was actually followed. // See https://github.com/rust-lang/rust/issues/18943 -use run_make_support::{count_rlibs, rustc}; +use run_make_support::{rust_lib_name, rustc}; +use std::path::Path; fn main() { rustc().input("foo.rs").crate_type("lib").run(); - assert_eq!(count_rlibs("foo"), 1); + assert!(Path::new(&rust_lib_name("foo")).exists()); } diff --git a/tests/run-make/mixing-libs/rmake.rs b/tests/run-make/mixing-libs/rmake.rs index d46a2403c25b3..06ef6ab00f5f8 100644 --- a/tests/run-make/mixing-libs/rmake.rs +++ b/tests/run-make/mixing-libs/rmake.rs @@ -6,7 +6,7 @@ //@ ignore-cross-compile -use run_make_support::{remove_dylibs, rustc}; +use run_make_support::{dynamic_lib_name, fs_wrapper, rustc}; fn main() { rustc().input("rlib.rs").crate_type("rlib").crate_type("dylib").run(); @@ -16,6 +16,6 @@ fn main() { // librlib's dynamic version needs to be removed here to prevent prog.rs from fetching // the wrong one. - remove_dylibs("rlib"); + fs_wrapper::remove_file(dynamic_lib_name("rlib")); rustc().input("prog.rs").run_fail(); } diff --git a/tests/run-make/obey-crate-type-flag/rmake.rs b/tests/run-make/obey-crate-type-flag/rmake.rs index 4ae4b6e4eec0a..8aa78cccbb23b 100644 --- a/tests/run-make/obey-crate-type-flag/rmake.rs +++ b/tests/run-make/obey-crate-type-flag/rmake.rs @@ -5,12 +5,17 @@ //@ ignore-cross-compile -use run_make_support::{count_rlibs, remove_dylibs, remove_rlibs, rustc}; +use run_make_support::{ + cwd, dynamic_lib_name, fs_wrapper, has_extension, rust_lib_name, rustc, shallow_find_files, +}; +use std::path::Path; fn main() { rustc().input("test.rs").run(); - remove_rlibs("test"); - remove_dylibs("test"); + assert!(Path::new(&dynamic_lib_name("test")).exists()); + assert!(Path::new(&rust_lib_name("test")).exists()); + + fs_wrapper::remove_file(rust_lib_name("test")); rustc().crate_type("dylib").input("test.rs").run(); - assert_eq!(count_rlibs("test"), 0); + assert!(shallow_find_files(cwd(), |path| { has_extension(path, "rlib") }).is_empty()); }