@@ -787,6 +787,102 @@ 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
+ [patch.crates-io]
807
+ bar = { path = 'bar', features = ["some_feature"] }
808
+ "# ,
809
+ )
810
+ . file ( "src/lib.rs" , "" )
811
+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
812
+ . file ( "bar/src/lib.rs" , r#""# )
813
+ . build ( ) ;
814
+
815
+ p. cargo ( "build" )
816
+ . with_stderr (
817
+ "\
818
+ [WARNING] patch for `bar` uses the features mechanism. \
819
+ default-features and features will not take effect because the patch dependency does not support this mechanism
820
+ [UPDATING] `[ROOT][..]` index
821
+ [COMPILING] bar v0.1.0 ([CWD]/bar)
822
+ [COMPILING] foo v0.0.1 ([CWD])
823
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
824
+ " ,
825
+ )
826
+ . run ( ) ;
827
+ p. cargo ( "build" )
828
+ . with_stderr (
829
+ "\
830
+ [WARNING] patch for `bar` uses the features mechanism. \
831
+ default-features and features will not take effect because the patch dependency does not support this mechanism
832
+ [FINISHED] [..]
833
+ " ,
834
+ )
835
+ . run ( ) ;
836
+ }
837
+
838
+ #[ cargo_test]
839
+ fn add_patch_with_setting_default_features ( ) {
840
+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
841
+
842
+ let p = project ( )
843
+ . file (
844
+ "Cargo.toml" ,
845
+ r#"
846
+ [package]
847
+ name = "foo"
848
+ version = "0.0.1"
849
+ authors = []
850
+
851
+ [dependencies]
852
+ bar = "0.1.0"
853
+
854
+ [patch.crates-io]
855
+ bar = { path = 'bar', default-features = false, features = ["none_default_feature"] }
856
+ "# ,
857
+ )
858
+ . file ( "src/lib.rs" , "" )
859
+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
860
+ . file ( "bar/src/lib.rs" , r#""# )
861
+ . build ( ) ;
862
+
863
+ p. cargo ( "build" )
864
+ . with_stderr (
865
+ "\
866
+ [WARNING] patch for `bar` uses the features mechanism. \
867
+ default-features and features will not take effect because the patch dependency does not support this mechanism
868
+ [UPDATING] `[ROOT][..]` index
869
+ [COMPILING] bar v0.1.0 ([CWD]/bar)
870
+ [COMPILING] foo v0.0.1 ([CWD])
871
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
872
+ " ,
873
+ )
874
+ . run ( ) ;
875
+ p. cargo ( "build" )
876
+ . with_stderr (
877
+ "\
878
+ [WARNING] patch for `bar` uses the features mechanism. \
879
+ default-features and features will not take effect because the patch dependency does not support this mechanism
880
+ [FINISHED] [..]
881
+ " ,
882
+ )
883
+ . run ( ) ;
884
+ }
885
+
790
886
#[ cargo_test]
791
887
fn no_warn_ws_patch ( ) {
792
888
Package :: new ( "c" , "0.1.0" ) . publish ( ) ;
0 commit comments