@@ -9,23 +9,11 @@ use colored::*;
99use compiletest_rs as compiletest;
1010
1111fn miri_path ( ) -> PathBuf {
12- if rustc_test_suite ( ) . is_some ( ) {
13- PathBuf :: from ( option_env ! ( "MIRI_PATH" ) . unwrap ( ) )
14- } else {
15- PathBuf :: from ( env ! ( "CARGO_BIN_EXE_miri" ) )
16- }
17- }
18-
19- fn rustc_test_suite ( ) -> Option < PathBuf > {
20- option_env ! ( "RUSTC_TEST_SUITE" ) . map ( PathBuf :: from)
21- }
22-
23- fn rustc_lib_path ( ) -> PathBuf {
24- option_env ! ( "RUSTC_LIB_PATH" ) . unwrap ( ) . into ( )
12+ PathBuf :: from ( option_env ! ( "MIRI_PATH" ) . unwrap_or ( env ! ( "CARGO_BIN_EXE_miri" ) ) )
2513}
2614
2715fn run_tests ( mode : & str , path : & str , target : & str ) {
28- let in_rustc_test_suite = rustc_test_suite ( ) . is_some ( ) ;
16+ let in_rustc_test_suite = option_env ! ( "RUSTC_STAGE" ) . is_some ( ) ;
2917 // Add some flags we always want.
3018 let mut flags = Vec :: new ( ) ;
3119 flags. push ( "--edition 2018" . to_owned ( ) ) ;
@@ -50,9 +38,9 @@ fn run_tests(mode: &str, path: &str, target: &str) {
5038 let mut config = compiletest:: Config :: default ( ) . tempdir ( ) ;
5139 config. mode = mode. parse ( ) . expect ( "Invalid mode" ) ;
5240 config. rustc_path = miri_path ( ) ;
53- if in_rustc_test_suite {
54- config. run_lib_path = rustc_lib_path ( ) ;
55- config. compile_lib_path = rustc_lib_path ( ) ;
41+ if let Some ( lib_path ) = option_env ! ( "RUSTC_LIB_PATH" ) {
42+ config. run_lib_path = PathBuf :: from ( lib_path ) ;
43+ config. compile_lib_path = PathBuf :: from ( lib_path ) ;
5644 }
5745 config. filter = env:: args ( ) . nth ( 1 ) ;
5846 config. host = get_host ( ) ;
@@ -65,12 +53,9 @@ fn run_tests(mode: &str, path: &str, target: &str) {
6553fn compile_fail ( path : & str , target : & str ) {
6654 eprintln ! (
6755 "{}" ,
68- format!(
69- "## Running compile-fail tests in {} against miri for target {}" ,
70- path, target
71- )
72- . green( )
73- . bold( )
56+ format!( "## Running compile-fail tests in {} against miri for target {}" , path, target)
57+ . green( )
58+ . bold( )
7459 ) ;
7560
7661 run_tests ( "compile-fail" , path, target) ;
@@ -79,27 +64,18 @@ fn compile_fail(path: &str, target: &str) {
7964fn miri_pass ( path : & str , target : & str ) {
8065 eprintln ! (
8166 "{}" ,
82- format!(
83- "## Running run-pass tests in {} against miri for target {}" ,
84- path, target
85- )
86- . green( )
87- . bold( )
67+ format!( "## Running run-pass tests in {} against miri for target {}" , path, target)
68+ . green( )
69+ . bold( )
8870 ) ;
8971
9072 run_tests ( "ui" , path, target) ;
9173}
9274
9375fn get_host ( ) -> String {
94- let rustc = rustc_test_suite ( ) . unwrap_or ( PathBuf :: from ( "rustc" ) ) ;
95- let rustc_version = std:: process:: Command :: new ( rustc)
96- . arg ( "-vV" )
97- . output ( )
98- . expect ( "rustc not found for -vV" )
99- . stdout ;
100- let rustc_version = std:: str:: from_utf8 ( & rustc_version) . expect ( "rustc -vV is not utf8" ) ;
101- let version_meta = rustc_version:: version_meta_for ( & rustc_version)
102- . expect ( "failed to parse rustc version info" ) ;
76+ let version_meta =
77+ rustc_version:: VersionMeta :: for_command ( std:: process:: Command :: new ( miri_path ( ) ) )
78+ . expect ( "failed to parse rustc version info" ) ;
10379 version_meta. host
10480}
10581
0 commit comments