Skip to content

Commit 47d8ba9

Browse files
committed
handle compiler emitting only excluded strings
1 parent 73497b1 commit 47d8ba9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/tools/compiletest/src/read2.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ pub fn read2_abbreviated(mut child: Child, exclude_from_len: &[String]) -> io::R
1111

1212
const HEAD_LEN: usize = 160 * 1024;
1313
const TAIL_LEN: usize = 256 * 1024;
14+
const EXCLUDED_PLACEHOLDER_LEN: isize = 32;
1415

1516
enum ProcOutput {
16-
Full { bytes: Vec<u8>, excluded_len: usize },
17+
Full { bytes: Vec<u8>, excluded_len: isize },
1718
Abbreviated { head: Vec<u8>, skipped: usize, tail: Box<[u8]> },
1819
}
1920

@@ -30,17 +31,22 @@ pub fn read2_abbreviated(mut child: Child, exclude_from_len: &[String]) -> io::R
3031
// paths when calculating the string length, while still including the full
3132
// path in the output. This could result in some output being larger than the
3233
// threshold, but it's better than having nondeterministic failures.
34+
//
35+
// The compiler emitting only excluded strings is addressed by adding a
36+
// placeholder size for each excluded segment, which will eventually reach
37+
// the configured threshold.
3338
for pattern in exclude_from_len {
3439
let pattern_bytes = pattern.as_bytes();
3540
let matches = data
3641
.windows(pattern_bytes.len())
3742
.filter(|window| window == &pattern_bytes)
3843
.count();
39-
*excluded_len += matches * pattern_bytes.len();
44+
*excluded_len += matches as isize
45+
* (EXCLUDED_PLACEHOLDER_LEN - pattern_bytes.len() as isize);
4046
}
4147

4248
let new_len = bytes.len();
43-
if new_len.saturating_sub(*excluded_len) <= HEAD_LEN + TAIL_LEN {
49+
if (new_len as isize + *excluded_len) as usize <= HEAD_LEN + TAIL_LEN {
4450
return;
4551
}
4652

0 commit comments

Comments
 (0)