@@ -24,9 +24,10 @@ fn rustc_lib_path() -> PathBuf {
2424 option_env ! ( "RUSTC_LIB_PATH" ) . unwrap ( ) . into ( )
2525}
2626
27- fn run_tests ( mode : & str , path : & str , target : & str , mut flags : Vec < String > ) {
27+ fn run_tests ( mode : & str , path : & str , target : & str ) {
2828 let in_rustc_test_suite = rustc_test_suite ( ) . is_some ( ) ;
2929 // Add some flags we always want.
30+ let mut flags = Vec :: new ( ) ;
3031 flags. push ( "--edition 2018" . to_owned ( ) ) ;
3132 if in_rustc_test_suite {
3233 // 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>) {
3839 if let Ok ( sysroot) = std:: env:: var ( "MIRI_SYSROOT" ) {
3940 flags. push ( format ! ( "--sysroot {}" , sysroot) ) ;
4041 }
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) ;
4148
4249 // The rest of the configuration.
4350 let mut config = compiletest:: Config :: default ( ) . tempdir ( ) ;
@@ -51,48 +58,36 @@ fn run_tests(mode: &str, path: &str, target: &str, mut flags: Vec<String>) {
5158 config. host = get_host ( ) ;
5259 config. src_base = PathBuf :: from ( path) ;
5360 config. target = target. to_owned ( ) ;
54- config. target_rustcflags = Some ( flags. join ( " " ) ) ;
61+ config. target_rustcflags = Some ( flags) ;
5562 compiletest:: run_tests ( & config) ;
5663}
5764
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 ) {
6066 eprintln ! (
6167 "{}" ,
6268 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
6571 )
6672 . green( )
6773 . bold( )
6874 ) ;
6975
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) ;
7677}
7778
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 ) {
8080 eprintln ! (
8181 "{}" ,
8282 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
8585 )
8686 . green( )
8787 . bold( )
8888 ) ;
8989
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) ;
9691}
9792
9893fn get_host ( ) -> String {
@@ -112,21 +107,11 @@ fn get_target() -> String {
112107 std:: env:: var ( "MIRI_TEST_TARGET" ) . unwrap_or_else ( |_| get_host ( ) )
113108}
114109
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-
123110fn 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.
125112 std:: env:: set_var ( "MIRI_ENV_VAR_TEST" , "0" ) ;
126113
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) ;
132117}
0 commit comments