diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-12 23:18:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-12 23:18:53 +0100 |
| commit | 82fda11cc7d8745d6dd438df6f1ba2da9b50de90 (patch) | |
| tree | e4d0dd7cabdc3e3eb8ae552b527c1fbabedeba6e | |
| parent | 78403e86d5dc0ff451201d7d7a1d248476c58f83 (diff) | |
| parent | bcfdf3307bcc0246dbe6ac709ed695a0a809c2ea (diff) | |
| download | rust-82fda11cc7d8745d6dd438df6f1ba2da9b50de90.tar.gz rust-82fda11cc7d8745d6dd438df6f1ba2da9b50de90.zip | |
Rollup merge of #120273 - klensy:ct-run, r=onur-ozkan
compiletest: few naive improvements Tested on `python x.py --stage=1 t tests/ui/borrowck/ --force-rerun`, see individual commits. Wall time didn't improved :-) .
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 2 | ||||
| -rw-r--r-- | src/tools/compiletest/src/lib.rs | 13 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 12 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index ff907152ca9..daec3914145 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -650,7 +650,7 @@ fn iter_header_extra( let comment = if testfile.extension().is_some_and(|e| e == "rs") { "//" } else { "#" }; - let mut rdr = BufReader::new(rdr); + let mut rdr = BufReader::with_capacity(1024, rdr); let mut ln = String::new(); let mut line_number = 0; diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 60dd15841b7..667358b1a6e 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -25,7 +25,7 @@ use build_helper::git::{get_git_modified_files, get_git_untracked_files}; use core::panic; use getopts::Options; use lazycell::AtomicLazyCell; -use std::collections::BTreeSet; +use std::collections::HashSet; use std::ffi::OsString; use std::fs; use std::io::{self, ErrorKind}; @@ -415,7 +415,7 @@ pub fn run_tests(config: Arc<Config>) { let mut tests = Vec::new(); for c in configs { - let mut found_paths = BTreeSet::new(); + let mut found_paths = HashSet::new(); make_tests(c, &mut tests, &mut found_paths); check_overlapping_tests(&found_paths); } @@ -550,7 +550,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts { pub fn make_tests( config: Arc<Config>, tests: &mut Vec<test::TestDescAndFn>, - found_paths: &mut BTreeSet<PathBuf>, + found_paths: &mut HashSet<PathBuf>, ) { debug!("making tests from {:?}", config.src_base.display()); let inputs = common_inputs_stamp(&config); @@ -646,7 +646,7 @@ fn collect_tests_from_dir( relative_dir_path: &Path, inputs: &Stamp, tests: &mut Vec<test::TestDescAndFn>, - found_paths: &mut BTreeSet<PathBuf>, + found_paths: &mut HashSet<PathBuf>, modified_tests: &Vec<PathBuf>, poisoned: &mut bool, ) -> io::Result<()> { @@ -675,6 +675,8 @@ fn collect_tests_from_dir( // Add each `.rs` file as a test, and recurse further on any // subdirectories we find, except for `aux` directories. + // FIXME: this walks full tests tree, even if we have something to ignore + // use walkdir/ignore like in tidy? for file in fs::read_dir(dir)? { let file = file?; let file_path = file.path(); @@ -1128,7 +1130,7 @@ fn not_a_digit(c: char) -> bool { !c.is_digit(10) } -fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) { +fn check_overlapping_tests(found_paths: &HashSet<PathBuf>) { let mut collisions = Vec::new(); for path in found_paths { for ancestor in path.ancestors().skip(1) { @@ -1138,6 +1140,7 @@ fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) { } } if !collisions.is_empty() { + collisions.sort(); let collisions: String = collisions .into_iter() .map(|(path, check_parent)| format!("test {path:?} clashes with {check_parent:?}\n")) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ed1c559e1f6..f3a0e87d43a 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -4316,10 +4316,11 @@ impl<'test> TestCx<'test> { let mut seen_allocs = indexmap::IndexSet::new(); // The alloc-id appears in pretty-printed allocations. - let re = + static ALLOC_ID_PP_RE: Lazy<Regex> = Lazy::new(|| { Regex::new(r"╾─*a(lloc)?([0-9]+)(\+0x[0-9]+)?(<imm>)?( \([0-9]+ ptr bytes\))?─*╼") - .unwrap(); - normalized = re + .unwrap() + }); + normalized = ALLOC_ID_PP_RE .replace_all(&normalized, |caps: &Captures<'_>| { // Renumber the captured index. let index = caps.get(2).unwrap().as_str().to_string(); @@ -4332,8 +4333,9 @@ impl<'test> TestCx<'test> { .into_owned(); // The alloc-id appears in a sentence. - let re = Regex::new(r"\balloc([0-9]+)\b").unwrap(); - normalized = re + static ALLOC_ID_RE: Lazy<Regex> = + Lazy::new(|| Regex::new(r"\balloc([0-9]+)\b").unwrap()); + normalized = ALLOC_ID_RE .replace_all(&normalized, |caps: &Captures<'_>| { let index = caps.get(1).unwrap().as_str().to_string(); let (index, _) = seen_allocs.insert_full(index); |
