@@ -15,8 +15,10 @@ def fail(msg):
1515 print ("\n TEST FAIL: {}" .format (msg ))
1616 sys .exit (1 )
1717
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" ]
2022 if 'MIRI_TEST_TARGET' in os .environ :
2123 args += ["--target" , os .environ ['MIRI_TEST_TARGET' ]]
2224 return args
@@ -48,6 +50,25 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
4850 print ("--- END stderr ---" )
4951 fail ("exit code was {}" .format (p .returncode ))
5052
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+
5172def test_cargo_miri_run ():
5273 test ("`cargo miri run` (no isolation)" ,
5374 cargo_miri ("run" ),
@@ -67,6 +88,12 @@ def test_cargo_miri_run():
6788 "run.subcrate.stdout.ref" , "run.subcrate.stderr.ref" ,
6889 env = {'MIRIFLAGS' : "-Zmiri-disable-isolation" },
6990 )
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+ )
7097
7198def test_cargo_miri_test ():
7299 # rustdoc is not run on foreign targets
0 commit comments