1
- //! Tests for -Zpackage-features2
1
+ //! Tests for -Zpackage-features
2
2
3
3
use cargo_test_support:: registry:: Package ;
4
4
use cargo_test_support:: { basic_manifest, project} ;
@@ -61,7 +61,7 @@ fn virtual_no_default_features() {
61
61
)
62
62
. run ( ) ;
63
63
64
- p. cargo ( "check --no-default-features -Zpackage-features2 " )
64
+ p. cargo ( "check --no-default-features -Zpackage-features " )
65
65
. masquerade_as_nightly_cargo ( )
66
66
. with_stderr_unordered (
67
67
"\
@@ -73,13 +73,13 @@ fn virtual_no_default_features() {
73
73
)
74
74
. run ( ) ;
75
75
76
- p. cargo ( "check --features foo -Zpackage-features2 " )
76
+ p. cargo ( "check --features foo -Zpackage-features " )
77
77
. masquerade_as_nightly_cargo ( )
78
78
. with_status ( 101 )
79
79
. with_stderr ( "[ERROR] none of the selected packages contains these features: foo" )
80
80
. run ( ) ;
81
81
82
- p. cargo ( "check --features a/dep1,b/f1,b/f2,f2 -Zpackage-features2 " )
82
+ p. cargo ( "check --features a/dep1,b/f1,b/f2,f2 -Zpackage-features " )
83
83
. masquerade_as_nightly_cargo ( )
84
84
. with_status ( 101 )
85
85
. with_stderr ( "[ERROR] none of the selected packages contains these features: b/f2, f2" )
@@ -129,7 +129,7 @@ fn virtual_features() {
129
129
)
130
130
. run ( ) ;
131
131
132
- p. cargo ( "check --features f1 -Zpackage-features2 " )
132
+ p. cargo ( "check --features f1 -Zpackage-features " )
133
133
. masquerade_as_nightly_cargo ( )
134
134
. with_stderr_unordered (
135
135
"\
@@ -206,7 +206,7 @@ fn virtual_with_specific() {
206
206
)
207
207
. run ( ) ;
208
208
209
- p. cargo ( "check -p a -p b --features f1,f2,f3 -Zpackage-features2 " )
209
+ p. cargo ( "check -p a -p b --features f1,f2,f3 -Zpackage-features " )
210
210
. masquerade_as_nightly_cargo ( )
211
211
. with_stderr_unordered (
212
212
"\
@@ -280,7 +280,7 @@ fn other_member_from_current() {
280
280
. with_stdout ( "f3f4" )
281
281
. run ( ) ;
282
282
283
- p. cargo ( "run -p bar --features f1 -Zpackage-features2 " )
283
+ p. cargo ( "run -p bar --features f1 -Zpackage-features " )
284
284
. masquerade_as_nightly_cargo ( )
285
285
. with_stdout ( "f1" )
286
286
. run ( ) ;
@@ -290,7 +290,7 @@ fn other_member_from_current() {
290
290
. with_stderr ( "[ERROR] Package `foo[..]` does not have these features: `f2`" )
291
291
. run ( ) ;
292
292
293
- p. cargo ( "run -p bar --features f1,f2 -Zpackage-features2 " )
293
+ p. cargo ( "run -p bar --features f1,f2 -Zpackage-features " )
294
294
. masquerade_as_nightly_cargo ( )
295
295
. with_stdout ( "f1f2" )
296
296
. run ( ) ;
@@ -299,7 +299,7 @@ fn other_member_from_current() {
299
299
. with_stdout ( "f1f3" )
300
300
. run ( ) ;
301
301
302
- p. cargo ( "run -p bar --features bar/f1 -Zpackage-features2 " )
302
+ p. cargo ( "run -p bar --features bar/f1 -Zpackage-features " )
303
303
. masquerade_as_nightly_cargo ( )
304
304
. with_stdout ( "f1" )
305
305
. run ( ) ;
@@ -375,43 +375,98 @@ fn virtual_member_slash() {
375
375
)
376
376
. run ( ) ;
377
377
378
- p. cargo ( "check -p a -Zpackage-features2 " )
378
+ p. cargo ( "check -p a -Zpackage-features " )
379
379
. masquerade_as_nightly_cargo ( )
380
380
. with_status ( 101 )
381
381
. with_stderr_contains ( "[..]f1 is set[..]" )
382
382
. with_stderr_does_not_contain ( "[..]f2 is set[..]" )
383
383
. with_stderr_does_not_contain ( "[..]b is set[..]" )
384
384
. run ( ) ;
385
385
386
- p. cargo ( "check -p a --features a/f1 -Zpackage-features2 " )
386
+ p. cargo ( "check -p a --features a/f1 -Zpackage-features " )
387
387
. masquerade_as_nightly_cargo ( )
388
388
. with_status ( 101 )
389
389
. with_stderr_contains ( "[..]f1 is set[..]" )
390
390
. with_stderr_does_not_contain ( "[..]f2 is set[..]" )
391
391
. with_stderr_does_not_contain ( "[..]b is set[..]" )
392
392
. run ( ) ;
393
393
394
- p. cargo ( "check -p a --features a/f2 -Zpackage-features2 " )
394
+ p. cargo ( "check -p a --features a/f2 -Zpackage-features " )
395
395
. masquerade_as_nightly_cargo ( )
396
396
. with_status ( 101 )
397
397
. with_stderr_contains ( "[..]f1 is set[..]" )
398
398
. with_stderr_contains ( "[..]f2 is set[..]" )
399
399
. with_stderr_does_not_contain ( "[..]b is set[..]" )
400
400
. run ( ) ;
401
401
402
- p. cargo ( "check -p a --features b/bfeat -Zpackage-features2 " )
402
+ p. cargo ( "check -p a --features b/bfeat -Zpackage-features " )
403
403
. masquerade_as_nightly_cargo ( )
404
404
. with_status ( 101 )
405
405
. with_stderr_contains ( "[..]bfeat is set[..]" )
406
406
. run ( ) ;
407
407
408
- p. cargo ( "check -p a --no-default-features -Zpackage-features2 " )
408
+ p. cargo ( "check -p a --no-default-features -Zpackage-features " )
409
409
. masquerade_as_nightly_cargo ( )
410
410
. run ( ) ;
411
411
412
- p. cargo ( "check -p a --no-default-features --features b -Zpackage-features2 " )
412
+ p. cargo ( "check -p a --no-default-features --features b -Zpackage-features " )
413
413
. masquerade_as_nightly_cargo ( )
414
414
. with_status ( 101 )
415
415
. with_stderr_contains ( "[..]b is set[..]" )
416
416
. run ( ) ;
417
417
}
418
+
419
+ #[ cargo_test]
420
+ fn non_member ( ) {
421
+ // -p for a non-member
422
+ Package :: new ( "dep" , "1.0.0" ) . publish ( ) ;
423
+ let p = project ( )
424
+ . file (
425
+ "Cargo.toml" ,
426
+ r#"
427
+ [package]
428
+ name = "foo"
429
+ version = "0.1.0"
430
+
431
+ [dependencies]
432
+ dep = "1.0"
433
+
434
+ [features]
435
+ f1 = []
436
+ "# ,
437
+ )
438
+ . file ( "src/lib.rs" , "" )
439
+ . build ( ) ;
440
+
441
+ p. cargo ( "build -Zpackage-features -p dep --features f1" )
442
+ . masquerade_as_nightly_cargo ( )
443
+ . with_status ( 101 )
444
+ . with_stderr (
445
+ "[UPDATING][..]\n [ERROR] cannot specify features for packages outside of workspace" ,
446
+ )
447
+ . run ( ) ;
448
+
449
+ p. cargo ( "build -Zpackage-features -p dep --all-features" )
450
+ . masquerade_as_nightly_cargo ( )
451
+ . with_status ( 101 )
452
+ . with_stderr ( "[ERROR] cannot specify features for packages outside of workspace" )
453
+ . run ( ) ;
454
+
455
+ p. cargo ( "build -Zpackage-features -p dep --no-default-features" )
456
+ . masquerade_as_nightly_cargo ( )
457
+ . with_status ( 101 )
458
+ . with_stderr ( "[ERROR] cannot specify features for packages outside of workspace" )
459
+ . run ( ) ;
460
+
461
+ p. cargo ( "build -Zpackage-features -p dep" )
462
+ . masquerade_as_nightly_cargo ( )
463
+ . with_stderr (
464
+ "\
465
+ [DOWNLOADING] [..]
466
+ [DOWNLOADED] [..]
467
+ [COMPILING] dep [..]
468
+ [FINISHED] [..]
469
+ " ,
470
+ )
471
+ . run ( ) ;
472
+ }
0 commit comments