diff --git a/Cargo.lock b/Cargo.lock index e419c0e9a46d6..699e5ebf754fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3461,7 +3461,6 @@ name = "run_make_support" version = "0.2.0" dependencies = [ "gimli 0.28.1", - "glob", "object 0.34.0", "regex", "similar", diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index 4a244252c84d8..2f7f51442f164 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -9,4 +9,3 @@ similar = "2.5.0" wasmparser = "0.118.2" regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace gimli = "0.28.1" -glob = "0.3.1" diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 17b62bc8dbbc9..0827ef6623d23 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -22,7 +22,6 @@ use std::panic; use std::path::{Path, PathBuf}; pub use gimli; -pub use glob; pub use object; pub use regex; pub use wasmparser; @@ -248,14 +247,14 @@ pub fn uname() -> String { /// Inside a glob pattern of files (paths), read their contents and count the /// number of regex matches with a given expression (re). #[track_caller] -pub fn count_regex_matches_in_file_glob(re: &str, paths: &str) -> usize { +pub fn count_regex_matches_in_files_with_extension(re: &str, ext: &str) -> usize { let re = regex::Regex::new(re).expect(format!("Regex expression {re} is not valid.").as_str()); - let paths = glob::glob(paths).expect(format!("Glob expression {paths} is not valid.").as_str()); use io::BufRead; - paths + fs_wrapper::read_dir(cwd()) .filter_map(|entry| entry.ok()) - .filter(|entry| entry.as_path().is_file()) - .filter_map(|path| fs::File::open(&path).ok()) + .filter(|entry| entry.path().is_file()) + .filter(|entry| entry.path().extension().unwrap() == ext) + .filter_map(|entry| fs::File::open(&entry.path()).ok()) .map(|file| io::BufReader::new(file)) .flat_map(|reader| reader.lines().filter_map(|entry| entry.ok())) .filter(|line| re.is_match(line)) diff --git a/tests/run-make/sepcomp-cci-copies/rmake.rs b/tests/run-make/sepcomp-cci-copies/rmake.rs index 8d2411c1faec4..ff0abd9e8781b 100644 --- a/tests/run-make/sepcomp-cci-copies/rmake.rs +++ b/tests/run-make/sepcomp-cci-copies/rmake.rs @@ -4,10 +4,10 @@ // created for each source module (see `rustc_const_eval::monomorphize::partitioning`). // See https://github.com/rust-lang/rust/pull/16367 -use run_make_support::{count_regex_matches_in_file_glob, rustc}; +use run_make_support::{count_regex_matches_in_files_with_extension, rustc}; fn main() { rustc().input("cci_lib.rs").run(); rustc().input("foo.rs").emit("llvm-ir").codegen_units(6).arg("-Zinline-in-all-cgus").run(); - assert_eq!(count_regex_matches_in_file_glob(r#"define\ .*cci_fn"#, "foo.*.ll"), 2); + assert_eq!(count_regex_matches_in_files_with_extension(r#"define\ .*cci_fn"#, "ll"), 2); } diff --git a/tests/run-make/sepcomp-inlining/rmake.rs b/tests/run-make/sepcomp-inlining/rmake.rs index 0315fd6997204..4d2d09b3ba799 100644 --- a/tests/run-make/sepcomp-inlining/rmake.rs +++ b/tests/run-make/sepcomp-inlining/rmake.rs @@ -5,15 +5,21 @@ // in only one compilation unit. // See https://github.com/rust-lang/rust/pull/16367 -use run_make_support::{count_regex_matches_in_file_glob, glob, regex, rustc}; +use run_make_support::{count_regex_matches_in_files_with_extension, glob, regex, rustc}; fn main() { rustc().input("foo.rs").emit("llvm-ir").codegen_units(3).arg("-Zinline-in-all-cgus").run(); - assert_eq!(count_regex_matches_in_file_glob(r#"define\ i32\ .*inlined"#, "foo.*.ll"), 0); - assert_eq!(count_regex_matches_in_file_glob(r#"define\ internal\ .*inlined"#, "foo.*.ll"), 2); - assert_eq!(count_regex_matches_in_file_glob(r#"define\ hidden\ i32\ .*normal"#, "foo.*.ll"), 1); + assert_eq!(count_regex_matches_in_files_with_extension(r#"define\ i32\ .*inlined"#, "ll"), 0); assert_eq!( - count_regex_matches_in_file_glob(r#"declare\ hidden\ i32\ .*normal"#, "foo.*.ll"), + count_regex_matches_in_files_with_extension(r#"define\ internal\ .*inlined"#, "ll"), + 2 + ); + assert_eq!( + count_regex_matches_in_files_with_extension(r#"define\ hidden\ i32\ .*normal"#, "ll"), + 1 + ); + assert_eq!( + count_regex_matches_in_files_with_extension(r#"declare\ hidden\ i32\ .*normal"#, "ll"), 2 ); } diff --git a/tests/run-make/sepcomp-separate/rmake.rs b/tests/run-make/sepcomp-separate/rmake.rs index 99ee221adc1b6..456fccc82834b 100644 --- a/tests/run-make/sepcomp-separate/rmake.rs +++ b/tests/run-make/sepcomp-separate/rmake.rs @@ -3,9 +3,9 @@ // wind up in three different compilation units. // See https://github.com/rust-lang/rust/pull/16367 -use run_make_support::{count_regex_matches_in_file_glob, rustc}; +use run_make_support::{count_regex_matches_in_files_with_extension, rustc}; fn main() { rustc().input("foo.rs").emit("llvm-ir").codegen_units(3).run(); - assert_eq!(count_regex_matches_in_file_glob(r#"define\ .*magic_fn"#, "foo.*.ll"), 3); + assert_eq!(count_regex_matches_in_files_with_extension(r#"define\ .*magic_fn"#, "ll"), 3); }