@@ -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] ,
@@ -903,5 +903,79 @@ fn which() {
903
903
& [ "rustup" , "which" , "--toolchain=custom-2" , "rustc" ] ,
904
904
"/toolchains/custom-2/bin/rustc" ,
905
905
) ;
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
+ "error: '+foo' isn't a valid value for '<release-channel>" ,
973
+ ) ;
974
+ expect_stderr_ok (
975
+ config,
976
+ & [ "rustup" , "+nightly" , "which" , "cargo" , "--toolchain=stable" ] ,
977
+ "warning: Both the <release-channel> arg (e.g. \" +nightly\" ) and the \" --toolchain\" option are provided.\n \
978
+ The <release-channel> arg would take precedence over the \" --toolchain\" option.",
979
+ ) ;
906
980
} ) ;
907
981
}
0 commit comments