@@ -18,7 +18,7 @@ def ignore_line_ending(ch):
18
18
return difflib .IS_CHARACTER_JUNK (ch , ws = " \r \n " )
19
19
20
20
21
- def compare_files (file1 , file2 ):
21
+ def compare_files (file1 , file2 , path_to_report ):
22
22
has_differences = False
23
23
diff = difflib .ndiff (open (file1 ).readlines (),
24
24
open (file2 ).readlines (), None , ignore_line_ending )
@@ -28,13 +28,16 @@ def compare_files(file1, file2):
28
28
has_differences = True
29
29
30
30
if has_differences :
31
- print ("Error: The generated file doesn't match the one in the codebase. Please check and fix file '" +
32
- file1 + "'." , file = sys .stderr )
33
- sys .exit (1 )
31
+ print ("The generated file doesn't match the one in the codebase. Please check and fix file '" +
32
+ path_to_report + "'." , file = sys .stderr )
33
+ return False
34
+ return True
34
35
35
36
36
37
languages = ['java' ]
37
38
39
+ all_ok = True
40
+
38
41
for lang in languages :
39
42
repo_output_rst = settings .repo_output_rst .format (language = lang )
40
43
repo_output_csv = settings .repo_output_csv .format (language = lang )
@@ -47,8 +50,20 @@ def compare_files(file1, file2):
47
50
check_file_exists (generated_output_rst )
48
51
check_file_exists (generated_output_csv )
49
52
50
- compare_files (repo_output_rst , generated_output_rst )
51
- compare_files (repo_output_csv , generated_output_csv )
53
+ docs_folder = settings .documentation_folder_no_prefix .format (language = lang )
54
+
55
+ rst_ok = compare_files (repo_output_rst , generated_output_rst ,
56
+ docs_folder + settings .output_rst_file_name )
57
+ csv_ok = compare_files (repo_output_csv , generated_output_csv ,
58
+ docs_folder + settings .output_csv_file_name )
59
+
60
+ if not rst_ok or not csv_ok :
61
+ print ("The generated CSV coverage report files for '" + lang + "' don't match the ones in the codebase. Please update the files in '" +
62
+ docs_folder + "'. The new files can be downloaded from the artifacts of this job." , file = sys .stderr )
63
+ all_ok = False
64
+ else :
65
+ print ("The generated files for '" + lang +
66
+ "' match the ones in the codebase." )
52
67
53
- print ( "The generated files for '" + lang +
54
- "' match the ones in the codebase." )
68
+ if not all_ok :
69
+ sys . exit ( 1 )
0 commit comments