1
1
//! Tests for public/private dependencies.
2
2
3
3
use cargo_test_support:: project;
4
- use cargo_test_support:: registry:: Package ;
4
+ use cargo_test_support:: registry:: { Dependency , Package } ;
5
5
6
6
#[ cargo_test( nightly, reason = "exported_private_dependencies lint is unstable" ) ]
7
7
fn exported_priv_warning ( ) {
@@ -486,7 +486,8 @@ fn recursive_package_pub_no_warning() {
486
486
. file ( "src/lib.rs" , "pub struct FromPub;" )
487
487
. publish ( ) ;
488
488
Package :: new ( "parent_bar" , "0.1.0" )
489
- . dep ( "grandparent_bar" , "0.1.0" )
489
+ . cargo_feature ( "public-dependency" )
490
+ . add_dep ( Dependency :: new ( "grandparent_bar" , "0.1.0" ) . public ( true ) )
490
491
. file (
491
492
"src/lib.rs" ,
492
493
"
@@ -496,7 +497,8 @@ fn recursive_package_pub_no_warning() {
496
497
)
497
498
. publish ( ) ;
498
499
Package :: new ( "pub_dep" , "0.1.0" )
499
- . dep ( "parent_bar" , "0.1.0" )
500
+ . cargo_feature ( "public-dependency" )
501
+ . add_dep ( Dependency :: new ( "parent_bar" , "0.1.0" ) . public ( true ) )
500
502
. file (
501
503
"src/lib.rs" ,
502
504
"
@@ -530,18 +532,8 @@ fn recursive_package_pub_no_warning() {
530
532
531
533
p. cargo ( "check --message-format=short" )
532
534
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
533
- . with_stderr (
534
- "\
535
- [UPDATING] `[..]` index
536
- [DOWNLOADING] crates ...
537
- [DOWNLOADED] pub_dep v0.1.0 ([..])
538
- [DOWNLOADED] parent_bar v0.1.0 ([..])
539
- [DOWNLOADED] grandparent_bar v0.1.0 ([..])
540
- [CHECKING] grandparent_bar v0.1.0
541
- [CHECKING] parent_bar v0.1.0
542
- [CHECKING] pub_dep v0.1.0
543
- [CHECKING] foo v0.0.1 ([CWD])
544
- [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" ,
535
+ . with_stderr_contains (
536
+ "src/lib.rs:3:13: warning: type `FromPub` from private dependency 'grandparent_bar' in public interface"
545
537
)
546
538
. run ( )
547
539
}
@@ -552,7 +544,8 @@ fn recursive_package_priv_warning() {
552
544
. file ( "src/lib.rs" , "pub struct FromPriv;" )
553
545
. publish ( ) ;
554
546
Package :: new ( "parent_bar" , "0.1.0" )
555
- . dep ( "grandparent_bar" , "0.1.0" )
547
+ . cargo_feature ( "public-dependency" )
548
+ . add_dep ( Dependency :: new ( "grandparent_bar" , "0.1.0" ) . public ( true ) )
556
549
. file (
557
550
"src/lib.rs" ,
558
551
"
@@ -562,7 +555,8 @@ fn recursive_package_priv_warning() {
562
555
)
563
556
. publish ( ) ;
564
557
Package :: new ( "priv_dep" , "0.1.0" )
565
- . dep ( "parent_bar" , "0.1.0" )
558
+ . cargo_feature ( "public-dependency" )
559
+ . add_dep ( Dependency :: new ( "parent_bar" , "0.1.0" ) . public ( true ) )
566
560
. file (
567
561
"src/lib.rs" ,
568
562
"
@@ -596,18 +590,8 @@ fn recursive_package_priv_warning() {
596
590
597
591
p. cargo ( "check --message-format=short" )
598
592
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
599
- . with_stderr (
600
- "\
601
- [UPDATING] `[..]` index
602
- [DOWNLOADING] crates ...
603
- [DOWNLOADED] priv_dep v0.1.0 ([..])
604
- [DOWNLOADED] parent_bar v0.1.0 ([..])
605
- [DOWNLOADED] grandparent_bar v0.1.0 ([..])
606
- [CHECKING] grandparent_bar v0.1.0
607
- [CHECKING] parent_bar v0.1.0
608
- [CHECKING] priv_dep v0.1.0
609
- [CHECKING] foo v0.0.1 ([CWD])
610
- [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" ,
593
+ . with_stderr_contains (
594
+ "src/lib.rs:3:13: warning: type `FromPriv` from private dependency 'grandparent_bar' in public interface"
611
595
)
612
596
. run ( )
613
597
}
0 commit comments