@@ -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 ) ; 
@@ -184,7 +198,11 @@ fn build_if_no_backend(env: &Env, args: &TestArg) -> Result<(), String> {
184198    if  args. config_info . backend . is_some ( )  { 
185199        return  Ok ( ( ) ) ; 
186200    } 
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" ) ; 
188206    let  mut  tmp_env; 
189207    let  env = if  args. config_info . channel  == Channel :: Release  { 
190208        tmp_env = env. clone ( ) ; 
@@ -460,11 +478,14 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
460478} 
461479
462480fn  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+     } ; 
468489    let  rust_dir_path = Path :: new ( crate :: BUILD_DIR ) . join ( "rust" ) ; 
469490    // If the repository was already cloned, command will fail, so doesn't matter. 
470491    let  _ = git_clone ( "https://github.com/rust-lang/rust.git" ,  Some ( & rust_dir_path) ,  false ) ; 
0 commit comments