@@ -866,8 +866,8 @@ fn add_remove_component() {
866
866
#[ test]
867
867
fn which ( ) {
868
868
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 ( ) ;
871
871
expect_ok (
872
872
config,
873
873
& [ "rustup" , "toolchain" , "link" , "custom-1" , & path_1] ,
@@ -885,8 +885,8 @@ fn which() {
885
885
& [ "rustup" , "which" , "rustc" ] ,
886
886
"/toolchains/custom-1/bin/rustc" ,
887
887
) ;
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 ( ) ;
890
890
expect_ok (
891
891
config,
892
892
& [ "rustup" , "toolchain" , "link" , "custom-2" , & path_2] ,
@@ -905,3 +905,68 @@ fn which() {
905
905
) ;
906
906
} ) ;
907
907
}
908
+
909
+ #[ test]
910
+ fn override_by_keyword_arg_with_which ( ) {
911
+ setup ( & |config| {
912
+ #[ cfg( windows) ]
913
+ expect_stdout_ok (
914
+ config,
915
+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
916
+ "\\ toolchains\\ stable-x86_64-" ,
917
+ ) ;
918
+ #[ cfg( windows) ]
919
+ expect_stdout_ok (
920
+ config,
921
+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
922
+ "\\ bin\\ rustc" ,
923
+ ) ;
924
+ #[ cfg( not( windows) ) ]
925
+ expect_stdout_ok (
926
+ config,
927
+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
928
+ "/toolchains/stable-x86_64-" ,
929
+ ) ;
930
+ #[ cfg( not( windows) ) ]
931
+ expect_stdout_ok (
932
+ config,
933
+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
934
+ "/bin/rustc" ,
935
+ ) ;
936
+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
937
+ #[ cfg( windows) ]
938
+ expect_stdout_ok (
939
+ config,
940
+ & [ "rustup" , "+nightly" , "which" , "rustc" ] ,
941
+ "\\ toolchains\\ nightly-x86_64-" ,
942
+ ) ;
943
+ #[ cfg( windows) ]
944
+ expect_stdout_ok (
945
+ config,
946
+ & [ "rustup" , "+nightly" , "which" , "rustc" ] ,
947
+ "\\ bin\\ rustc" ,
948
+ ) ;
949
+ #[ cfg( not( windows) ) ]
950
+ expect_stdout_ok (
951
+ config,
952
+ & [ "rustup" , "+nightly" , "which" , "rustc" ] ,
953
+ "/toolchains/nightly-x86_64-" ,
954
+ ) ;
955
+ #[ cfg( not( windows) ) ]
956
+ expect_stdout_ok (
957
+ config,
958
+ & [ "rustup" , "+nightly" , "which" , "rustc" ] ,
959
+ "/bin/rustc" ,
960
+ ) ;
961
+ expect_stderr_ok (
962
+ config,
963
+ & [ "rustup" , "+stable" , "which" , "rustc" ] ,
964
+ "set to 'stable-x86_64-" ,
965
+ ) ;
966
+ expect_err (
967
+ config,
968
+ & [ "rustup" , "+foo" , "which" , "rustc" ] ,
969
+ "toolchain 'foo' is not installed" ,
970
+ ) ;
971
+ } ) ;
972
+ }
0 commit comments