@@ -7,6 +7,7 @@ use std::{env, process::Command};
7
7
use colored:: * ;
8
8
use regex:: bytes:: Regex ;
9
9
use ui_test:: color_eyre:: eyre:: { Context , Result } ;
10
+ use ui_test:: spanned:: Spanned ;
10
11
use ui_test:: {
11
12
status_emitter, CommandBuilder , Config , Format , Match , Mode , OutputConflictHandling ,
12
13
RustfixMode ,
@@ -63,23 +64,42 @@ fn build_native_lib() -> PathBuf {
63
64
/// Does *not* set any args or env vars, since it is shared between the test runner and
64
65
/// run_dep_mode.
65
66
fn miri_config ( target : & str , path : & str , mode : Mode , with_dependencies : bool ) -> Config {
67
+ // FIXME: in ui_test 0.22.3+ this is method on Config.
68
+ fn fill_host_and_target ( cfg : & mut Config ) {
69
+ if cfg. host . is_none ( ) {
70
+ cfg. host = Some ( get_host ( ) ) ;
71
+ }
72
+ if cfg. target . is_none ( ) {
73
+ cfg. target = Some ( cfg. host . clone ( ) . unwrap ( ) ) ;
74
+ }
75
+ }
66
76
// Miri is rustc-like, so we create a default builder for rustc and modify it
67
77
let mut program = CommandBuilder :: rustc ( ) ;
68
78
program. program = miri_path ( ) ;
69
79
70
80
let mut config = Config {
71
81
target : Some ( target. to_owned ( ) ) ,
72
- stderr_filters : stderr_filters ( ) . into ( ) ,
73
- stdout_filters : stdout_filters ( ) . into ( ) ,
74
- mode,
75
82
program,
76
83
out_dir : PathBuf :: from ( std:: env:: var_os ( "CARGO_TARGET_DIR" ) . unwrap ( ) ) . join ( "ui" ) ,
77
- edition : Some ( "2021" . into ( ) ) , // keep in sync with `./miri run`
78
84
threads : std:: env:: var ( "MIRI_TEST_THREADS" )
79
85
. ok ( )
80
86
. map ( |threads| NonZero :: new ( threads. parse ( ) . unwrap ( ) ) . unwrap ( ) ) ,
87
+ output_conflict_handling : OutputConflictHandling :: Error ,
88
+ bless_command : Some ( "./miri test --bless" . into ( ) ) ,
81
89
..Config :: rustc ( path)
82
90
} ;
91
+ fill_host_and_target ( & mut config) ;
92
+
93
+ config. comment_defaults . base ( ) . normalize_stdout =
94
+ stdout_filters ( ) . iter ( ) . cloned ( ) . map ( |( m, v) | ( m, v. into ( ) ) ) . collect ( ) ;
95
+ config. comment_defaults . base ( ) . normalize_stderr =
96
+ stderr_filters ( ) . iter ( ) . cloned ( ) . map ( |( m, v) | ( m, v. into ( ) ) ) . collect ( ) ;
97
+ config. comment_defaults . base ( ) . mode = Spanned :: dummy ( mode) . into ( ) ;
98
+ config. filter ( path, "$$DIR" ) ;
99
+
100
+ // keep in sync with `./miri run`
101
+ const EDITION : & str = "2021" ;
102
+ config. comment_defaults . base ( ) . edition = Spanned :: dummy ( EDITION . to_owned ( ) ) . into ( ) ;
83
103
84
104
if with_dependencies {
85
105
// Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
@@ -130,9 +150,11 @@ fn run_tests(
130
150
}
131
151
}
132
152
config. program . args . push ( "-Zui-testing" . into ( ) ) ;
133
- config. program . args . push ( "--target" . into ( ) ) ;
134
- config. program . args . push ( target. into ( ) ) ;
135
153
154
+ if config. host != config. target {
155
+ config. program . args . push ( "--target" . into ( ) ) ;
156
+ config. program . args . push ( target. into ( ) ) ;
157
+ }
136
158
// If we're testing the native-lib functionality, then build the shared object file for testing
137
159
// external C function calls and push the relevant compiler flag.
138
160
if path. starts_with ( "tests/native-lib/" ) {
@@ -143,14 +165,12 @@ fn run_tests(
143
165
}
144
166
145
167
// Handle command-line arguments.
146
- let args = ui_test:: Args :: test ( ) ?;
147
- let default_bless = env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
148
- config. with_args ( & args, default_bless) ;
149
- if let OutputConflictHandling :: Error ( msg) = & mut config. output_conflict_handling {
150
- * msg = "./miri test --bless" . into ( ) ;
151
- }
168
+ let mut args = ui_test:: Args :: test ( ) ?;
169
+ args. bless |= env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
170
+ config. with_args ( & args) ;
171
+
152
172
if env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) {
153
- assert ! ( !default_bless , "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
173
+ assert ! ( !args . bless , "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
154
174
config. output_conflict_handling = OutputConflictHandling :: Ignore ;
155
175
}
156
176
eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
0 commit comments