@@ -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,49 @@ 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
+
99
+ // FIXME: this is replacement of removed ui_test feature for masking path with $DIR:
100
+ // https://github.com/oli-obk/ui_test/pull/180
101
+ // Can't use path_filter or other simpler filter because 'path' here is path to test suite,
102
+ // not path to test, i.e. "tests/pass".
103
+ // regex is oversimplified and can probably fail in corner cases.
104
+ config. filter ( path, "$$DIR" ) ;
105
+ config. filter ( r"\$DIR[\\/]([\w-]+[\\/])*" , "$$DIR/" ) ;
106
+
107
+ // keep in sync with `./miri run`
108
+ const EDITION : & str = "2021" ;
109
+ config. comment_defaults . base ( ) . edition = Spanned :: dummy ( EDITION . to_owned ( ) ) . into ( ) ;
83
110
84
111
if with_dependencies {
85
112
// Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
@@ -130,9 +157,11 @@ fn run_tests(
130
157
}
131
158
}
132
159
config. program . args . push ( "-Zui-testing" . into ( ) ) ;
133
- config. program . args . push ( "--target" . into ( ) ) ;
134
- config. program . args . push ( target. into ( ) ) ;
135
160
161
+ if config. host != config. target {
162
+ config. program . args . push ( "--target" . into ( ) ) ;
163
+ config. program . args . push ( target. into ( ) ) ;
164
+ }
136
165
// If we're testing the native-lib functionality, then build the shared object file for testing
137
166
// external C function calls and push the relevant compiler flag.
138
167
if path. starts_with ( "tests/native-lib/" ) {
@@ -143,14 +172,12 @@ fn run_tests(
143
172
}
144
173
145
174
// 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
- }
175
+ let mut args = ui_test:: Args :: test ( ) ?;
176
+ args. bless |= env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
177
+ config. with_args ( & args) ;
178
+
152
179
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" ) ;
180
+ assert ! ( !args . bless , "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
154
181
config. output_conflict_handling = OutputConflictHandling :: Ignore ;
155
182
}
156
183
eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
0 commit comments