Rollup merge of #152658 - scrabsha:normalize-before-svg, r=jieyouxu

compiletest: normalize stderr before SVG rendering

Element position is hardcoded in the rendered SVG. This means that any change in element length (for instance, when substituting the path with the `rust` checkout with `$DIR`) would not change the position and result in buggy SVG being generated. Normalizing before SVG rendering allows us to keep a consistent element placement.
This commit is contained in:
Jonathan Brouwer 2026-02-18 18:55:18 +01:00 committed by GitHub
commit cf32cab26c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2384,15 +2384,22 @@ impl<'test> TestCx<'test> {
_ => {}
};
let stderr = if self.force_color_svg() {
anstyle_svg::Term::new().render_svg(&proc_res.stderr)
} else if explicit_format {
proc_res.stderr.clone()
} else {
json::extract_rendered(&proc_res.stderr)
};
let stderr;
let normalized_stderr;
if self.force_color_svg() {
let normalized = self.normalize_output(&proc_res.stderr, &self.props.normalize_stderr);
stderr = anstyle_svg::Term::new().render_svg(&normalized);
normalized_stderr = stderr.clone();
} else {
stderr = if explicit_format {
proc_res.stderr.clone()
} else {
json::extract_rendered(&proc_res.stderr)
};
normalized_stderr = self.normalize_output(&stderr, &self.props.normalize_stderr);
}
let normalized_stderr = self.normalize_output(&stderr, &self.props.normalize_stderr);
let mut errors = 0;
match output_kind {
TestOutput::Compile => {