@@ -15,8 +15,10 @@ def fail(msg):
15
15
print ("\n TEST FAIL: {}" .format (msg ))
16
16
sys .exit (1 )
17
17
18
- def cargo_miri (cmd ):
19
- args = ["cargo" , "miri" , cmd , "-q" ]
18
+ def cargo_miri (cmd , quiet = True ):
19
+ args = ["cargo" , "miri" , cmd ]
20
+ if quiet :
21
+ args += ["-q" ]
20
22
if 'MIRI_TEST_TARGET' in os .environ :
21
23
args += ["--target" , os .environ ['MIRI_TEST_TARGET' ]]
22
24
return args
@@ -48,6 +50,25 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
48
50
print ("--- END stderr ---" )
49
51
fail ("exit code was {}" .format (p .returncode ))
50
52
53
+ def test_no_rebuild (name , cmd ):
54
+ print ("Testing {}..." .format (name ))
55
+ p = subprocess .Popen (
56
+ cmd ,
57
+ stdout = subprocess .PIPE ,
58
+ stderr = subprocess .PIPE ,
59
+ )
60
+ (stdout , stderr ) = p .communicate ()
61
+ stdout = stdout .decode ("UTF-8" )
62
+ stderr = stderr .decode ("UTF-8" )
63
+ if p .returncode != 0 :
64
+ fail ("rebuild failed" );
65
+ # Also check for 'Running' as a sanity check.
66
+ if stderr .count (" Compiling " ) > 0 or stderr .count (" Running " ) == 0 :
67
+ print ("--- BEGIN stderr ---" )
68
+ print (stderr , end = "" )
69
+ print ("--- END stderr ---" )
70
+ fail ("Something was being rebuilt when it should not be (or we got no output)" );
71
+
51
72
def test_cargo_miri_run ():
52
73
test ("`cargo miri run` (no isolation)" ,
53
74
cargo_miri ("run" ),
@@ -67,6 +88,12 @@ def test_cargo_miri_run():
67
88
"run.subcrate.stdout.ref" , "run.subcrate.stderr.ref" ,
68
89
env = {'MIRIFLAGS' : "-Zmiri-disable-isolation" },
69
90
)
91
+ # Special test: run it again *without* `-q` to make sure nothing is being rebuilt (Miri issue #1722)
92
+ # FIXME: move this test up to right after the first `test`
93
+ # (currently that fails, only the 3rd and later runs are really clean... see Miri issue #1722)
94
+ test_no_rebuild ("`cargo miri run` (no rebuild)" ,
95
+ cargo_miri ("run" , quiet = False ) + ["--" , "" ],
96
+ )
70
97
71
98
def test_cargo_miri_test ():
72
99
# rustdoc is not run on foreign targets
0 commit comments