@@ -8,6 +8,12 @@ fn miri_path() -> PathBuf {
88 PathBuf :: from ( option_env ! ( "MIRI" ) . unwrap_or ( env ! ( "CARGO_BIN_EXE_miri" ) ) )
99}
1010
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+
1117// Build the shared object file for testing external C function calls.
1218fn build_so_for_c_ffi_tests ( ) -> PathBuf {
1319 let cc = option_env ! ( "CC" ) . unwrap_or ( "cc" ) ;
@@ -37,14 +43,9 @@ fn build_so_for_c_ffi_tests() -> PathBuf {
3743 so_file_path
3844}
3945
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 < ( ) > {
4647 let mut config = Config {
47- target,
48+ target : Some ( target . to_owned ( ) ) ,
4849 stderr_filters : STDERR . clone ( ) ,
4950 stdout_filters : STDOUT . clone ( ) ,
5051 root_dir : PathBuf :: from ( path) ,
@@ -179,13 +180,8 @@ enum Dependencies {
179180
180181use Dependencies :: * ;
181182
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}" ) ;
189185 eprintln ! ( "{}" , msg. green( ) . bold( ) ) ;
190186
191187 let with_dependencies = match with_dependencies {
@@ -195,25 +191,31 @@ fn ui(mode: Mode, path: &str, with_dependencies: Dependencies) -> Result<()> {
195191 run_tests ( mode, path, target, with_dependencies)
196192}
197193
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 )
200196}
201197
202198fn main ( ) -> Result < ( ) > {
203199 ui_test:: color_eyre:: install ( ) ?;
200+ let target = get_target ( ) ;
204201
205202 // Add a test env var to do environment communication tests.
206203 env:: set_var ( "MIRI_ENV_VAR_TEST" , "0" ) ;
207204 // Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
208205 env:: set_var ( "MIRI_TEMP" , env:: temp_dir ( ) ) ;
209206
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 ) ?;
214211 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+ ) ?;
217219 }
218220
219221 Ok ( ( ) )
0 commit comments