File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
misc/scripts/library-coverage Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
1
import sys
2
2
import os
3
3
import settings
4
- import filecmp
4
+ import difflib
5
5
6
6
"""
7
7
This script compares the generated CSV coverage files with the ones in the codebase.
@@ -14,10 +14,21 @@ def check_file_exists(file):
14
14
sys .exit (1 )
15
15
16
16
17
+ def ignore_line_ending (ch ):
18
+ return difflib .IS_CHARACTER_JUNK (ch , ws = " \r \n " )
19
+
20
+
17
21
def compare_files (file1 , file2 ):
18
- filecmp .clear_cache ()
19
- if not filecmp .cmp (file1 , file2 ):
20
- print ("Error: The generated files do not match the ones in the codebase. Please check and fix file '" +
22
+ has_differences = False
23
+ diff = difflib .ndiff (open (file1 ).readlines (),
24
+ open (file2 ).readlines (), None , ignore_line_ending )
25
+ for line in diff :
26
+ if line .startswith ("+" ) or line .startswith ("-" ):
27
+ print (line , end = "" , file = sys .stderr )
28
+ has_differences = True
29
+
30
+ if has_differences :
31
+ print ("Error: The generated file doesn't match the one in the codebase. Please check and fix file '" +
21
32
file1 + "'." , file = sys .stderr )
22
33
sys .exit (1 )
23
34
You can’t perform that action at this time.
0 commit comments