Skip to content

Commit a80525d

Browse files
committed
Make it a bit easier to debug test changes
1 parent 5912bd6 commit a80525d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test-cargo-miri/run-test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
and the working directory to contain the cargo-miri-test project.
66
'''
77

8-
import sys, subprocess, os, re
8+
import sys, subprocess, os, re, difflib
99

1010
CGREEN = '\33[32m'
1111
CBOLD = '\33[1m'
@@ -42,13 +42,16 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
4242
(stdout, stderr) = p.communicate(input=stdin)
4343
stdout = stdout.decode("UTF-8")
4444
stderr = stderr.decode("UTF-8")
45-
if p.returncode == 0 and normalize_stdout(stdout) == open(stdout_ref).read() and stderr == open(stderr_ref).read():
45+
stdout = normalize_stdout(stdout)
46+
expected_stdout = open(stdout_ref).read()
47+
if p.returncode == 0 and stdout == expected_stdout and stderr == open(stderr_ref).read():
4648
# All good!
4749
return
4850
# Show output
49-
print("Test stdout or stderr did not match reference!")
51+
print(f"{stdout_ref} or {stderr_ref} did not match reference!")
5052
print("--- BEGIN test stdout ---")
51-
print(stdout, end="")
53+
for text in difflib.unified_diff(expected_stdout.split("\n"), stdout.split("\n")):
54+
print(text)
5255
print("--- END test stdout ---")
5356
print("--- BEGIN test stderr ---")
5457
print(stderr, end="")

0 commit comments

Comments
 (0)