55and the working directory to contain the cargo-miri-test project.
66'''
77
8- import sys , subprocess , os , re , difflib
8+ import difflib
9+ import os
10+ import re
11+ import sys
12+ import subprocess
913
1014CGREEN = '\33 [32m'
1115CBOLD = '\33 [1m'
@@ -46,7 +50,9 @@ def check_output(actual, path, name):
4650 print (f"--- END diff { name } ---" )
4751 return False
4852
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 = {}
5056 print ("Testing {}..." .format (name ))
5157 ## Call `cargo miri`, capture all output
5258 p_env = os .environ .copy ()
@@ -64,13 +70,15 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
6470
6571 stdout_matches = check_output (stdout , stdout_ref , "stdout" )
6672 stderr_matches = check_output (stderr , stderr_ref , "stderr" )
67-
73+
6874 if p .returncode == 0 and stdout_matches and stderr_matches :
6975 # All good!
7076 return
7177 fail ("exit code was {}" .format (p .returncode ))
7278
73- def test_no_rebuild (name , cmd , env = {}):
79+ def test_no_rebuild (name , cmd , env = None ):
80+ if env is None :
81+ env = {}
7482 print ("Testing {}..." .format (name ))
7583 p_env = os .environ .copy ()
7684 p_env .update (env )
@@ -84,13 +92,13 @@ def test_no_rebuild(name, cmd, env={}):
8492 stdout = stdout .decode ("UTF-8" )
8593 stderr = stderr .decode ("UTF-8" )
8694 if p .returncode != 0 :
87- fail ("rebuild failed" );
95+ fail ("rebuild failed" )
8896 # Also check for 'Running' as a sanity check.
8997 if stderr .count (" Compiling " ) > 0 or stderr .count (" Running " ) == 0 :
9098 print ("--- BEGIN stderr ---" )
9199 print (stderr , end = "" )
92100 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)" )
94102
95103def test_cargo_miri_run ():
96104 test ("`cargo miri run` (no isolation)" ,
0 commit comments