@@ -54,34 +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 ( "-Dwarnings" . into ( ) ) ;
64
- program. args . push ( "-Dunused" . into ( ) ) ;
65
- program. args . push ( "-Ainternal_features" . into ( ) ) ;
66
- if let Ok ( extra_flags) = env:: var ( "MIRIFLAGS" ) {
67
- for flag in extra_flags. split_whitespace ( ) {
68
- program. args . push ( flag. into ( ) ) ;
69
- }
70
- }
71
- program. args . push ( "-Zui-testing" . into ( ) ) ;
72
- program. args . push ( "--target" . into ( ) ) ;
73
- program. args . push ( target. into ( ) ) ;
74
-
75
- // If we're on linux, and we're testing the extern-so functionality,
76
- // then build the shared object file for testing external C function calls
77
- // and push the relevant compiler flag.
78
- if cfg ! ( target_os = "linux" ) && path. starts_with ( "tests/extern-so/" ) {
79
- let so_file_path = build_so_for_c_ffi_tests ( ) ;
80
- let mut flag = std:: ffi:: OsString :: from ( "-Zmiri-extern-so-file=" ) ;
81
- flag. push ( so_file_path. into_os_string ( ) ) ;
82
- program. args . push ( flag) ;
83
- }
84
-
85
64
let mut config = Config {
86
65
target : Some ( target. to_owned ( ) ) ,
87
66
stderr_filters : STDERR . clone ( ) ,
@@ -119,17 +98,38 @@ fn run_tests(
119
98
with_dependencies : bool ,
120
99
tmpdir : & Path ,
121
100
) -> Result < ( ) > {
122
- let mut config = test_config ( target, path, mode, with_dependencies) ;
101
+ let mut config = miri_config ( target, path, mode, with_dependencies) ;
123
102
124
103
// Add a test env var to do environment communication tests.
125
104
config. program . envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
126
-
127
105
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
128
106
config. program . envs . push ( ( "MIRI_TEMP" . into ( ) , Some ( tmpdir. to_owned ( ) . into ( ) ) ) ) ;
129
-
130
107
// If a test ICEs, we want to see a backtrace.
131
108
config. program . envs . push ( ( "RUST_BACKTRACE" . into ( ) , Some ( "1" . into ( ) ) ) ) ;
132
109
110
+ // Add some flags we always want.
111
+ config. program . args . push ( "-Dwarnings" . into ( ) ) ;
112
+ config. program . args . push ( "-Dunused" . into ( ) ) ;
113
+ config. program . args . push ( "-Ainternal_features" . into ( ) ) ;
114
+ if let Ok ( extra_flags) = env:: var ( "MIRIFLAGS" ) {
115
+ for flag in extra_flags. split_whitespace ( ) {
116
+ config. program . args . push ( flag. into ( ) ) ;
117
+ }
118
+ }
119
+ config. program . args . push ( "-Zui-testing" . into ( ) ) ;
120
+ config. program . args . push ( "--target" . into ( ) ) ;
121
+ config. program . args . push ( target. into ( ) ) ;
122
+
123
+ // If we're on linux, and we're testing the extern-so functionality,
124
+ // then build the shared object file for testing external C function calls
125
+ // and push the relevant compiler flag.
126
+ if cfg ! ( target_os = "linux" ) && path. starts_with ( "tests/extern-so/" ) {
127
+ let so_file_path = build_so_for_c_ffi_tests ( ) ;
128
+ let mut flag = std:: ffi:: OsString :: from ( "-Zmiri-extern-so-file=" ) ;
129
+ flag. push ( so_file_path. into_os_string ( ) ) ;
130
+ config. program . args . push ( flag) ;
131
+ }
132
+
133
133
// Handle command-line arguments.
134
134
let args = ui_test:: Args :: test ( ) ?;
135
135
let default_bless = env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
@@ -292,13 +292,12 @@ fn main() -> Result<()> {
292
292
293
293
fn run_dep_mode ( target : String , mut args : impl Iterator < Item = OsString > ) -> Result < ( ) > {
294
294
let path = args. next ( ) . expect ( "./miri run-dep must be followed by a file name" ) ;
295
- let mut config = test_config (
295
+ let config = miri_config (
296
296
& target,
297
297
"" ,
298
298
Mode :: Yolo { rustfix : RustfixMode :: Disabled } ,
299
299
/* with dependencies */ true ,
300
300
) ;
301
- config. program . args . clear ( ) ; // We want to give the user full control over flags
302
301
let dep_args = config. build_dependencies ( ) ?;
303
302
304
303
let mut cmd = config. program . build ( & config. out_dir ) ;
0 commit comments