@@ -8,6 +8,12 @@ fn miri_path() -> PathBuf {
8
8
PathBuf :: from ( option_env ! ( "MIRI" ) . unwrap_or ( env ! ( "CARGO_BIN_EXE_miri" ) ) )
9
9
}
10
10
11
+ fn get_host ( ) -> String {
12
+ rustc_version:: VersionMeta :: for_command ( std:: process:: Command :: new ( miri_path ( ) ) )
13
+ . expect ( "failed to parse rustc version info" )
14
+ . host
15
+ }
16
+
11
17
// Build the shared object file for testing external C function calls.
12
18
fn build_so_for_c_ffi_tests ( ) -> PathBuf {
13
19
let cc = option_env ! ( "CC" ) . unwrap_or ( "cc" ) ;
@@ -37,14 +43,9 @@ fn build_so_for_c_ffi_tests() -> PathBuf {
37
43
so_file_path
38
44
}
39
45
40
- fn run_tests (
41
- mode : Mode ,
42
- path : & str ,
43
- target : Option < String > ,
44
- with_dependencies : bool ,
45
- ) -> Result < ( ) > {
46
+ fn run_tests ( mode : Mode , path : & str , target : & str , with_dependencies : bool ) -> Result < ( ) > {
46
47
let mut config = Config {
47
- target,
48
+ target : Some ( target . to_owned ( ) ) ,
48
49
stderr_filters : STDERR . clone ( ) ,
49
50
stdout_filters : STDOUT . clone ( ) ,
50
51
root_dir : PathBuf :: from ( path) ,
@@ -179,13 +180,8 @@ enum Dependencies {
179
180
180
181
use Dependencies :: * ;
181
182
182
- fn ui ( mode : Mode , path : & str , with_dependencies : Dependencies ) -> Result < ( ) > {
183
- let target = get_target ( ) ;
184
-
185
- let msg = format ! (
186
- "## Running ui tests in {path} against miri for {}" ,
187
- target. as_deref( ) . unwrap_or( "host" )
188
- ) ;
183
+ fn ui ( mode : Mode , path : & str , target : & str , with_dependencies : Dependencies ) -> Result < ( ) > {
184
+ let msg = format ! ( "## Running ui tests in {path} against miri for {target}" ) ;
189
185
eprintln ! ( "{}" , msg. green( ) . bold( ) ) ;
190
186
191
187
let with_dependencies = match with_dependencies {
@@ -195,25 +191,31 @@ fn ui(mode: Mode, path: &str, with_dependencies: Dependencies) -> Result<()> {
195
191
run_tests ( mode, path, target, with_dependencies)
196
192
}
197
193
198
- fn get_target ( ) -> Option < String > {
199
- env:: var ( "MIRI_TEST_TARGET" ) . ok ( )
194
+ fn get_target ( ) -> String {
195
+ env:: var ( "MIRI_TEST_TARGET" ) . ok ( ) . unwrap_or_else ( get_host )
200
196
}
201
197
202
198
fn main ( ) -> Result < ( ) > {
203
199
ui_test:: color_eyre:: install ( ) ?;
200
+ let target = get_target ( ) ;
204
201
205
202
// Add a test env var to do environment communication tests.
206
203
env:: set_var ( "MIRI_ENV_VAR_TEST" , "0" ) ;
207
204
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
208
205
env:: set_var ( "MIRI_TEMP" , env:: temp_dir ( ) ) ;
209
206
210
- ui ( Mode :: Pass , "tests/pass" , WithoutDependencies ) ?;
211
- ui ( Mode :: Pass , "tests/pass-dep" , WithDependencies ) ?;
212
- ui ( Mode :: Panic , "tests/panic" , WithDependencies ) ?;
213
- ui ( Mode :: Fail { require_patterns : true } , "tests/fail" , WithDependencies ) ?;
207
+ ui ( Mode :: Pass , "tests/pass" , & target , WithoutDependencies ) ?;
208
+ ui ( Mode :: Pass , "tests/pass-dep" , & target , WithDependencies ) ?;
209
+ ui ( Mode :: Panic , "tests/panic" , & target , WithDependencies ) ?;
210
+ ui ( Mode :: Fail { require_patterns : true } , "tests/fail" , & target , WithDependencies ) ?;
214
211
if cfg ! ( target_os = "linux" ) {
215
- ui ( Mode :: Pass , "tests/extern-so/pass" , WithoutDependencies ) ?;
216
- ui ( Mode :: Fail { require_patterns : true } , "tests/extern-so/fail" , WithoutDependencies ) ?;
212
+ ui ( Mode :: Pass , "tests/extern-so/pass" , & target, WithoutDependencies ) ?;
213
+ ui (
214
+ Mode :: Fail { require_patterns : true } ,
215
+ "tests/extern-so/fail" ,
216
+ & target,
217
+ WithoutDependencies ,
218
+ ) ?;
217
219
}
218
220
219
221
Ok ( ( ) )
0 commit comments