@@ -54,41 +54,13 @@ fn build_so_for_c_ffi_tests() -> PathBuf {
54
54
so_file_path
55
55
}
56
56
57
- fn test_config ( target : & str , path : & str , mode : Mode , with_dependencies : bool ) -> Config {
57
+ /// Does *not* set any args or env vars, since it is shared between the test runner and
58
+ /// run_dep_mode.
59
+ fn miri_config ( target : & str , path : & str , mode : Mode , with_dependencies : bool ) -> Config {
58
60
// Miri is rustc-like, so we create a default builder for rustc and modify it
59
61
let mut program = CommandBuilder :: rustc ( ) ;
60
62
program. program = miri_path ( ) ;
61
63
62
- // Add some flags we always want.
63
- program. args . push (
64
- format ! (
65
- "--sysroot={}" ,
66
- env:: var( "MIRI_SYSROOT" ) . expect( "MIRI_SYSROOT must be set to run the ui test suite" )
67
- )
68
- . into ( ) ,
69
- ) ;
70
- program. args . push ( "-Dwarnings" . into ( ) ) ;
71
- program. args . push ( "-Dunused" . into ( ) ) ;
72
- program. args . push ( "-Ainternal_features" . into ( ) ) ;
73
- if let Ok ( extra_flags) = env:: var ( "MIRIFLAGS" ) {
74
- for flag in extra_flags. split_whitespace ( ) {
75
- program. args . push ( flag. into ( ) ) ;
76
- }
77
- }
78
- program. args . push ( "-Zui-testing" . into ( ) ) ;
79
- program. args . push ( "--target" . into ( ) ) ;
80
- program. args . push ( target. into ( ) ) ;
81
-
82
- // If we're on linux, and we're testing the extern-so functionality,
83
- // then build the shared object file for testing external C function calls
84
- // and push the relevant compiler flag.
85
- if cfg ! ( target_os = "linux" ) && path. starts_with ( "tests/extern-so/" ) {
86
- let so_file_path = build_so_for_c_ffi_tests ( ) ;
87
- let mut flag = std:: ffi:: OsString :: from ( "-Zmiri-extern-so-file=" ) ;
88
- flag. push ( so_file_path. into_os_string ( ) ) ;
89
- program. args . push ( flag) ;
90
- }
91
-
92
64
let mut config = Config {
93
65
target : Some ( target. to_owned ( ) ) ,
94
66
stderr_filters : STDERR . clone ( ) ,
@@ -126,17 +98,45 @@ fn run_tests(
126
98
with_dependencies : bool ,
127
99
tmpdir : & Path ,
128
100
) -> Result < ( ) > {
129
- let mut config = test_config ( target, path, mode, with_dependencies) ;
101
+ let mut config = miri_config ( target, path, mode, with_dependencies) ;
130
102
131
103
// Add a test env var to do environment communication tests.
132
104
config. program . envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
133
-
134
105
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
135
106
config. program . envs . push ( ( "MIRI_TEMP" . into ( ) , Some ( tmpdir. to_owned ( ) . into ( ) ) ) ) ;
136
-
137
107
// If a test ICEs, we want to see a backtrace.
138
108
config. program . envs . push ( ( "RUST_BACKTRACE" . into ( ) , Some ( "1" . into ( ) ) ) ) ;
139
109
110
+ // Add some flags we always want.
111
+ config. program . args . push (
112
+ format ! (
113
+ "--sysroot={}" ,
114
+ env:: var( "MIRI_SYSROOT" ) . expect( "MIRI_SYSROOT must be set to run the ui test suite" )
115
+ )
116
+ . into ( ) ,
117
+ ) ;
118
+ config. program . args . push ( "-Dwarnings" . into ( ) ) ;
119
+ config. program . args . push ( "-Dunused" . into ( ) ) ;
120
+ config. program . args . push ( "-Ainternal_features" . into ( ) ) ;
121
+ if let Ok ( extra_flags) = env:: var ( "MIRIFLAGS" ) {
122
+ for flag in extra_flags. split_whitespace ( ) {
123
+ config. program . args . push ( flag. into ( ) ) ;
124
+ }
125
+ }
126
+ config. program . args . push ( "-Zui-testing" . into ( ) ) ;
127
+ config. program . args . push ( "--target" . into ( ) ) ;
128
+ config. program . args . push ( target. into ( ) ) ;
129
+
130
+ // If we're on linux, and we're testing the extern-so functionality,
131
+ // then build the shared object file for testing external C function calls
132
+ // and push the relevant compiler flag.
133
+ if cfg ! ( target_os = "linux" ) && path. starts_with ( "tests/extern-so/" ) {
134
+ let so_file_path = build_so_for_c_ffi_tests ( ) ;
135
+ let mut flag = std:: ffi:: OsString :: from ( "-Zmiri-extern-so-file=" ) ;
136
+ flag. push ( so_file_path. into_os_string ( ) ) ;
137
+ config. program . args . push ( flag) ;
138
+ }
139
+
140
140
// Handle command-line arguments.
141
141
let args = ui_test:: Args :: test ( ) ?;
142
142
let default_bless = env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
@@ -299,13 +299,12 @@ fn main() -> Result<()> {
299
299
300
300
fn run_dep_mode ( target : String , mut args : impl Iterator < Item = OsString > ) -> Result < ( ) > {
301
301
let path = args. next ( ) . expect ( "./miri run-dep must be followed by a file name" ) ;
302
- let mut config = test_config (
302
+ let config = miri_config (
303
303
& target,
304
304
"" ,
305
305
Mode :: Yolo { rustfix : RustfixMode :: Disabled } ,
306
306
/* with dependencies */ true ,
307
307
) ;
308
- config. program . args . clear ( ) ; // We want to give the user full control over flags
309
308
let dep_args = config. build_dependencies ( ) ?;
310
309
311
310
let mut cmd = config. program . build ( & config. out_dir ) ;
0 commit comments