@@ -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_rebuild (name , cmd , rebuild_count_expected ):
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
+ rebuild_count = stderr .count (" Compiling " );
66
+ if rebuild_count != rebuild_count_expected :
67
+ print ("--- BEGIN stderr ---" )
68
+ print (stderr , end = "" )
69
+ print ("--- END stderr ---" )
70
+ fail ("Expected {} rebuild(s), but got {}" .format (rebuild_count_expected , rebuild_count ));
71
+
51
72
def test_cargo_miri_run ():
52
73
test ("`cargo miri run` (no isolation)" ,
53
74
cargo_miri ("run" ),
@@ -67,6 +88,11 @@ 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
+ test_rebuild ("`cargo miri run` (clean rebuild)" ,
93
+ cargo_miri ("run" , quiet = False ) + ["--" , "" ],
94
+ rebuild_count_expected = 1 ,
95
+ )
70
96
71
97
def test_cargo_miri_test ():
72
98
# rustdoc is not run on foreign targets
0 commit comments