diff options
| author | bors <bors@rust-lang.org> | 2024-03-20 18:47:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-20 18:47:34 +0000 |
| commit | e3df96cfda905301fc8514e000f942222c1ab6ad (patch) | |
| tree | 6c3b3bf03526cffe63c507616a06776e35853ceb /src | |
| parent | 94b72d6bebbddb5d17860914c4544f37365e988c (diff) | |
| parent | bf63f7eefe785fcb93ab918533ac2a3d85c86190 (diff) | |
Auto merge of #122779 - estebank:test-svg-non-determinism, r=compiler-errors
When comparing SVG tests against their blessed version, ignore the first line `anstyle_svg` has some weird non-determinism in the width parameter, which makes tests blessed in one environment to fail in another. This is the *only* non-determinism detected so far, so we modify the diff check to ignore the first line of the SVG. In order for a test to fail/be updated by `--bless`, a different part of the file needs to also have changed. If other sources of non-determinism are found, we should back out of the "`--color=always` means `.svg`" change. r? `@compiler-errors`
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 63e52df8c04..0c590b0fda6 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3982,6 +3982,10 @@ impl<'test> TestCx<'test> { } } + fn force_color_svg(&self) -> bool { + self.props.compile_flags.iter().any(|s| s.contains("--color=always")) + } + fn load_compare_outputs( &self, proc_res: &ProcRes, @@ -3989,10 +3993,9 @@ impl<'test> TestCx<'test> { explicit_format: bool, ) -> usize { let stderr_bits = format!("{}bit.stderr", self.config.get_pointer_width()); - let force_color_svg = self.props.compile_flags.iter().any(|s| s.contains("--color=always")); let (stderr_kind, stdout_kind) = match output_kind { TestOutput::Compile => ( - if force_color_svg { + if self.force_color_svg() { if self.config.target.contains("windows") { // We single out Windows here because some of the CLI coloring is // specifically changed for Windows. @@ -4039,8 +4042,8 @@ impl<'test> TestCx<'test> { _ => {} }; - let stderr = if force_color_svg { - anstyle_svg::Term::new().min_width_px(730).render_svg(&proc_res.stderr) + 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 { @@ -4652,7 +4655,13 @@ impl<'test> TestCx<'test> { } fn compare_output(&self, kind: &str, actual: &str, expected: &str) -> usize { - if actual == expected { + let are_different = match (self.force_color_svg(), expected.find('\n'), actual.find('\n')) { + // FIXME: We ignore the first line of SVG files + // because the width parameter is non-deterministic. + (true, Some(nl_e), Some(nl_a)) => expected[nl_e..] != actual[nl_a..], + _ => expected != actual, + }; + if !are_different { return 0; } |
