@@ -1614,6 +1614,127 @@ repository = "foo"
1614
1614
) ;
1615
1615
}
1616
1616
1617
+ // This test case have a feature `foo_feature = [byte-unit/alloc]` which is owned by `dev-dependencies`,
1618
+ // `cargo publish` should strip it to `foo_feature = []`.
1619
+ #[ cargo_test]
1620
+ fn publish_strip_feature_which_is_owned_by_dev_deps ( ) {
1621
+ let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
1622
+
1623
+ let p = project ( )
1624
+ . file (
1625
+ "Cargo.toml" ,
1626
+ r#"
1627
+ [package]
1628
+ name = "foo"
1629
+ version = "0.1.0"
1630
+ authors = []
1631
+ license = "MIT"
1632
+ description = "foo"
1633
+ documentation = "foo"
1634
+ homepage = "foo"
1635
+ repository = "foo"
1636
+
1637
+ [dependencies]
1638
+
1639
+ [dev-dependencies]
1640
+ byte-unit = {version = "4.0.19", features = ["alloc"]}
1641
+
1642
+ [features]
1643
+ foo_feature = ["byte-unit/alloc"]
1644
+
1645
+ "# ,
1646
+ )
1647
+ . file ( "src/lib.rs" , "" )
1648
+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.0.1" ) )
1649
+ . file ( "bar/src/lib.rs" , "" )
1650
+ . build ( ) ;
1651
+
1652
+ p. cargo ( "publish --no-verify" )
1653
+ . replace_crates_io ( registry. index_url ( ) )
1654
+ . with_stderr (
1655
+ "\
1656
+ [UPDATING] [..]
1657
+ [PACKAGING] foo v0.1.0 [..]
1658
+ [PACKAGED] [..] files, [..] ([..] compressed)
1659
+ [UPLOADING] foo v0.1.0 [..]
1660
+ [UPLOADED] foo v0.1.0 [..]
1661
+ note: Waiting [..]
1662
+ You may press ctrl-c [..]
1663
+ [PUBLISHED] foo v0.1.0 [..]
1664
+ " ,
1665
+ )
1666
+ . run ( ) ;
1667
+
1668
+ publish:: validate_upload_with_contents (
1669
+ r#"
1670
+ {
1671
+ "authors": [],
1672
+ "badges": {},
1673
+ "categories": [],
1674
+ "deps": [
1675
+ {
1676
+ "default_features": true,
1677
+ "features": [
1678
+ "alloc"
1679
+ ],
1680
+ "kind": "dev",
1681
+ "name": "byte-unit",
1682
+ "optional": false,
1683
+ "target": null,
1684
+ "version_req": "^4.0.19"
1685
+ }
1686
+ ],
1687
+ "description": "foo",
1688
+ "documentation": "foo",
1689
+ "features": {
1690
+ "foo_feature": [
1691
+ "byte-unit/alloc"
1692
+ ]
1693
+ },
1694
+ "homepage": "foo",
1695
+ "keywords": [],
1696
+ "license": "MIT",
1697
+ "license_file": null,
1698
+ "links": null,
1699
+ "name": "foo",
1700
+ "readme": null,
1701
+ "readme_file": null,
1702
+ "repository": "foo",
1703
+ "rust_version": null,
1704
+ "vers": "0.1.0"
1705
+ }
1706
+ "# ,
1707
+ "foo-0.1.0.crate" ,
1708
+ & [ "Cargo.toml" , "Cargo.toml.orig" , "src/lib.rs" ] ,
1709
+ & [ (
1710
+ "Cargo.toml" ,
1711
+ & format ! (
1712
+ r#"{}
1713
+ [package]
1714
+ name = "foo"
1715
+ version = "0.1.0"
1716
+ authors = []
1717
+ description = "foo"
1718
+ homepage = "foo"
1719
+ documentation = "foo"
1720
+ license = "MIT"
1721
+ repository = "foo"
1722
+
1723
+ [dependencies]
1724
+
1725
+ [dev-dependencies.byte-unit]
1726
+ version = "4.0.19"
1727
+ features = ["alloc"]
1728
+
1729
+ [features]
1730
+ foo_feature = []
1731
+ "# ,
1732
+ cargo:: core:: package:: MANIFEST_PREAMBLE
1733
+ ) ,
1734
+ ) ] ,
1735
+ ) ;
1736
+ }
1737
+
1617
1738
#[ cargo_test]
1618
1739
fn credentials_ambiguous_filename ( ) {
1619
1740
// `publish` generally requires a remote registry
0 commit comments