@@ -18,7 +18,7 @@ def ignore_line_ending(ch):
1818 return difflib .IS_CHARACTER_JUNK (ch , ws = " \r \n " )
1919
2020
21- def compare_files (file1 , file2 ):
21+ def compare_files (file1 , file2 , path_to_report ):
2222 has_differences = False
2323 diff = difflib .ndiff (open (file1 ).readlines (),
2424 open (file2 ).readlines (), None , ignore_line_ending )
@@ -28,13 +28,16 @@ def compare_files(file1, file2):
2828 has_differences = True
2929
3030 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
3435
3536
3637languages = ['java' ]
3738
39+ all_ok = True
40+
3841for lang in languages :
3942 repo_output_rst = settings .repo_output_rst .format (language = lang )
4043 repo_output_csv = settings .repo_output_csv .format (language = lang )
@@ -47,8 +50,20 @@ def compare_files(file1, file2):
4750 check_file_exists (generated_output_rst )
4851 check_file_exists (generated_output_csv )
4952
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." )
5267
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