Skip to content

Commit a4e8c88

Browse files
authored
Improve test script to log diff (#5131)
1 parent 7ea05d9 commit a4e8c88

File tree

1 file changed

+10
-1
lines changed
  • test/migration-tool-tests/src/test/resources

1 file changed

+10
-1
lines changed

test/migration-tool-tests/src/test/resources/run-test

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import filecmp
55
import os
66
import shutil, errno
77
import argparse
8+
import difflib
89

910
RESOURCE_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "resources")
1011
BEFORE_DIR = os.path.join(RESOURCE_DIR, "before")
@@ -29,11 +30,19 @@ def run_test(version):
2930
comparison = filecmp.dircmp(TARGET_DIR, AFTER_DIR)
3031
is_same = compare_directory(filecmp.dircmp(TARGET_DIR, AFTER_DIR))
3132
if not is_same:
32-
comparison.report_full_closure()
3333
raise Exception("The transformed directory('target/generated-test-sources/project') does not match with the expected one('src/test/resources/after')")
3434

3535
def compare_directory(dcmp):
3636
if dcmp.diff_files or dcmp.left_only or dcmp.right_only:
37+
for diff_file in dcmp.diff_files:
38+
file1 = open(dcmp.right + "/" + diff_file, 'r')
39+
file2 = open(dcmp.left + "/" + diff_file, 'r')
40+
diff = difflib.ndiff(file1.readlines(), file2.readlines())
41+
changes = [l for l in diff if l.startswith('+ ') or l.startswith('- ')]
42+
print("Diff found in file: " + diff_file)
43+
for change in changes:
44+
print(change)
45+
3746
return False
3847
for sub_dcmp in dcmp.subdirs.values():
3948
if not compare_directory(sub_dcmp):

0 commit comments

Comments
 (0)