@@ -24,9 +24,10 @@ fn rustc_lib_path() -> PathBuf {
24
24
option_env ! ( "RUSTC_LIB_PATH" ) . unwrap ( ) . into ( )
25
25
}
26
26
27
- fn run_tests ( mode : & str , path : & str , target : & str , mut flags : Vec < String > ) {
27
+ fn run_tests ( mode : & str , path : & str , target : & str ) {
28
28
let in_rustc_test_suite = rustc_test_suite ( ) . is_some ( ) ;
29
29
// Add some flags we always want.
30
+ let mut flags = Vec :: new ( ) ;
30
31
flags. push ( "--edition 2018" . to_owned ( ) ) ;
31
32
if in_rustc_test_suite {
32
33
// Less aggressive warnings to make the rustc toolstate management less painful.
@@ -38,6 +39,12 @@ fn run_tests(mode: &str, path: &str, target: &str, mut flags: Vec<String>) {
38
39
if let Ok ( sysroot) = std:: env:: var ( "MIRI_SYSROOT" ) {
39
40
flags. push ( format ! ( "--sysroot {}" , sysroot) ) ;
40
41
}
42
+ if let Ok ( extra_flags) = std:: env:: var ( "MIRI_TEST_FLAGS" ) {
43
+ flags. push ( extra_flags) ;
44
+ }
45
+
46
+ let flags = flags. join ( " " ) ;
47
+ eprintln ! ( " Compiler flags: {}" , flags) ;
41
48
42
49
// The rest of the configuration.
43
50
let mut config = compiletest:: Config :: default ( ) . tempdir ( ) ;
@@ -51,48 +58,36 @@ fn run_tests(mode: &str, path: &str, target: &str, mut flags: Vec<String>) {
51
58
config. host = get_host ( ) ;
52
59
config. src_base = PathBuf :: from ( path) ;
53
60
config. target = target. to_owned ( ) ;
54
- config. target_rustcflags = Some ( flags. join ( " " ) ) ;
61
+ config. target_rustcflags = Some ( flags) ;
55
62
compiletest:: run_tests ( & config) ;
56
63
}
57
64
58
- fn compile_fail ( path : & str , target : & str , opt : bool ) {
59
- let opt_str = if opt { " with optimizations" } else { "" } ;
65
+ fn compile_fail ( path : & str , target : & str ) {
60
66
eprintln ! (
61
67
"{}" ,
62
68
format!(
63
- "## Running compile-fail tests in {} against miri for target {}{} " ,
64
- path, target, opt_str
69
+ "## Running compile-fail tests in {} against miri for target {}" ,
70
+ path, target
65
71
)
66
72
. green( )
67
73
. bold( )
68
74
) ;
69
75
70
- let mut flags = Vec :: new ( ) ;
71
- if opt {
72
- flags. push ( "-Zmir-opt-level=3" . to_owned ( ) ) ;
73
- }
74
-
75
- run_tests ( "compile-fail" , path, target, flags) ;
76
+ run_tests ( "compile-fail" , path, target) ;
76
77
}
77
78
78
- fn miri_pass ( path : & str , target : & str , opt : bool ) {
79
- let opt_str = if opt { " with optimizations" } else { "" } ;
79
+ fn miri_pass ( path : & str , target : & str ) {
80
80
eprintln ! (
81
81
"{}" ,
82
82
format!(
83
- "## Running run-pass tests in {} against miri for target {}{} " ,
84
- path, target, opt_str
83
+ "## Running run-pass tests in {} against miri for target {}" ,
84
+ path, target
85
85
)
86
86
. green( )
87
87
. bold( )
88
88
) ;
89
89
90
- let mut flags = Vec :: new ( ) ;
91
- if opt {
92
- flags. push ( "-Zmir-opt-level=3" . to_owned ( ) ) ;
93
- }
94
-
95
- run_tests ( "ui" , path, target, flags) ;
90
+ run_tests ( "ui" , path, target) ;
96
91
}
97
92
98
93
fn get_host ( ) -> String {
@@ -112,21 +107,11 @@ fn get_target() -> String {
112
107
std:: env:: var ( "MIRI_TEST_TARGET" ) . unwrap_or_else ( |_| get_host ( ) )
113
108
}
114
109
115
- fn run_pass_miri ( opt : bool ) {
116
- miri_pass ( "tests/run-pass" , & get_target ( ) , opt) ;
117
- }
118
-
119
- fn compile_fail_miri ( opt : bool ) {
120
- compile_fail ( "tests/compile-fail" , & get_target ( ) , opt) ;
121
- }
122
-
123
110
fn test_runner ( _tests : & [ & ( ) ] ) {
124
- // Add a test env var to do environment communication tests
111
+ // Add a test env var to do environment communication tests.
125
112
std:: env:: set_var ( "MIRI_ENV_VAR_TEST" , "0" ) ;
126
113
127
- run_pass_miri ( false ) ;
128
- run_pass_miri ( true ) ;
129
-
130
- compile_fail_miri ( false ) ;
131
- compile_fail_miri ( true ) ;
114
+ let target = get_target ( ) ;
115
+ miri_pass ( "tests/run-pass" , & target) ;
116
+ compile_fail ( "tests/compile-fail" , & target) ;
132
117
}
0 commit comments