@@ -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 ) ;
@@ -181,7 +195,7 @@ impl TestArg {
181
195
}
182
196
183
197
fn build_if_no_backend ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
184
- if args. config_info . backend . is_some ( ) {
198
+ if args. config_info . backend . is_some ( ) || args . toolchain_name . is_some ( ) {
185
199
return Ok ( ( ) ) ;
186
200
}
187
201
let mut command: Vec < & dyn AsRef < OsStr > > = vec ! [ & "cargo" , & "rustc" ] ;
@@ -460,11 +474,14 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
460
474
}
461
475
462
476
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
- ) ;
477
+ let toolchain = match args. toolchain_name {
478
+ Some ( ref toolchain_name) => toolchain_name. clone ( ) ,
479
+ None => format ! (
480
+ "+{channel}-{host}" ,
481
+ channel = get_toolchain( ) ?, // May also include date
482
+ host = args. config_info. host_triple
483
+ ) ,
484
+ } ;
468
485
let rust_dir_path = Path :: new ( crate :: BUILD_DIR ) . join ( "rust" ) ;
469
486
// If the repository was already cloned, command will fail, so doesn't matter.
470
487
let _ = git_clone ( "https://github.com/rust-lang/rust.git" , Some ( & rust_dir_path) , false ) ;
0 commit comments