5
5
and the working directory to contain the cargo-miri-test project.
6
6
'''
7
7
8
- import sys , subprocess , os , re , difflib
8
+ import difflib
9
+ import os
10
+ import re
11
+ import sys
12
+ import subprocess
9
13
10
14
CGREEN = '\33 [32m'
11
15
CBOLD = '\33 [1m'
@@ -46,7 +50,9 @@ def check_output(actual, path, name):
46
50
print (f"--- END diff { name } ---" )
47
51
return False
48
52
49
- def test (name , cmd , stdout_ref , stderr_ref , stdin = b'' , env = {}):
53
+ def test (name , cmd , stdout_ref , stderr_ref , stdin = b'' , env = None ):
54
+ if env is None :
55
+ env = {}
50
56
print ("Testing {}..." .format (name ))
51
57
## Call `cargo miri`, capture all output
52
58
p_env = os .environ .copy ()
@@ -64,13 +70,15 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
64
70
65
71
stdout_matches = check_output (stdout , stdout_ref , "stdout" )
66
72
stderr_matches = check_output (stderr , stderr_ref , "stderr" )
67
-
73
+
68
74
if p .returncode == 0 and stdout_matches and stderr_matches :
69
75
# All good!
70
76
return
71
77
fail ("exit code was {}" .format (p .returncode ))
72
78
73
- def test_no_rebuild (name , cmd , env = {}):
79
+ def test_no_rebuild (name , cmd , env = None ):
80
+ if env is None :
81
+ env = {}
74
82
print ("Testing {}..." .format (name ))
75
83
p_env = os .environ .copy ()
76
84
p_env .update (env )
@@ -84,13 +92,13 @@ def test_no_rebuild(name, cmd, env={}):
84
92
stdout = stdout .decode ("UTF-8" )
85
93
stderr = stderr .decode ("UTF-8" )
86
94
if p .returncode != 0 :
87
- fail ("rebuild failed" );
95
+ fail ("rebuild failed" )
88
96
# Also check for 'Running' as a sanity check.
89
97
if stderr .count (" Compiling " ) > 0 or stderr .count (" Running " ) == 0 :
90
98
print ("--- BEGIN stderr ---" )
91
99
print (stderr , end = "" )
92
100
print ("--- END stderr ---" )
93
- fail ("Something was being rebuilt when it should not be (or we got no output)" );
101
+ fail ("Something was being rebuilt when it should not be (or we got no output)" )
94
102
95
103
def test_cargo_miri_run ():
96
104
test ("`cargo miri run` (no isolation)" ,
0 commit comments