Skip to content

Commit ce53586

Browse files
committed
Refactor file comparison
1 parent 3db22ba commit ce53586

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

misc/scripts/library-coverage/compare-files.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ def check_file_exists(file):
1414
sys.exit(1)
1515

1616

17+
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 '" +
21+
file1 + "'.", file=sys.stderr)
22+
sys.exit(1)
23+
24+
1725
languages = ['java']
1826

1927
for lang in languages:
@@ -28,11 +36,8 @@ def check_file_exists(file):
2836
check_file_exists(generated_output_rst)
2937
check_file_exists(generated_output_csv)
3038

31-
filecmp.clear_cache()
32-
if not filecmp.cmp(repo_output_rst, generated_output_rst, shallow=False) or not filecmp.cmp(repo_output_csv, generated_output_csv, shallow=False):
33-
print("Error: The generated files for '" + lang +
34-
"' do not match the ones in the codebase. Please check and fix.", file=sys.stderr)
35-
sys.exit(1)
39+
compare_files(repo_output_rst, generated_output_rst)
40+
compare_files(repo_output_csv, generated_output_csv)
3641

3742
print("The generated files for '" + lang +
3843
"' match the ones in the codebase.")

0 commit comments

Comments
 (0)