@@ -1628,6 +1628,96 @@ fn exclude_but_also_depend() {
16281628 assert ! ( p. root( ) . join( "foo/bar/target" ) . is_dir( ) ) ;
16291629}
16301630
1631+ #[ cargo_test]
1632+ fn excluded_default_members_still_must_be_members ( ) {
1633+ let p = project ( )
1634+ . file (
1635+ "Cargo.toml" ,
1636+ r#"
1637+ [workspace]
1638+ members = ["foo"]
1639+ default-members = ["foo", "bar"]
1640+ exclude = ["bar"]
1641+ "# ,
1642+ )
1643+ . file ( "foo/Cargo.toml" , & basic_manifest ( "foo" , "0.1.0" ) )
1644+ . file ( "foo/src/lib.rs" , "" )
1645+ . file ( "bar/something.txt" , "" ) ;
1646+ let p = p. build ( ) ;
1647+ p. cargo ( "build" )
1648+ . with_status ( 101 )
1649+ . with_stderr (
1650+ "\
1651+ error: package `[..]bar` is listed in workspace’s default-members \
1652+ but is not a member.
1653+ " ,
1654+ )
1655+ . run ( ) ;
1656+ }
1657+
1658+ #[ cargo_test]
1659+ fn excluded_default_members_crate_glob ( ) {
1660+ let p = project ( )
1661+ . file (
1662+ "Cargo.toml" ,
1663+ r#"
1664+ [workspace]
1665+ members = ["foo", "bar/*"]
1666+ default-members = ["bar/*"]
1667+ exclude = ["bar/quux"]
1668+ "# ,
1669+ )
1670+ . file ( "foo/Cargo.toml" , & basic_manifest ( "foo" , "0.1.0" ) )
1671+ . file ( "foo/src/main.rs" , "fn main() {}" )
1672+ . file ( "bar/baz/Cargo.toml" , & basic_manifest ( "baz" , "0.1.0" ) )
1673+ . file ( "bar/baz/src/main.rs" , "fn main() {}" )
1674+ . file ( "bar/quux/Cargo.toml" , & basic_manifest ( "quux" , "0.1.0" ) )
1675+ . file ( "bar/quux/src/main.rs" , "fn main() {}" ) ;
1676+
1677+ let p = p. build ( ) ;
1678+ p. cargo ( "build" ) . run ( ) ;
1679+
1680+ assert ! ( p. root( ) . join( "target" ) . is_dir( ) ) ;
1681+ assert ! ( !p. bin( "foo" ) . is_file( ) ) ;
1682+ assert ! ( p. bin( "baz" ) . is_file( ) ) ;
1683+ assert ! ( !p. bin( "quux" ) . exists( ) ) ;
1684+
1685+ p. cargo ( "build --workspace" ) . run ( ) ;
1686+ assert ! ( p. root( ) . join( "target" ) . is_dir( ) ) ;
1687+ assert ! ( p. bin( "foo" ) . is_file( ) ) ;
1688+ assert ! ( !p. bin( "quux" ) . exists( ) ) ;
1689+
1690+ p. cargo ( "build" ) . cwd ( "bar/quux" ) . run ( ) ;
1691+ assert ! ( p. root( ) . join( "bar/quux/target" ) . is_dir( ) ) ;
1692+ }
1693+
1694+ #[ cargo_test]
1695+ fn excluded_default_members_not_crate_glob ( ) {
1696+ let p = project ( )
1697+ . file (
1698+ "Cargo.toml" ,
1699+ r#"
1700+ [workspace]
1701+ members = ["foo", "bar/*"]
1702+ default-members = ["bar/*"]
1703+ exclude = ["bar/docs"]
1704+ "# ,
1705+ )
1706+ . file ( "foo/Cargo.toml" , & basic_manifest ( "foo" , "0.1.0" ) )
1707+ . file ( "foo/src/main.rs" , "fn main() {}" )
1708+ . file ( "bar/baz/Cargo.toml" , & basic_manifest ( "baz" , "0.1.0" ) )
1709+ . file ( "bar/baz/src/main.rs" , "fn main() {}" )
1710+ . file ( "bar/docs/readme.txt" , "This folder is not a crate!" ) ;
1711+
1712+ let p = p. build ( ) ;
1713+ p. cargo ( "build" ) . run ( ) ;
1714+
1715+ assert ! ( !p. bin( "foo" ) . is_file( ) ) ;
1716+ assert ! ( p. bin( "baz" ) . is_file( ) ) ;
1717+ p. cargo ( "build --workspace" ) . run ( ) ;
1718+ assert ! ( p. bin( "foo" ) . is_file( ) ) ;
1719+ }
1720+
16311721#[ cargo_test]
16321722fn glob_syntax ( ) {
16331723 let p = project ( )
0 commit comments