@@ -27,6 +27,16 @@ def normalize_stdout(str):
27
27
str = str .replace ("src\\ " , "src/" ) # normalize paths across platforms
28
28
return re .sub ("finished in \d+\.\d\ds" , "finished in $TIME" , str )
29
29
30
+ def check_output (expected , actual , path , name ):
31
+ if expected == actual :
32
+ return True
33
+ print (f"{ path } did not match reference!" )
34
+ print (f"--- BEGIN diff { name } ---" )
35
+ for text in difflib .unified_diff (expected .split ("\n " ), actual .split ("\n " )):
36
+ print (text )
37
+ print (f"--- END diff { name } ---" )
38
+ return False
39
+
30
40
def test (name , cmd , stdout_ref , stderr_ref , stdin = b'' , env = {}):
31
41
print ("Testing {}..." .format (name ))
32
42
## Call `cargo miri`, capture all output
@@ -44,18 +54,9 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
44
54
stderr = stderr .decode ("UTF-8" )
45
55
stdout = normalize_stdout (stdout )
46
56
expected_stdout = open (stdout_ref ).read ()
47
- if p .returncode == 0 and stdout == expected_stdout and stderr == open (stderr_ref ).read ():
57
+ if p .returncode == 0 and check_output ( expected_stdout , stdout , stdout_ref , "stdout" ) and check_output ( open (stderr_ref ).read (), stderr , stderr_ref , "stderr" ):
48
58
# All good!
49
59
return
50
- # Show output
51
- print (f"{ stdout_ref } or { stderr_ref } did not match reference!" )
52
- print ("--- BEGIN test stdout ---" )
53
- for text in difflib .unified_diff (expected_stdout .split ("\n " ), stdout .split ("\n " )):
54
- print (text )
55
- print ("--- END test stdout ---" )
56
- print ("--- BEGIN test stderr ---" )
57
- print (stderr , end = "" )
58
- print ("--- END test stderr ---" )
59
60
fail ("exit code was {}" .format (p .returncode ))
60
61
61
62
def test_no_rebuild (name , cmd , env = {}):
0 commit comments