@@ -9,23 +9,11 @@ use colored::*;
9
9
use compiletest_rs as compiletest;
10
10
11
11
fn 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" ) ) )
25
13
}
26
14
27
15
fn 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 ( ) ;
29
17
// Add some flags we always want.
30
18
let mut flags = Vec :: new ( ) ;
31
19
flags. push ( "--edition 2018" . to_owned ( ) ) ;
@@ -50,9 +38,9 @@ fn run_tests(mode: &str, path: &str, target: &str) {
50
38
let mut config = compiletest:: Config :: default ( ) . tempdir ( ) ;
51
39
config. mode = mode. parse ( ) . expect ( "Invalid mode" ) ;
52
40
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 ) ;
56
44
}
57
45
config. filter = env:: args ( ) . nth ( 1 ) ;
58
46
config. host = get_host ( ) ;
@@ -65,12 +53,9 @@ fn run_tests(mode: &str, path: &str, target: &str) {
65
53
fn compile_fail ( path : & str , target : & str ) {
66
54
eprintln ! (
67
55
"{}" ,
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( )
74
59
) ;
75
60
76
61
run_tests ( "compile-fail" , path, target) ;
@@ -79,27 +64,18 @@ fn compile_fail(path: &str, target: &str) {
79
64
fn miri_pass ( path : & str , target : & str ) {
80
65
eprintln ! (
81
66
"{}" ,
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( )
88
70
) ;
89
71
90
72
run_tests ( "ui" , path, target) ;
91
73
}
92
74
93
75
fn 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" ) ;
103
79
version_meta. host
104
80
}
105
81
0 commit comments