@@ -143,6 +143,107 @@ version required: ^1.0
143
143
" ) ) ;
144
144
}
145
145
146
+
147
+ #[ test]
148
+ fn explicit_stdlib_deps_with_flag ( ) {
149
+ setup ( ) ;
150
+ Package :: new ( "core" , "1.0.0" ) . local ( true ) . publish ( ) ;
151
+ Package :: new ( "std" , "1.0.0" ) . local ( true ) . file ( "src/lib.rs" , STD ) . publish ( ) ;
152
+ Package :: new ( "test" , "1.0.0" ) . local ( true ) . publish ( ) ;
153
+
154
+ let p = project ( "local" )
155
+ . file ( "Cargo.toml" , r#"
156
+ [package]
157
+ name = "local"
158
+ version = "0.0.1"
159
+ authors = []
160
+ implicit-dependencies = false
161
+
162
+ [dependencies]
163
+ core = { version = "1", stdlib = true }
164
+ std = { version = "1", stdlib = true }
165
+ test = { version = "1", stdlib = true }
166
+ "# )
167
+ . file ( "src/lib.rs" , "" ) ;
168
+
169
+ assert_that ( p. cargo_process ( "build" ) . arg ( "--verbose" ) ,
170
+ execs ( ) . with_status ( 0 )
171
+ . with_stderr_contains (
172
+ "[WARNING] the \" compiler source\" is unstable [..]" )
173
+ . with_stderr_contains (
174
+ "[WARNING] explicit dependencies are unstable" ) ) ;
175
+ }
176
+
177
+ #[ test]
178
+ fn implicit_stdlib_dep_with_flag ( ) {
179
+ setup ( ) ;
180
+ Package :: new ( "core" , "1.0.0" ) . local ( true ) . publish ( ) ;
181
+ Package :: new ( "std" , "1.0.0" ) . local ( true ) . file ( "src/lib.rs" , STD ) . publish ( ) ;
182
+ Package :: new ( "test" , "1.0.0" ) . local ( true ) . publish ( ) ;
183
+
184
+ let p = project ( "local" )
185
+ . file ( "Cargo.toml" , r#"
186
+ [package]
187
+ name = "local"
188
+ version = "0.0.1"
189
+ authors = []
190
+ implicit-dependencies = true
191
+ "# )
192
+ . file ( "src/lib.rs" , "" ) ;
193
+
194
+ assert_that ( p. cargo_process ( "build" ) . arg ( "--verbose" ) ,
195
+ execs ( ) . with_status ( 0 )
196
+ . with_stderr_contains (
197
+ "[WARNING] the \" compiler source\" is unstable [..]" ) ) ;
198
+ }
199
+
200
+ #[ test]
201
+ fn no_primary_stdlib_deps_at_all ( ) {
202
+ setup ( ) ;
203
+ // For dev & build
204
+ Package :: new ( "core" , "1.0.0" )
205
+ . file ( "src/lib.rs" , "I AM INVALID SYNTAX CANNOT COMPILE" )
206
+ . local ( true ) . publish ( ) ;
207
+ Package :: new ( "std" , "1.0.0" ) . local ( true ) . publish ( ) ;
208
+ Package :: new ( "test" , "1.0.0" ) . local ( true ) . publish ( ) ;
209
+
210
+ let foo = project ( "foo" )
211
+ . file ( "Cargo.toml" , r#"
212
+ [package]
213
+ name = "foo"
214
+ version = "0.0.0"
215
+ authors = []
216
+ implicit-dependencies = false
217
+ "# )
218
+ . file ( "src/lib.rs" , "" ) ;
219
+ assert_that ( foo. cargo_process ( "build" ) . arg ( "-v" ) ,
220
+ execs ( ) . with_status ( 0 ) ) ;
221
+ }
222
+
223
+ #[ test]
224
+ fn mixed_expicit_and_implicit_stdlib_deps ( ) {
225
+ setup ( ) ;
226
+ let foo = project ( "foo" )
227
+ . file ( "Cargo.toml" , r#"
228
+ [package]
229
+ name = "foo"
230
+ version = "0.0.0"
231
+ authors = []
232
+ implicit-dependencies = true
233
+
234
+ [dependencies]
235
+ foo = { stdlib = true }
236
+ "# )
237
+ . file ( "src/lib.rs" , "" ) ;
238
+ assert_that ( foo. cargo_process ( "build" ) . arg ( "-v" ) ,
239
+ execs ( ) . with_status ( 101 ) . with_stderr ( "\
240
+ [ERROR] failed to parse manifest at `[..]`
241
+
242
+ Caused by:
243
+ cannot use explicit stdlib deps when implicit deps were explicitly enabled.
244
+ " ) ) ;
245
+ }
246
+
146
247
#[ test]
147
248
fn stdlib_replacement ( ) {
148
249
setup ( ) ;
0 commit comments