Skip to content

Commit 8e6e9c9

Browse files
committed
test: extend some edge case on feature dep
1 parent 9f08721 commit 8e6e9c9

File tree

1 file changed

+56
-64
lines changed

1 file changed

+56
-64
lines changed

tests/testsuite/publish.rs

Lines changed: 56 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,9 +1687,26 @@ repository = "foo"
16871687
}
16881688

16891689
#[cargo_test]
1690-
fn publish_feature_point_to_stripped_dep() {
1690+
fn publish_with_feature_point_diff_kinds_dep() {
16911691
let registry = RegistryBuilder::new().http_api().http_index().build();
1692-
1692+
Package::new("normal-only", "1.0.0")
1693+
.feature("cat", &[])
1694+
.publish();
1695+
Package::new("build-only", "1.0.0")
1696+
.feature("cat", &[])
1697+
.publish();
1698+
Package::new("normal-and-dev", "1.0.0")
1699+
.feature("cat", &[])
1700+
.publish();
1701+
Package::new("target-normal-only", "1.0.0")
1702+
.feature("cat", &[])
1703+
.publish();
1704+
Package::new("target-build-only", "1.0.0")
1705+
.feature("cat", &[])
1706+
.publish();
1707+
Package::new("target-normal-and-dev", "1.0.0")
1708+
.feature("cat", &[])
1709+
.publish();
16931710
let p = project()
16941711
.file(
16951712
"Cargo.toml",
@@ -1707,11 +1724,38 @@ fn publish_feature_point_to_stripped_dep() {
17071724
17081725
17091726
[features]
1710-
foo_feature = ["bar/cat"]
1727+
foo_feature = [
1728+
"normal-only/cat",
1729+
"build-only/cat",
1730+
"dev-only/cat",
1731+
"normal-and-dev/cat",
1732+
"target-normal-only/cat",
1733+
"target-build-only/cat",
1734+
"target-dev-only/cat",
1735+
"target-normal-and-dev/cat",
1736+
]
1737+
1738+
[dependencies]
1739+
normal-only = { version = "1.0", features = ["cat"] }
1740+
normal-and-dev = { version = "1.0", features = ["cat"] }
1741+
1742+
[build-dependencies]
1743+
build-only = { version = "1.0", features = ["cat"] }
1744+
1745+
[dev-dependencies]
1746+
dev-only = { path = "../bar", features = ["cat"] }
1747+
normal-and-dev = { version = "1.0", features = ["cat"] }
17111748
1712-
[dev-dependencies.bar]
1713-
path = "../bar"
1714-
features = ["cat"]
1749+
[target.'cfg(unix)'.dependencies]
1750+
target-normal-only = { version = "1.0", features = ["cat"] }
1751+
target-normal-and-dev = { version = "1.0", features = ["cat"] }
1752+
1753+
[target.'cfg(unix)'.build-dependencies]
1754+
target-build-only = { version = "1.0", features = ["cat"] }
1755+
1756+
[target.'cfg(unix)'.dev-dependencies]
1757+
target-dev-only = { path = "../bar", features = ["cat"] }
1758+
target-normal-and-dev = { version = "1.0", features = ["cat"] }
17151759
"#,
17161760
)
17171761
.file("src/main.rs", "")
@@ -1738,72 +1782,20 @@ fn publish_feature_point_to_stripped_dep() {
17381782
.build();
17391783

17401784
p.cargo("publish --no-verify")
1785+
.env("RUSTFLAGS", "--cfg unix")
17411786
.replace_crates_io(registry.index_url())
1787+
.with_status(101)
17421788
.with_stderr(
17431789
"\
17441790
[UPDATING] [..]
17451791
[PACKAGING] foo v0.1.0 [..]
1746-
[PACKAGED] [..] files, [..] ([..] compressed)
1747-
[UPLOADING] foo v0.1.0 [..]
1748-
[UPLOADED] foo v0.1.0 [..]
1749-
[NOTE] waiting [..]
1750-
You may press ctrl-c [..]
1751-
[PUBLISHED] foo v0.1.0 [..]
1792+
[ERROR] failed to prepare local package [..]
1793+
1794+
Caused by:
1795+
feature `foo_feature` includes `target-dev-only/cat`, but `target-dev-only` is not a dependency
17521796
",
17531797
)
17541798
.run();
1755-
1756-
publish::validate_upload_with_contents(
1757-
r#"
1758-
{
1759-
"authors": [],
1760-
"badges": {},
1761-
"categories": [],
1762-
"deps": [],
1763-
"description": "foo",
1764-
"documentation": "foo",
1765-
"features": {
1766-
"foo_feature": []
1767-
},
1768-
"homepage": "foo",
1769-
"keywords": [],
1770-
"license": "MIT",
1771-
"license_file": null,
1772-
"links": null,
1773-
"name": "foo",
1774-
"readme": null,
1775-
"readme_file": null,
1776-
"repository": "foo",
1777-
"rust_version": null,
1778-
"vers": "0.1.0"
1779-
}
1780-
"#,
1781-
"foo-0.1.0.crate",
1782-
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
1783-
&[(
1784-
"Cargo.toml",
1785-
&format!(
1786-
r#"{}
1787-
[package]
1788-
edition = "2015"
1789-
name = "foo"
1790-
version = "0.1.0"
1791-
authors = []
1792-
description = "foo"
1793-
homepage = "foo"
1794-
documentation = "foo"
1795-
license = "MIT"
1796-
repository = "foo"
1797-
1798-
[dev-dependencies]
1799-
1800-
[features]
1801-
foo_feature = []
1802-
"#,
1803-
cargo::core::package::MANIFEST_PREAMBLE
1804-
),
1805-
)],
1806-
);
18071799
}
18081800
#[cargo_test]
18091801
fn credentials_ambiguous_filename() {

0 commit comments

Comments
 (0)