Skip to content

Commit bb47676

Browse files
committed
compiletest: ignore SVG y offset in by-lines comparison
1 parent d595fce commit bb47676

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/tools/compiletest/src/runtest.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,6 +2299,24 @@ impl<'test> TestCx<'test> {
22992299
self.props.compile_flags.iter().any(|s| s.contains("--color=always"))
23002300
}
23012301

2302+
/// Strip the SVG `y` offset and header line so a reordering of rows
2303+
/// under the parallel front-end is not seen as a difference. Non-SVG output
2304+
/// is returned unchanged.
2305+
fn normalize_svg_for_line_comparison<'a>(&self, output: &'a str) -> Cow<'a, str> {
2306+
if !self.force_color_svg() {
2307+
return Cow::Borrowed(output);
2308+
}
2309+
let strip_y = static_regex!(r#"y="\d+px""#);
2310+
Cow::Owned(
2311+
output
2312+
.lines()
2313+
.skip(1)
2314+
.map(|line| strip_y.replace_all(line, r#"y="0px""#))
2315+
.collect::<Vec<_>>()
2316+
.join("\n"),
2317+
)
2318+
}
2319+
23022320
fn load_compare_outputs(
23032321
&self,
23042322
proc_res: &ProcRes,
@@ -2714,8 +2732,10 @@ impl<'test> TestCx<'test> {
27142732
(&tmp.0, &tmp.1)
27152733
}
27162734
} else if compare_output_by_lines {
2717-
let mut actual_lines: Vec<&str> = actual.lines().collect();
2718-
let mut expected_lines: Vec<&str> = expected.lines().collect();
2735+
let actual_norm = self.normalize_svg_for_line_comparison(actual);
2736+
let expected_norm = self.normalize_svg_for_line_comparison(expected);
2737+
let mut actual_lines: Vec<&str> = actual_norm.lines().collect();
2738+
let mut expected_lines: Vec<&str> = expected_norm.lines().collect();
27192739
actual_lines.sort_unstable();
27202740
expected_lines.sort_unstable();
27212741
if actual_lines == expected_lines {
@@ -2859,7 +2879,9 @@ impl<'test> TestCx<'test> {
28592879
}
28602880

28612881
if show_diff_by_lines {
2862-
write!(self.stderr, "{}", diff_by_lines(expected, actual));
2882+
let expected_norm = self.normalize_svg_for_line_comparison(expected);
2883+
let actual_norm = self.normalize_svg_for_line_comparison(actual);
2884+
write!(self.stderr, "{}", diff_by_lines(&expected_norm, &actual_norm));
28632885
}
28642886
}
28652887

tests/ui/error-emitter/multiline-removal-suggestion.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,3 @@ fn bay() -> Vec<(bool, HashSet<u8>)> {
5656
.collect()
5757
}
5858
fn main() {}
59-
//@ ignore-parallel-frontend invalid svg(multiple threads trying to write to the same file)

0 commit comments

Comments
 (0)