Skip to content

Commit 25be678

Browse files
committed
Add unit test for publish dev-dep only owned feature
1 parent a1583c8 commit 25be678

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

tests/testsuite/publish.rs

+105
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,111 @@ repository = "foo"
16141614
);
16151615
}
16161616

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

0 commit comments

Comments
 (0)