@@ -866,8 +866,8 @@ fn add_remove_component() {
866866#[ test]
867867fn which ( ) {
868868 setup ( & |config| {
869- let path_1 = config. customdir . join ( "custom-1" ) ;
870- let path_1 = path_1 . to_string_lossy ( ) ;
869+ let _path_1 = config. customdir . join ( "custom-1" ) ;
870+ let path_1 = _path_1 . to_string_lossy ( ) ;
871871 expect_ok (
872872 config,
873873 & [ "rustup" , "toolchain" , "link" , "custom-1" , & path_1] ,
@@ -885,8 +885,8 @@ fn which() {
885885 & [ "rustup" , "which" , "rustc" ] ,
886886 "/toolchains/custom-1/bin/rustc" ,
887887 ) ;
888- let path_2 = config. customdir . join ( "custom-2" ) ;
889- let path_2 = path_2 . to_string_lossy ( ) ;
888+ let _path_2 = config. customdir . join ( "custom-2" ) ;
889+ let path_2 = _path_2 . to_string_lossy ( ) ;
890890 expect_ok (
891891 config,
892892 & [ "rustup" , "toolchain" , "link" , "custom-2" , & path_2] ,
@@ -903,5 +903,91 @@ fn which() {
903903 & [ "rustup" , "which" , "--toolchain=custom-2" , "rustc" ] ,
904904 "/toolchains/custom-2/bin/rustc" ,
905905 ) ;
906+ #[ cfg( windows) ]
907+ expect_stdout_ok (
908+ config,
909+ & [ "rustup" , "--toolchain=custom-2" , "which" , "rustc" ] ,
910+ "\\ toolchains\\ custom-2\\ bin\\ rustc" ,
911+ ) ;
912+ #[ cfg( not( windows) ) ]
913+ expect_stdout_ok (
914+ config,
915+ & [ "rustup" , "--toolchain=custom-2" , "which" , "rustc" ] ,
916+ "/toolchains/custom-2/bin/rustc" ,
917+ ) ;
918+ expect_ok ( config, & [ "rustup" , "default" , "stable" ] ) ;
919+ #[ cfg( windows) ]
920+ expect_stdout_ok (
921+ config,
922+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
923+ "\\ toolchains\\ stable-x86_64-" ,
924+ ) ;
925+ #[ cfg( windows) ]
926+ expect_stdout_ok (
927+ config,
928+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
929+ "\\ bin\\ rustc" ,
930+ ) ;
931+ #[ cfg( not( windows) ) ]
932+ expect_stdout_ok (
933+ config,
934+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
935+ "/toolchains/stable-x86_64-" ,
936+ ) ;
937+ #[ cfg( not( windows) ) ]
938+ expect_stdout_ok (
939+ config,
940+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
941+ "/bin/rustc" ,
942+ ) ;
943+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
944+ #[ cfg( windows) ]
945+ expect_stdout_ok (
946+ config,
947+ & [ "rustup" , "+nightly" , "which" , "rustc" ] ,
948+ "\\ toolchains\\ nightly-x86_64-" ,
949+ ) ;
950+ #[ cfg( windows) ]
951+ expect_stdout_ok (
952+ config,
953+ & [ "rustup" , "+nightly" , "which" , "rustc" ] ,
954+ "\\ bin\\ rustc" ,
955+ ) ;
956+ #[ cfg( not( windows) ) ]
957+ expect_stdout_ok (
958+ config,
959+ & [ "rustup" , "+nightly" , "which" , "rustc" ] ,
960+ "/toolchains/nightly-x86_64-" ,
961+ ) ;
962+ #[ cfg( not( windows) ) ]
963+ expect_stdout_ok (
964+ config,
965+ & [ "rustup" , "+nightly" , "which" , "rustc" ] ,
966+ "/bin/rustc" ,
967+ ) ;
968+
969+ expect_err (
970+ config,
971+ & [ "rustup" , "+foo" , "which" , "rustc" ] ,
972+ "binary not found" ,
973+ ) ;
974+ expect_stderr_ok (
975+ config,
976+ & [ "rustup" , "+nightly" , "--toolchain=stable" , "which" , "cargo" ] ,
977+ "Both toolchain keyword (e.g. \" +nightly\" ) and \" --toolchain\" option are provided. \
978+ The toolchain keyword would take precedence.",
979+ ) ;
980+ expect_stderr_ok (
981+ config,
982+ & [
983+ "rustup" ,
984+ "--toolchain=nightly" ,
985+ "which" ,
986+ "cargo" ,
987+ "--toolchain=stable" ,
988+ ] ,
989+ "Toolchain options are provided before and after the \" which\" subcommand. \
990+ The first toolchain option would take precedence.",
991+ ) ;
906992 } ) ;
907993}
0 commit comments