@@ -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 pure 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,13 @@ 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+ // Compare as a sorted line multiset. For SVG snapshots this strips
2736+ // the `y` offset first, so a pure reordering of rows under the
2737+ // parallel front-end is not reported as a difference.
2738+ let actual_norm = self . normalize_svg_for_line_comparison ( actual) ;
2739+ let expected_norm = self . normalize_svg_for_line_comparison ( expected) ;
2740+ let mut actual_lines: Vec < & str > = actual_norm. lines ( ) . collect ( ) ;
2741+ let mut expected_lines: Vec < & str > = expected_norm. lines ( ) . collect ( ) ;
27192742 actual_lines. sort_unstable ( ) ;
27202743 expected_lines. sort_unstable ( ) ;
27212744 if actual_lines == expected_lines {
@@ -2859,7 +2882,10 @@ impl<'test> TestCx<'test> {
28592882 }
28602883
28612884 if show_diff_by_lines {
2862- write ! ( self . stderr, "{}" , diff_by_lines( expected, actual) ) ;
2885+ // Normalize the same way as the by-lines comparison.
2886+ let expected_norm = self . normalize_svg_for_line_comparison ( expected) ;
2887+ let actual_norm = self . normalize_svg_for_line_comparison ( actual) ;
2888+ write ! ( self . stderr, "{}" , diff_by_lines( & expected_norm, & actual_norm) ) ;
28632889 }
28642890 }
28652891
0 commit comments