5
5
and the working directory to contain the cargo-miri-test project.
6
6
'''
7
7
8
- import sys , subprocess
8
+ import sys , subprocess , os
9
9
10
10
def fail (msg ):
11
11
print ("TEST FAIL: {}" .format (msg ))
12
12
sys .exit (1 )
13
13
14
+ def cargo_miri (cmd ):
15
+ args = ["cargo" , "miri" , cmd , "-q" ]
16
+ if 'MIRI_TEST_TARGET' in os .environ :
17
+ args += ["--target" , os .environ ['MIRI_TEST_TARGET' ]]
18
+ return args
19
+
14
20
def test (name , cmd , stdout_ref , stderr_ref ):
15
21
print ("==> Testing `{}` <==" .format (name ))
16
22
## Call `cargo miri`, capture all output
@@ -36,16 +42,22 @@ def test(name, cmd, stdout_ref, stderr_ref):
36
42
fail ("stderr does not match reference" )
37
43
38
44
def test_cargo_miri_run ():
39
- test ("cargo miri run" , ["cargo" , "miri" , "run" , "-q" ], "stdout.ref" , "stderr.ref" )
45
+ test ("cargo miri run" ,
46
+ cargo_miri ("run" ),
47
+ "stdout.ref" , "stderr.ref"
48
+ )
40
49
test ("cargo miri run (with arguments)" ,
41
- [ "cargo" , "miri" , " run", "-q" , "--" , "--" , "hello world" , '"hello world"' ],
50
+ cargo_miri ( " run") + [ "--" , "--" , "hello world" , '"hello world"' ],
42
51
"stdout.ref" , "stderr.ref2"
43
52
)
44
53
45
54
def test_cargo_miri_test ():
46
- test ("cargo miri test" , ["cargo" , "miri" , "test" , "-q" , "--" , "-Zmiri-seed=feed" ], "test.stdout.ref" , "test.stderr.ref" )
55
+ test ("cargo miri test" ,
56
+ cargo_miri ("test" ) + ["--" , "-Zmiri-seed=feed" ],
57
+ "test.stdout.ref" , "test.stderr.ref"
58
+ )
47
59
test ("cargo miri test (with filter)" ,
48
- [ "cargo" , "miri" , " test", "-q" , "--" , "--" , "impl" ],
60
+ cargo_miri ( " test") + [ "--" , "--" , "impl" ],
49
61
"test.stdout.ref2" , "test.stderr.ref"
50
62
)
51
63
0 commit comments