@@ -52,6 +52,104 @@ fn override_simple() {
5252 . run ( ) ;
5353}
5454
55+ #[ cargo_test]
56+ fn override_with_features ( ) {
57+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
58+
59+ let bar = git:: repo ( & paths:: root ( ) . join ( "override" ) )
60+ . file ( "Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
61+ . file ( "src/lib.rs" , "pub fn bar() {}" )
62+ . build ( ) ;
63+
64+ let p = project ( )
65+ . file (
66+ "Cargo.toml" ,
67+ & format ! (
68+ r#"
69+ [package]
70+ name = "foo"
71+ version = "0.0.1"
72+ authors = []
73+
74+ [dependencies]
75+ bar = "0.1.0"
76+
77+ [replace]
78+ "bar:0.1.0" = {{ git = '{}', features = ["some_feature"] }}
79+ "# ,
80+ bar. url( )
81+ ) ,
82+ )
83+ . file (
84+ "src/lib.rs" ,
85+ "extern crate bar; pub fn foo() { bar::bar(); }" ,
86+ )
87+ . build ( ) ;
88+
89+ p. cargo ( "build" )
90+ . with_stderr (
91+ "\
92+ [UPDATING] [..] index
93+ [UPDATING] git repository `[..]`
94+ [WARNING] replacement for `bar` uses the features mechanism. default-features and features \
95+ will not take effect because the replacement dependency does not support this mechanism
96+ [COMPILING] bar v0.1.0 (file://[..])
97+ [COMPILING] foo v0.0.1 ([CWD])
98+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
99+ " ,
100+ )
101+ . run ( ) ;
102+ }
103+
104+ #[ cargo_test]
105+ fn override_with_setting_default_features ( ) {
106+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
107+
108+ let bar = git:: repo ( & paths:: root ( ) . join ( "override" ) )
109+ . file ( "Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
110+ . file ( "src/lib.rs" , "pub fn bar() {}" )
111+ . build ( ) ;
112+
113+ let p = project ( )
114+ . file (
115+ "Cargo.toml" ,
116+ & format ! (
117+ r#"
118+ [package]
119+ name = "foo"
120+ version = "0.0.1"
121+ authors = []
122+
123+ [dependencies]
124+ bar = "0.1.0"
125+
126+ [replace]
127+ "bar:0.1.0" = {{ git = '{}', default-features = false, features = ["none_default_feature"] }}
128+ "# ,
129+ bar. url( )
130+ ) ,
131+ )
132+ . file (
133+ "src/lib.rs" ,
134+ "extern crate bar; pub fn foo() { bar::bar(); }" ,
135+ )
136+ . build ( ) ;
137+
138+ p. cargo ( "build" )
139+ . with_stderr (
140+ "\
141+ [UPDATING] [..] index
142+ [UPDATING] git repository `[..]`
143+ [WARNING] replacement for `bar` uses the features mechanism. default-features and features \
144+ will not take effect because the replacement dependency does not support this mechanism
145+ [COMPILING] bar v0.1.0 (file://[..])
146+ [COMPILING] foo v0.0.1 ([CWD])
147+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
148+ " ,
149+ )
150+ . run ( ) ;
151+ }
152+
55153#[ cargo_test]
56154fn missing_version ( ) {
57155 let p = project ( )
0 commit comments