Skip to content

Commit 0b9dcc1

Browse files
committed
fixing the helpers.py function
Signed-off-by: Ethan Mahintorabi <[email protected]>
1 parent 493a60d commit 0b9dcc1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/helpers.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def make_result_file(filename):
4848
def diff_files(file1, file2, ignore=None):
4949
if ignore:
5050
ignore = re.compile(ignore)
51+
52+
report_function = utl.report
53+
if os.environ.get("TEST_SRCDIR", ""):
54+
report_function = print
5155

5256
with open(file1, "r") as f:
5357
lines1 = f.readlines()
@@ -61,20 +65,20 @@ def diff_files(file1, file2, ignore=None):
6165
if ignore and (ignore.search(lines1[i]) or ignore.search(lines2[i])):
6266
continue
6367
if lines1[i] != lines2[i]:
64-
print(f"Differences found at line {i+1}.")
65-
print(lines1[i][:-1])
66-
print(lines2[i][:-1])
68+
report_function(f"Differences found at line {i+1}.")
69+
report_function(lines1[i][:-1])
70+
report_function(lines2[i][:-1])
6771
if os.environ.get("TEST_SRCDIR", ""):
6872
raise Exception("Diffs found")
6973
return 1
7074

7175
if num_lines1 != num_lines2:
72-
print(f"Number of lines differs {num_lines1} vs {num_lines2}.")
76+
report_function(f"Number of lines differs {num_lines1} vs {num_lines2}.")
7377
if os.environ.get("TEST_SRCDIR", ""):
7478
raise Exception("Diffs found")
7579
return 1
7680

77-
print("No differences found.")
81+
report_function("No differences found.")
7882
return 0
7983

8084

0 commit comments

Comments
 (0)