@@ -70,7 +70,8 @@ fn show_usage() {
7070 --use-system-gcc : Use system installed libgccjit
7171 --build-only : Only build rustc_codegen_gcc then exits
7272 --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"#
7475 ) ;
7576 ConfigInfo :: show_usage ( ) ;
7677 for ( option, ( doc, _) ) in get_runners ( ) {
@@ -95,6 +96,7 @@ struct TestArg {
9596 sysroot_panic_abort : bool ,
9697 config_info : ConfigInfo ,
9798 sysroot_features : Vec < String > ,
99+ toolchain_name : Option < String > ,
98100 keep_lto_tests : bool ,
99101}
100102
@@ -142,6 +144,18 @@ impl TestArg {
142144 return Err ( format ! ( "Expected an argument after `{}`, found nothing" , arg) ) ;
143145 }
144146 } ,
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+ } ,
145159 "--help" => {
146160 show_usage ( ) ;
147161 return Ok ( None ) ;
@@ -181,7 +195,7 @@ impl TestArg {
181195}
182196
183197fn 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 ( ) {
185199 return Ok ( ( ) ) ;
186200 }
187201 let mut command: Vec < & dyn AsRef < OsStr > > = vec ! [ & "cargo" , & "rustc" ] ;
@@ -460,11 +474,14 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
460474}
461475
462476fn 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+ } ;
468485 let rust_dir_path = Path :: new ( crate :: BUILD_DIR ) . join ( "rust" ) ;
469486 // If the repository was already cloned, command will fail, so doesn't matter.
470487 let _ = git_clone ( "https://github.com/rust-lang/rust.git" , Some ( & rust_dir_path) , false ) ;
0 commit comments