@@ -3,7 +3,7 @@ extern crate hamcrest;
3
3
4
4
use hamcrest:: assert_that;
5
5
use cargotest:: support:: registry:: Package ;
6
- use cargotest:: support:: { project, execs, basic_bin_manifest, main_file} ;
6
+ use cargotest:: support:: { project, execs, basic_bin_manifest, basic_lib_manifest , main_file} ;
7
7
8
8
#[ test]
9
9
fn cargo_metadata_simple ( ) {
@@ -32,6 +32,7 @@ fn cargo_metadata_simple() {
32
32
"manifest_path": "[..]Cargo.toml"
33
33
}
34
34
],
35
+ "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
35
36
"resolve": {
36
37
"nodes": [
37
38
{
@@ -149,6 +150,7 @@ fn cargo_metadata_with_deps_and_version() {
149
150
"version": "0.5.0"
150
151
}
151
152
],
153
+ "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
152
154
"resolve": {
153
155
"nodes": [
154
156
{
@@ -174,6 +176,128 @@ fn cargo_metadata_with_deps_and_version() {
174
176
}"# ) ) ;
175
177
}
176
178
179
+ #[ test]
180
+ fn workspace_metadata ( ) {
181
+ let p = project ( "foo" )
182
+ . file ( "Cargo.toml" , r#"
183
+ [workspace]
184
+ members = ["bar", "baz"]
185
+ "# )
186
+ . file ( "bar/Cargo.toml" , & basic_lib_manifest ( "bar" ) )
187
+ . file ( "bar/src/lib.rs" , "" )
188
+ . file ( "baz/Cargo.toml" , & basic_lib_manifest ( "baz" ) )
189
+ . file ( "baz/src/lib.rs" , "" ) ;
190
+ p. build ( ) ;
191
+
192
+ assert_that ( p. cargo_process ( "metadata" ) , execs ( ) . with_status ( 0 ) . with_json ( r#"
193
+ {
194
+ "packages": [
195
+ {
196
+ "name": "bar",
197
+ "version": "0.5.0",
198
+ "id": "bar[..]",
199
+ "source": null,
200
+ "dependencies": [],
201
+ "targets": [
202
+ {
203
+ "kind": [ "lib" ],
204
+ "name": "bar",
205
+ "src_path": "[..]bar[..]src[..]lib.rs"
206
+ }
207
+ ],
208
+ "features": {},
209
+ "manifest_path": "[..]bar[..]Cargo.toml"
210
+ },
211
+ {
212
+ "name": "baz",
213
+ "version": "0.5.0",
214
+ "id": "baz[..]",
215
+ "source": null,
216
+ "dependencies": [],
217
+ "targets": [
218
+ {
219
+ "kind": [ "lib" ],
220
+ "name": "baz",
221
+ "src_path": "[..]baz[..]src[..]lib.rs"
222
+ }
223
+ ],
224
+ "features": {},
225
+ "manifest_path": "[..]baz[..]Cargo.toml"
226
+ }
227
+ ],
228
+ "workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
229
+ "resolve": {
230
+ "nodes": [
231
+ {
232
+ "dependencies": [],
233
+ "id": "baz 0.5.0 (path+file:[..]baz)"
234
+ },
235
+ {
236
+ "dependencies": [],
237
+ "id": "bar 0.5.0 (path+file:[..]bar)"
238
+ }
239
+ ],
240
+ "root": null
241
+ },
242
+ "version": 1
243
+ }"# ) )
244
+ }
245
+
246
+ #[ test]
247
+ fn workspace_metadata_no_deps ( ) {
248
+ let p = project ( "foo" )
249
+ . file ( "Cargo.toml" , r#"
250
+ [workspace]
251
+ members = ["bar", "baz"]
252
+ "# )
253
+ . file ( "bar/Cargo.toml" , & basic_lib_manifest ( "bar" ) )
254
+ . file ( "bar/src/lib.rs" , "" )
255
+ . file ( "baz/Cargo.toml" , & basic_lib_manifest ( "baz" ) )
256
+ . file ( "baz/src/lib.rs" , "" ) ;
257
+ p. build ( ) ;
258
+
259
+ assert_that ( p. cargo_process ( "metadata" ) . arg ( "--no-deps" ) , execs ( ) . with_status ( 0 ) . with_json ( r#"
260
+ {
261
+ "packages": [
262
+ {
263
+ "name": "bar",
264
+ "version": "0.5.0",
265
+ "id": "bar[..]",
266
+ "source": null,
267
+ "dependencies": [],
268
+ "targets": [
269
+ {
270
+ "kind": [ "lib" ],
271
+ "name": "bar",
272
+ "src_path": "[..]bar[..]src[..]lib.rs"
273
+ }
274
+ ],
275
+ "features": {},
276
+ "manifest_path": "[..]bar[..]Cargo.toml"
277
+ },
278
+ {
279
+ "name": "baz",
280
+ "version": "0.5.0",
281
+ "id": "baz[..]",
282
+ "source": null,
283
+ "dependencies": [],
284
+ "targets": [
285
+ {
286
+ "kind": [ "lib" ],
287
+ "name": "baz",
288
+ "src_path": "[..]baz[..]src[..]lib.rs"
289
+ }
290
+ ],
291
+ "features": {},
292
+ "manifest_path": "[..]baz[..]Cargo.toml"
293
+ }
294
+ ],
295
+ "workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
296
+ "resolve": null,
297
+ "version": 1
298
+ }"# ) )
299
+ }
300
+
177
301
#[ test]
178
302
fn cargo_metadata_with_invalid_manifest ( ) {
179
303
let p = project ( "foo" )
@@ -204,6 +328,7 @@ const MANIFEST_OUTPUT: &'static str=
204
328
"features":{},
205
329
"manifest_path":"[..]Cargo.toml"
206
330
}],
331
+ "workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ],
207
332
"resolve": null,
208
333
"version": 1
209
334
}"# ;
0 commit comments