From c259c4048a97329a70a7ec2dcd0e79fe2c36be68 Mon Sep 17 00:00:00 2001 From: Sasha Pourcelot Date: Sat, 14 Feb 2026 19:52:42 +0000 Subject: [PATCH] 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. --- src/tools/compiletest/src/runtest.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index e6eb1f3bd957..99c51207f601 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2379,15 +2379,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 => {