@@ -3,19 +3,24 @@ extern crate compiletest_rs as compiletest;
3
3
use std:: path:: { PathBuf , Path } ;
4
4
use std:: io:: Write ;
5
5
6
- fn compile_fail ( sysroot : & Path ) {
7
- let flags = format ! ( "--sysroot {} -Dwarnings" , sysroot. to_str( ) . expect( "non utf8 path" ) ) ;
8
- for_all_targets ( sysroot, |target| {
9
- let mut config = compiletest:: default_config ( ) ;
10
- config. host_rustcflags = Some ( flags. clone ( ) ) ;
11
- config. mode = "compile-fail" . parse ( ) . expect ( "Invalid mode" ) ;
12
- config. run_lib_path = Path :: new ( sysroot) . join ( "lib" ) . join ( "rustlib" ) . join ( & target) . join ( "lib" ) ;
13
- config. rustc_path = "target/debug/miri" . into ( ) ;
14
- config. src_base = PathBuf :: from ( "tests/compile-fail" . to_string ( ) ) ;
15
- config. target = target. to_owned ( ) ;
16
- config. target_rustcflags = Some ( flags. clone ( ) ) ;
17
- compiletest:: run_tests ( & config) ;
18
- } ) ;
6
+ fn compile_fail ( sysroot : & Path , path : & str , target : & str , host : & str , fullmir : bool ) {
7
+ let mut config = compiletest:: default_config ( ) ;
8
+ config. mode = "compile-fail" . parse ( ) . expect ( "Invalid mode" ) ;
9
+ config. rustc_path = "target/debug/miri" . into ( ) ;
10
+ if fullmir {
11
+ if host != target {
12
+ // skip fullmir on nonhost
13
+ return ;
14
+ }
15
+ let sysroot = Path :: new ( & std:: env:: var ( "HOME" ) . unwrap ( ) ) . join ( ".xargo" ) . join ( "HOST" ) ;
16
+ config. target_rustcflags = Some ( format ! ( "--sysroot {}" , sysroot. to_str( ) . unwrap( ) ) ) ;
17
+ config. src_base = PathBuf :: from ( path. to_string ( ) ) ;
18
+ } else {
19
+ config. target_rustcflags = Some ( format ! ( "--sysroot {}" , sysroot. to_str( ) . unwrap( ) ) ) ;
20
+ config. src_base = PathBuf :: from ( path. to_string ( ) ) ;
21
+ }
22
+ config. target = target. to_owned ( ) ;
23
+ compiletest:: run_tests ( & config) ;
19
24
}
20
25
21
26
fn run_pass ( ) {
@@ -35,6 +40,10 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool) {
35
40
config. host = host. to_owned ( ) ;
36
41
config. rustc_path = PathBuf :: from ( "target/debug/miri" ) ;
37
42
if fullmir {
43
+ if host != target {
44
+ // skip fullmir on nonhost
45
+ return ;
46
+ }
38
47
let sysroot = Path :: new ( & std:: env:: var ( "HOME" ) . unwrap ( ) ) . join ( ".xargo" ) . join ( "HOST" ) ;
39
48
config. target_rustcflags = Some ( format ! ( "--sysroot {}" , sysroot. to_str( ) . unwrap( ) ) ) ;
40
49
}
@@ -203,9 +212,10 @@ fn compile_test() {
203
212
run_pass ( ) ;
204
213
for_all_targets ( sysroot, |target| {
205
214
miri_pass ( "tests/run-pass" , & target, host, false ) ;
215
+ compile_fail ( sysroot, "tests/compile-fail" , & target, host, false ) ;
206
216
} ) ;
207
217
miri_pass ( "tests/run-pass-fullmir" , host, host, true ) ;
208
- compile_fail ( sysroot) ;
218
+ compile_fail ( sysroot, "tests/compile-fail-fullmir" , host , host , true ) ;
209
219
}
210
220
}
211
221
0 commit comments