@@ -764,7 +764,9 @@ fn unavailable_component() {
764
764
)
765
765
. unwrap_err ( ) ;
766
766
match * err. kind ( ) {
767
- ErrorKind :: RequestedComponentsUnavailable ( ..) => { }
767
+ ErrorKind :: RequestedComponentsUnavailable ( ..) => {
768
+ assert ! ( err. to_string( ) . contains( "rustup component remove --toolchain nightly --target x86_64-apple-darwin bonus" ) ) ;
769
+ }
768
770
_ => panic ! ( ) ,
769
771
}
770
772
} ,
@@ -823,7 +825,9 @@ fn unavailable_component_from_profile() {
823
825
)
824
826
. unwrap_err ( ) ;
825
827
match * err. kind ( ) {
826
- ErrorKind :: RequestedComponentsUnavailable ( ..) => { }
828
+ ErrorKind :: RequestedComponentsUnavailable ( ..) => {
829
+ assert ! ( err. to_string( ) . contains( "rustup component remove --toolchain nightly --target x86_64-apple-darwin rustc" ) ) ;
830
+ }
827
831
_ => panic ! ( ) ,
828
832
}
829
833
@@ -889,17 +893,184 @@ fn removed_component() {
889
893
890
894
// Update without bonus, should fail with RequestedComponentsUnavailable
891
895
change_channel_date ( url, "nightly" , "2016-02-02" ) ;
892
- assert ! ( update_from_dist(
896
+ let err = update_from_dist (
897
+ url,
898
+ toolchain,
899
+ prefix,
900
+ & [ ] ,
901
+ & [ ] ,
902
+ & download_cfg,
903
+ temp_cfg,
904
+ false ,
905
+ )
906
+ . unwrap_err ( ) ;
907
+ match * err. kind ( ) {
908
+ ErrorKind :: RequestedComponentsUnavailable ( ..) => {
909
+ assert ! ( err. to_string( ) . contains( "rustup component remove --toolchain nightly --target x86_64-apple-darwin bonus" ) ) ;
910
+ }
911
+ _ => panic ! ( ) ,
912
+ }
913
+ } ,
914
+ ) ;
915
+ }
916
+
917
+ #[ test]
918
+ fn unavailable_components_is_target ( ) {
919
+ // On day 2 the rust-std component is no longer available
920
+ let edit = & |date : & str , chan : & mut MockChannel | {
921
+ // Mark the rust-std package as unavailable in 2016-02-02
922
+ if date == "2016-02-02" {
923
+ let pkg = chan
924
+ . packages
925
+ . iter_mut ( )
926
+ . find ( |p| p. name == "rust-std" )
927
+ . unwrap ( ) ;
928
+
929
+ for target in & mut pkg. targets {
930
+ target. available = false ;
931
+ }
932
+ }
933
+ } ;
934
+
935
+ setup (
936
+ Some ( edit) ,
937
+ false ,
938
+ & |url, toolchain, prefix, download_cfg, temp_cfg| {
939
+ let adds = [
940
+ Component :: new (
941
+ "rust-std" . to_string ( ) ,
942
+ Some ( TargetTriple :: new ( "i686-apple-darwin" ) ) ,
943
+ false ,
944
+ ) ,
945
+ Component :: new (
946
+ "rust-std" . to_string ( ) ,
947
+ Some ( TargetTriple :: new ( "i686-unknown-linux-gnu" ) ) ,
948
+ false ,
949
+ ) ,
950
+ ] ;
951
+
952
+ // Update with rust-std
953
+ change_channel_date ( url, "nightly" , "2016-02-01" ) ;
954
+ update_from_dist (
955
+ url,
956
+ toolchain,
957
+ prefix,
958
+ & adds,
959
+ & [ ] ,
960
+ & download_cfg,
961
+ temp_cfg,
962
+ false ,
963
+ )
964
+ . unwrap ( ) ;
965
+
966
+ assert ! ( utils:: path_exists(
967
+ & prefix. path( ) . join( "lib/i686-apple-darwin/libstd.rlib" )
968
+ ) ) ;
969
+ assert ! ( utils:: path_exists(
970
+ & prefix. path( ) . join( "lib/i686-unknown-linux-gnu/libstd.rlib" )
971
+ ) ) ;
972
+
973
+ // Update without rust-std
974
+ change_channel_date ( url, "nightly" , "2016-02-02" ) ;
975
+ let err = update_from_dist (
976
+ url,
977
+ toolchain,
978
+ prefix,
979
+ & [ ] ,
980
+ & [ ] ,
981
+ & download_cfg,
982
+ temp_cfg,
983
+ false ,
984
+ )
985
+ . unwrap_err ( ) ;
986
+ match * err. kind ( ) {
987
+ ErrorKind :: RequestedComponentsUnavailable ( ..) => {
988
+ let err_str = err. to_string ( ) ;
989
+ assert ! ( err_str
990
+ . contains( "rustup target remove --toolchain nightly i686-apple-darwin" ) ) ;
991
+ assert ! ( err_str. contains(
992
+ "rustup target remove --toolchain nightly i686-unknown-linux-gnu"
993
+ ) ) ;
994
+ }
995
+ _ => panic ! ( ) ,
996
+ }
997
+ } ,
998
+ ) ;
999
+ }
1000
+
1001
+ #[ test]
1002
+ fn unavailable_components_with_same_target ( ) {
1003
+ // On day 2, the rust-std and rustc components are no longer available
1004
+ let edit = & |date : & str , chan : & mut MockChannel | {
1005
+ // Mark the rust-std package as unavailable in 2016-02-02
1006
+ if date == "2016-02-02" {
1007
+ let pkg = chan
1008
+ . packages
1009
+ . iter_mut ( )
1010
+ . find ( |p| p. name == "rust-std" )
1011
+ . unwrap ( ) ;
1012
+
1013
+ for target in & mut pkg. targets {
1014
+ target. available = false ;
1015
+ }
1016
+ }
1017
+
1018
+ // Mark the rustc package as unavailable in 2016-02-02
1019
+ if date == "2016-02-02" {
1020
+ let pkg = chan
1021
+ . packages
1022
+ . iter_mut ( )
1023
+ . find ( |p| p. name == "rustc" )
1024
+ . unwrap ( ) ;
1025
+
1026
+ for target in & mut pkg. targets {
1027
+ target. available = false ;
1028
+ }
1029
+ }
1030
+ } ;
1031
+
1032
+ setup (
1033
+ Some ( edit) ,
1034
+ false ,
1035
+ & |url, toolchain, prefix, download_cfg, temp_cfg| {
1036
+ // Update with rust-std and rustc
1037
+ change_channel_date ( url, "nightly" , "2016-02-01" ) ;
1038
+ update_from_dist (
1039
+ url,
1040
+ toolchain,
1041
+ prefix,
1042
+ & [ ] ,
1043
+ & [ ] ,
1044
+ & download_cfg,
1045
+ temp_cfg,
1046
+ false ,
1047
+ )
1048
+ . unwrap ( ) ;
1049
+ assert ! ( utils:: path_exists( & prefix. path( ) . join( "bin/rustc" ) ) ) ;
1050
+ assert ! ( utils:: path_exists( & prefix. path( ) . join( "lib/libstd.rlib" ) ) ) ;
1051
+
1052
+ // Update without rust-std and rustc
1053
+ change_channel_date ( url, "nightly" , "2016-02-02" ) ;
1054
+ let err = update_from_dist (
893
1055
url,
894
1056
toolchain,
895
1057
prefix,
896
1058
& [ ] ,
897
1059
& [ ] ,
898
1060
& download_cfg,
899
1061
temp_cfg,
900
- false
1062
+ false ,
901
1063
)
902
- . is_err( ) ) ;
1064
+ . unwrap_err ( ) ;
1065
+ match * err. kind ( ) {
1066
+ ErrorKind :: RequestedComponentsUnavailable ( ..) => {
1067
+ let err_str = err. to_string ( ) ;
1068
+ assert ! ( err_str
1069
+ . contains( "rustup target remove --toolchain nightly x86_64-apple-darwin" ) ) ;
1070
+ assert ! ( err_str. contains( "rustup component remove --toolchain nightly --target x86_64-apple-darwin rustc" ) ) ;
1071
+ }
1072
+ _ => panic ! ( ) ,
1073
+ }
903
1074
} ,
904
1075
) ;
905
1076
}
0 commit comments