@@ -83,11 +83,11 @@ def shallow_equal(self, other, time_resolution_ns):
8383
8484
8585def remove_blank_lines (text ):
86- splits = text . splitlines ()
87- lines = text .splitlines ( True )
88- blanks = set ([ i for i , l in enumerate ( splits ) if not l ])
89- lines = [ l for i , l in enumerate ( lines ) if i not in blanks ]
90- return b'' .join (lines )
86+ """
87+ Remove blank lines from text.
88+ And normalize line ending
89+ """
90+ return b'\n ' .join (filter ( bool , text . splitlines ()) )
9191
9292
9393def _files_same (files , regexes , comparison_args ):
@@ -184,13 +184,12 @@ def _files_same(files, regexes, comparison_args):
184184 if result == Different and need_contents :
185185 contents = [b"" .join (c ) for c in contents ]
186186 # For probable text files, discard newline differences to match
187- # file comparisons.
188- contents = [b"\n " .join (c .splitlines ()) for c in contents ]
189-
190- contents = [misc .apply_text_filters (c , regexes ) for c in contents ]
191-
192187 if ignore_blank_lines :
193188 contents = [remove_blank_lines (c ) for c in contents ]
189+ else :
190+ contents = [b"\n " .join (c .splitlines ()) for c in contents ]
191+
192+ contents = [misc .apply_text_filters (c , regexes ) for c in contents ]
194193 result = SameFiltered if all_same (contents ) else Different
195194
196195 _cache [cache_key ] = CacheResult (stats , result )
0 commit comments