@@ -70,7 +70,8 @@ fn show_usage() {
70
70
--use-system-gcc : Use system installed libgccjit
71
71
--build-only : Only build rustc_codegen_gcc then exits
72
72
--nb-parts : Used to split rustc_tests (for CI needs)
73
- --current-part : Used with `--nb-parts`, allows you to specify which parts to test"#
73
+ --current-part : Used with `--nb-parts`, allows you to specify which parts to test
74
+ --toolchain [arg] : The (rustc) toolchain to be used"#
74
75
) ;
75
76
ConfigInfo :: show_usage ( ) ;
76
77
for ( option, ( doc, _) ) in get_runners ( ) {
@@ -95,6 +96,7 @@ struct TestArg {
95
96
sysroot_panic_abort : bool ,
96
97
config_info : ConfigInfo ,
97
98
sysroot_features : Vec < String > ,
99
+ toolchain_name : Option < String > ,
98
100
keep_lto_tests : bool ,
99
101
}
100
102
@@ -142,6 +144,18 @@ impl TestArg {
142
144
return Err ( format ! ( "Expected an argument after `{}`, found nothing" , arg) ) ;
143
145
}
144
146
} ,
147
+ "--toolchain" => match args. next ( ) {
148
+ Some ( toolchain_name) if !toolchain_name. is_empty ( ) => {
149
+ if !toolchain_name. starts_with ( '+' ) {
150
+ test_arg. toolchain_name = Some ( format ! ( "+{toolchain_name}" ) ) ;
151
+ } else {
152
+ test_arg. toolchain_name = Some ( toolchain_name) ;
153
+ }
154
+ }
155
+ _ => {
156
+ return Err ( format ! ( "Expected an argument after `{}`, found nothing" , arg) ) ;
157
+ }
158
+ }
145
159
"--help" => {
146
160
show_usage ( ) ;
147
161
return Ok ( None ) ;
@@ -184,7 +198,11 @@ fn build_if_no_backend(env: &Env, args: &TestArg) -> Result<(), String> {
184
198
if args. config_info . backend . is_some ( ) {
185
199
return Ok ( ( ) ) ;
186
200
}
187
- let mut command: Vec < & dyn AsRef < OsStr > > = vec ! [ & "cargo" , & "rustc" ] ;
201
+ let mut command: Vec < & dyn AsRef < OsStr > > = vec ! [ & "cargo" ] ;
202
+ if let Some ( ref toolchain_name) = args. toolchain_name {
203
+ command. push ( toolchain_name) ;
204
+ }
205
+ command. push ( & "rustc" ) ;
188
206
let mut tmp_env;
189
207
let env = if args. config_info . channel == Channel :: Release {
190
208
tmp_env = env. clone ( ) ;
@@ -460,11 +478,14 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
460
478
}
461
479
462
480
fn setup_rustc ( env : & mut Env , args : & TestArg ) -> Result < PathBuf , String > {
463
- let toolchain = format ! (
464
- "+{channel}-{host}" ,
465
- channel = get_toolchain( ) ?, // May also include date
466
- host = args. config_info. host_triple
467
- ) ;
481
+ let toolchain = match args. toolchain_name {
482
+ Some ( ref toolchain_name) => toolchain_name. clone ( ) ,
483
+ None => format ! (
484
+ "+{channel}-{host}" ,
485
+ channel = get_toolchain( ) ?, // May also include date
486
+ host = args. config_info. host_triple
487
+ ) ,
488
+ } ;
468
489
let rust_dir_path = Path :: new ( crate :: BUILD_DIR ) . join ( "rust" ) ;
469
490
// If the repository was already cloned, command will fail, so doesn't matter.
470
491
let _ = git_clone ( "https://github.com/rust-lang/rust.git" , Some ( & rust_dir_path) , false ) ;
0 commit comments