Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b7473be

Browse files
committed
handle excluded strings across boundaries
1 parent 47d8ba9 commit b7473be

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/tools/compiletest/src/read2.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn read2_abbreviated(mut child: Child, exclude_from_len: &[String]) -> io::R
2222
fn extend(&mut self, data: &[u8], exclude_from_len: &[String]) {
2323
let new_self = match *self {
2424
ProcOutput::Full { ref mut bytes, ref mut excluded_len } => {
25+
let old_len = bytes.len();
2526
bytes.extend_from_slice(data);
2627

2728
// We had problems in the past with tests failing only in some environments,
@@ -37,7 +38,10 @@ pub fn read2_abbreviated(mut child: Child, exclude_from_len: &[String]) -> io::R
3738
// the configured threshold.
3839
for pattern in exclude_from_len {
3940
let pattern_bytes = pattern.as_bytes();
40-
let matches = data
41+
// We start matching `pattern_bytes - 1` into the previously loaded data,
42+
// to account for the fact a pattern might be included across multiple
43+
// `extend` calls. Starting from `- 1` avoids double-counting patterns.
44+
let matches = (&bytes[(old_len.saturating_sub(pattern_bytes.len() - 1))..])
4145
.windows(pattern_bytes.len())
4246
.filter(|window| window == &pattern_bytes)
4347
.count();

0 commit comments

Comments
 (0)