1
- use std:: path:: Path ;
2
-
3
1
use anyhow:: Context ;
4
2
use camino:: { Utf8Path , Utf8PathBuf } ;
5
3
@@ -27,8 +25,6 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> {
27
25
let host_triple = env. host_tuple ( ) ;
28
26
let version = find_dist_version ( & dist_dir) ?;
29
27
30
- let channel = version_to_channel ( & version) ;
31
-
32
28
// Extract rustc, libstd, cargo and src archives to create the optimized sysroot
33
29
let rustc_dir = extract_dist_dir ( & format ! ( "rustc-{version}-{host_triple}" ) ) ?. join ( "rustc" ) ;
34
30
let libstd_dir = extract_dist_dir ( & format ! ( "rust-std-{version}-{host_triple}" ) ) ?
@@ -64,82 +60,98 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> {
64
60
. join ( format ! ( "llvm-config{}" , executable_extension( ) ) ) ;
65
61
assert ! ( llvm_config. is_file( ) ) ;
66
62
67
- let config_content = format ! (
68
- r#"
69
- profile = "user"
70
- change-id = 115898
71
-
72
- [rust]
73
- channel = "{channel}"
74
- verbose-tests = true
75
-
76
- [build]
77
- rustc = "{rustc}"
78
- cargo = "{cargo}"
79
- local-rebuild = true
80
-
81
- [target.{host_triple}]
82
- llvm-config = "{llvm_config}"
83
- "# ,
84
- rustc = rustc_path. to_string( ) . replace( '\\' , "/" ) ,
85
- cargo = cargo_path. to_string( ) . replace( '\\' , "/" ) ,
86
- llvm_config = llvm_config. to_string( ) . replace( '\\' , "/" )
87
- ) ;
88
- log:: info!( "Using following `bootstrap.toml` for running tests:\n {config_content}" ) ;
63
+ // let config_content = format!(
64
+ // r#"
65
+ // profile = "user"
66
+ // change-id = 115898
67
+ //
68
+ // [rust]
69
+ // channel = "{channel}"
70
+ // verbose-tests = true
71
+ //
72
+ // [build]
73
+ // rustc = "{rustc}"
74
+ // cargo = "{cargo}"
75
+ // local-rebuild = true
76
+ //
77
+ // [target.{host_triple}]
78
+ // llvm-config = "{llvm_config}"
79
+ // "#,
80
+ // rustc = rustc_path.to_string().replace('\\', "/"),
81
+ // cargo = cargo_path.to_string().replace('\\', "/"),
82
+ // llvm_config = llvm_config.to_string().replace('\\', "/")
83
+ // );
84
+ // log::info!("Using following `bootstrap.toml` for running tests:\n{config_content}");
85
+
86
+ let rustc = rustc_path. to_string ( ) . replace ( '\\' , "/" ) ;
87
+ let cargo = cargo_path. to_string ( ) . replace ( '\\' , "/" ) ;
88
+ let llvm_config = llvm_config. to_string ( ) . replace ( '\\' , "/" ) ;
89
89
90
90
// Simulate a stage 0 compiler with the extracted optimized dist artifacts.
91
- with_backed_up_file ( Path :: new ( "bootstrap.toml" ) , & config_content, || {
92
- let x_py = env. checkout_path ( ) . join ( "x.py" ) ;
93
- let mut args = vec ! [
94
- env. python_binary( ) ,
95
- x_py. as_str( ) ,
96
- "test" ,
97
- "--build" ,
98
- env. host_tuple( ) ,
99
- "--stage" ,
100
- "0" ,
101
- "tests/assembly" ,
102
- "tests/codegen" ,
103
- "tests/codegen-units" ,
104
- "tests/incremental" ,
105
- "tests/mir-opt" ,
106
- "tests/pretty" ,
107
- "tests/run-make/glibc-symbols-x86_64-unknown-linux-gnu" ,
108
- "tests/ui" ,
109
- "tests/crashes" ,
110
- ] ;
111
- for test_path in env. skipped_tests ( ) {
112
- args. extend ( [ "--skip" , test_path] ) ;
113
- }
114
- cmd ( & args)
115
- . env ( "COMPILETEST_FORCE_STAGE0" , "1" )
116
- // Also run dist-only tests
117
- . env ( "COMPILETEST_ENABLE_DIST_TESTS" , "1" )
118
- . run ( )
119
- . context ( "Cannot execute tests" )
120
- } )
121
- }
122
-
123
- /// Backup `path` (if it exists), then write `contents` into it, and then restore the original
124
- /// contents of the file.
125
- fn with_backed_up_file < F > ( path : & Path , contents : & str , func : F ) -> anyhow:: Result < ( ) >
126
- where
127
- F : FnOnce ( ) -> anyhow:: Result < ( ) > ,
128
- {
129
- let original_contents =
130
- if path. is_file ( ) { Some ( std:: fs:: read_to_string ( path) ?) } else { None } ;
131
-
132
- // Overwrite it with new contents
133
- std:: fs:: write ( path, contents) ?;
134
-
135
- let ret = func ( ) ;
136
-
137
- if let Some ( original_contents) = original_contents {
138
- std:: fs:: write ( path, original_contents) ?;
91
+ // with_backed_up_file(Path::new("bootstrap.toml"), &config_content, || {
92
+ let x_py = env. checkout_path ( ) . join ( "x.py" ) ;
93
+ let mut args = vec ! [
94
+ env. python_binary( ) . to_string( ) ,
95
+ x_py. as_str( ) . to_string( ) ,
96
+ "test" . to_string( ) ,
97
+ "--build" . to_string( ) ,
98
+ env. host_tuple( ) . to_string( ) ,
99
+ "--stage" . to_string( ) ,
100
+ "0" . to_string( ) ,
101
+ ] ;
102
+ args. push ( "--set" . to_string ( ) ) ;
103
+ args. push ( format ! ( "build.rustc={rustc}" ) ) ;
104
+ args. push ( "--set" . to_string ( ) ) ;
105
+ args. push ( format ! ( "build.cargo={cargo}" ) ) ;
106
+ args. push ( "--set" . to_string ( ) ) ;
107
+ args. push ( "build.local-rebuild=true" . to_string ( ) ) ;
108
+ args. push ( "--set" . to_string ( ) ) ;
109
+ args. push ( format ! ( "target.{host_triple}.llvm-config={llvm_config}" ) ) ;
110
+
111
+ args. extend ( [
112
+ "tests/assembly" . to_string ( ) ,
113
+ "tests/codegen" . to_string ( ) ,
114
+ "tests/codegen-units" . to_string ( ) ,
115
+ "tests/incremental" . to_string ( ) ,
116
+ "tests/mir-opt" . to_string ( ) ,
117
+ "tests/pretty" . to_string ( ) ,
118
+ "tests/run-make/glibc-symbols-x86_64-unknown-linux-gnu" . to_string ( ) ,
119
+ "tests/ui" . to_string ( ) ,
120
+ "tests/crashes" . to_string ( ) ,
121
+ ] ) ;
122
+ for test_path in env. skipped_tests ( ) {
123
+ args. extend ( [ "--skip" . to_string ( ) , test_path. to_string ( ) ] ) ;
139
124
}
140
-
141
- ret
125
+ cmd ( & [ env. python_binary ( ) , env. checkout_path ( ) . join ( "x.py" ) . as_str ( ) , "clean" ] ) ;
126
+ cmd ( & args)
127
+ . env ( "COMPILETEST_FORCE_STAGE0" , "1" )
128
+ // Also run dist-only tests
129
+ . env ( "COMPILETEST_ENABLE_DIST_TESTS" , "1" )
130
+ . run ( )
131
+ . context ( "Cannot execute tests" )
132
+ // })
142
133
}
134
+ //
135
+ // /// Backup `path` (if it exists), then write `contents` into it, and then restore the original
136
+ // /// contents of the file.
137
+ // fn with_backed_up_file<F>(path: &Path, contents: &str, func: F) -> anyhow::Result<()>
138
+ // where
139
+ // F: FnOnce() -> anyhow::Result<()>,
140
+ // {
141
+ // let original_contents =
142
+ // if path.is_file() { Some(std::fs::read_to_string(path)?) } else { None };
143
+ //
144
+ // // Overwrite it with new contents
145
+ // std::fs::write(path, contents)?;
146
+ //
147
+ // let ret = func();
148
+ //
149
+ // if let Some(original_contents) = original_contents {
150
+ // std::fs::write(path, original_contents)?;
151
+ // }
152
+ //
153
+ // ret
154
+ // }
143
155
144
156
/// Tries to find the version of the dist artifacts (either nightly, beta, or 1.XY.Z).
145
157
fn find_dist_version ( directory : & Utf8Path ) -> anyhow:: Result < String > {
@@ -153,12 +165,12 @@ fn find_dist_version(directory: &Utf8Path) -> anyhow::Result<String> {
153
165
Ok ( version. to_string ( ) )
154
166
}
155
167
156
- /// Roughly convert a version string (`nightly`, `beta`, or `1.XY.Z`) to channel string (`nightly`,
157
- /// `beta` or `stable`).
158
- fn version_to_channel ( version_str : & str ) -> & ' static str {
159
- match version_str {
160
- "nightly" => "nightly" ,
161
- "beta" => "beta" ,
162
- _ => "stable" ,
163
- }
164
- }
168
+ // // / Roughly convert a version string (`nightly`, `beta`, or `1.XY.Z`) to channel string (`nightly`,
169
+ // // / `beta` or `stable`).
170
+ // fn version_to_channel(version_str: &str) -> &'static str {
171
+ // match version_str {
172
+ // "nightly" => "nightly",
173
+ // "beta" => "beta",
174
+ // _ => "stable",
175
+ // }
176
+ // }
0 commit comments