@@ -787,6 +787,154 @@ fn add_ignored_patch() {
787
787
. run ( ) ;
788
788
}
789
789
790
+ #[ cargo_test]
791
+ fn add_patch_with_features ( ) {
792
+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
793
+
794
+ let p = project ( )
795
+ . file (
796
+ "Cargo.toml" ,
797
+ r#"
798
+ [package]
799
+ name = "foo"
800
+ version = "0.0.1"
801
+ authors = []
802
+
803
+ [dependencies]
804
+ bar = "0.1.0"
805
+ "# ,
806
+ )
807
+ . file ( "src/lib.rs" , "" )
808
+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
809
+ . file ( "bar/src/lib.rs" , r#""# )
810
+ . build ( ) ;
811
+
812
+ p. cargo ( "build" )
813
+ . with_stderr (
814
+ "\
815
+ [UPDATING] `[ROOT][..]` index
816
+ [DOWNLOADING] crates ...
817
+ [DOWNLOADED] bar v0.1.0 [..]
818
+ [COMPILING] bar v0.1.0
819
+ [COMPILING] foo v0.0.1 ([CWD])
820
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
821
+ " ,
822
+ )
823
+ . run ( ) ;
824
+ p. cargo ( "build" ) . with_stderr ( "[FINISHED] [..]" ) . run ( ) ;
825
+
826
+ p. change_file (
827
+ "Cargo.toml" ,
828
+ r#"
829
+ [package]
830
+ name = "foo"
831
+ version = "0.0.1"
832
+ authors = []
833
+
834
+ [dependencies]
835
+ bar = "0.1.0"
836
+
837
+ [patch.crates-io]
838
+ bar = { path = 'bar', features = ["some_feature"] }
839
+ "# ,
840
+ ) ;
841
+
842
+ p. cargo ( "build" )
843
+ . with_stderr (
844
+ "\
845
+ [WARNING] patch for `bar` uses the features mechanism. \
846
+ default-features and features will not take effect because the patch dependency does not support this mechanism
847
+ [COMPILING] bar v0.1.0 ([CWD]/bar)
848
+ [COMPILING] foo v0.0.1 ([CWD])
849
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
850
+ " ,
851
+ )
852
+ . run ( ) ;
853
+ p. cargo ( "build" )
854
+ . with_stderr (
855
+ "\
856
+ [WARNING] patch for `bar` uses the features mechanism. \
857
+ default-features and features will not take effect because the patch dependency does not support this mechanism
858
+ [FINISHED] [..]
859
+ " ,
860
+ )
861
+ . run ( ) ;
862
+ }
863
+
864
+ #[ cargo_test]
865
+ fn add_patch_with_setting_default_features ( ) {
866
+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
867
+
868
+ let p = project ( )
869
+ . file (
870
+ "Cargo.toml" ,
871
+ r#"
872
+ [package]
873
+ name = "foo"
874
+ version = "0.0.1"
875
+ authors = []
876
+
877
+ [dependencies]
878
+ bar = "0.1.0"
879
+ "# ,
880
+ )
881
+ . file ( "src/lib.rs" , "" )
882
+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
883
+ . file ( "bar/src/lib.rs" , r#""# )
884
+ . build ( ) ;
885
+
886
+ p. cargo ( "build" )
887
+ . with_stderr (
888
+ "\
889
+ [UPDATING] `[ROOT][..]` index
890
+ [DOWNLOADING] crates ...
891
+ [DOWNLOADED] bar v0.1.0 [..]
892
+ [COMPILING] bar v0.1.0
893
+ [COMPILING] foo v0.0.1 ([CWD])
894
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
895
+ " ,
896
+ )
897
+ . run ( ) ;
898
+ p. cargo ( "build" ) . with_stderr ( "[FINISHED] [..]" ) . run ( ) ;
899
+
900
+ p. change_file (
901
+ "Cargo.toml" ,
902
+ r#"
903
+ [package]
904
+ name = "foo"
905
+ version = "0.0.1"
906
+ authors = []
907
+
908
+ [dependencies]
909
+ bar = "0.1.0"
910
+
911
+ [patch.crates-io]
912
+ bar = { path = 'bar', default-features = false, features = ["none_default_feature"] }
913
+ "# ,
914
+ ) ;
915
+
916
+ p. cargo ( "build" )
917
+ . with_stderr (
918
+ "\
919
+ [WARNING] patch for `bar` uses the features mechanism. \
920
+ default-features and features will not take effect because the patch dependency does not support this mechanism
921
+ [COMPILING] bar v0.1.0 ([CWD]/bar)
922
+ [COMPILING] foo v0.0.1 ([CWD])
923
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
924
+ " ,
925
+ )
926
+ . run ( ) ;
927
+ p. cargo ( "build" )
928
+ . with_stderr (
929
+ "\
930
+ [WARNING] patch for `bar` uses the features mechanism. \
931
+ default-features and features will not take effect because the patch dependency does not support this mechanism
932
+ [FINISHED] [..]
933
+ " ,
934
+ )
935
+ . run ( ) ;
936
+ }
937
+
790
938
#[ cargo_test]
791
939
fn no_warn_ws_patch ( ) {
792
940
Package :: new ( "c" , "0.1.0" ) . publish ( ) ;
0 commit comments