Skip to content

Commit 03c24d1

Browse files
authored
Unrolled build for rust-lang#120273
Rollup merge of rust-lang#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 :-) .
2 parents 74c3f5a + bcfdf33 commit 03c24d1

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/tools/compiletest/src/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ fn iter_header_extra(
650650

651651
let comment = if testfile.extension().is_some_and(|e| e == "rs") { "//" } else { "#" };
652652

653-
let mut rdr = BufReader::new(rdr);
653+
let mut rdr = BufReader::with_capacity(1024, rdr);
654654
let mut ln = String::new();
655655
let mut line_number = 0;
656656

src/tools/compiletest/src/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use build_helper::git::{get_git_modified_files, get_git_untracked_files};
2525
use core::panic;
2626
use getopts::Options;
2727
use lazycell::AtomicLazyCell;
28-
use std::collections::BTreeSet;
28+
use std::collections::HashSet;
2929
use std::ffi::OsString;
3030
use std::fs;
3131
use std::io::{self, ErrorKind};
@@ -415,7 +415,7 @@ pub fn run_tests(config: Arc<Config>) {
415415

416416
let mut tests = Vec::new();
417417
for c in configs {
418-
let mut found_paths = BTreeSet::new();
418+
let mut found_paths = HashSet::new();
419419
make_tests(c, &mut tests, &mut found_paths);
420420
check_overlapping_tests(&found_paths);
421421
}
@@ -550,7 +550,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
550550
pub fn make_tests(
551551
config: Arc<Config>,
552552
tests: &mut Vec<test::TestDescAndFn>,
553-
found_paths: &mut BTreeSet<PathBuf>,
553+
found_paths: &mut HashSet<PathBuf>,
554554
) {
555555
debug!("making tests from {:?}", config.src_base.display());
556556
let inputs = common_inputs_stamp(&config);
@@ -646,7 +646,7 @@ fn collect_tests_from_dir(
646646
relative_dir_path: &Path,
647647
inputs: &Stamp,
648648
tests: &mut Vec<test::TestDescAndFn>,
649-
found_paths: &mut BTreeSet<PathBuf>,
649+
found_paths: &mut HashSet<PathBuf>,
650650
modified_tests: &Vec<PathBuf>,
651651
poisoned: &mut bool,
652652
) -> io::Result<()> {
@@ -675,6 +675,8 @@ fn collect_tests_from_dir(
675675

676676
// Add each `.rs` file as a test, and recurse further on any
677677
// subdirectories we find, except for `aux` directories.
678+
// FIXME: this walks full tests tree, even if we have something to ignore
679+
// use walkdir/ignore like in tidy?
678680
for file in fs::read_dir(dir)? {
679681
let file = file?;
680682
let file_path = file.path();
@@ -1128,7 +1130,7 @@ fn not_a_digit(c: char) -> bool {
11281130
!c.is_digit(10)
11291131
}
11301132

1131-
fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) {
1133+
fn check_overlapping_tests(found_paths: &HashSet<PathBuf>) {
11321134
let mut collisions = Vec::new();
11331135
for path in found_paths {
11341136
for ancestor in path.ancestors().skip(1) {
@@ -1138,6 +1140,7 @@ fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) {
11381140
}
11391141
}
11401142
if !collisions.is_empty() {
1143+
collisions.sort();
11411144
let collisions: String = collisions
11421145
.into_iter()
11431146
.map(|(path, check_parent)| format!("test {path:?} clashes with {check_parent:?}\n"))

src/tools/compiletest/src/runtest.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -4316,10 +4316,11 @@ impl<'test> TestCx<'test> {
43164316
let mut seen_allocs = indexmap::IndexSet::new();
43174317

43184318
// The alloc-id appears in pretty-printed allocations.
4319-
let re =
4319+
static ALLOC_ID_PP_RE: Lazy<Regex> = Lazy::new(|| {
43204320
Regex::new(r"╾─*a(lloc)?([0-9]+)(\+0x[0-9]+)?(<imm>)?( \([0-9]+ ptr bytes\))?─*╼")
4321-
.unwrap();
4322-
normalized = re
4321+
.unwrap()
4322+
});
4323+
normalized = ALLOC_ID_PP_RE
43234324
.replace_all(&normalized, |caps: &Captures<'_>| {
43244325
// Renumber the captured index.
43254326
let index = caps.get(2).unwrap().as_str().to_string();
@@ -4332,8 +4333,9 @@ impl<'test> TestCx<'test> {
43324333
.into_owned();
43334334

43344335
// The alloc-id appears in a sentence.
4335-
let re = Regex::new(r"\balloc([0-9]+)\b").unwrap();
4336-
normalized = re
4336+
static ALLOC_ID_RE: Lazy<Regex> =
4337+
Lazy::new(|| Regex::new(r"\balloc([0-9]+)\b").unwrap());
4338+
normalized = ALLOC_ID_RE
43374339
.replace_all(&normalized, |caps: &Captures<'_>| {
43384340
let index = caps.get(1).unwrap().as_str().to_string();
43394341
let (index, _) = seen_allocs.insert_full(index);

0 commit comments

Comments
 (0)