From 244a91e7b96d5aace71783b845c607aa9bf7cb64 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 30 Jul 2024 13:36:28 -0500 Subject: [PATCH] test(publish): Add more dev-dep stripping regression cases --- tests/testsuite/publish.rs | 70 +++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index 79da7647b47..badfef3a216 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -1603,6 +1603,12 @@ fn publish_dev_dep_stripping() { Package::new("normal-only", "1.0.0") .feature("cat", &[]) .publish(); + Package::new("optional-dep-feature", "1.0.0") + .feature("cat", &[]) + .publish(); + Package::new("optional-namespaced", "1.0.0") + .feature("cat", &[]) + .publish(); Package::new("build-only", "1.0.0") .feature("cat", &[]) .publish(); @@ -1639,22 +1645,28 @@ fn publish_dev_dep_stripping() { "normal-only/cat", "build-only/cat", "dev-only/cat", + "renamed-dev-only01/cat", "normal-and-dev/cat", "target-normal-only/cat", "target-build-only/cat", "target-dev-only/cat", "target-normal-and-dev/cat", + "optional-dep-feature/cat", + "dep:optional-namespaced", ] [dependencies] normal-only = { version = "1.0", features = ["cat"] } normal-and-dev = { version = "1.0", features = ["cat"] } + optional-dep-feature = { version = "1.0", features = ["cat"], optional = true } + optional-namespaced = { version = "1.0", features = ["cat"], optional = true } [build-dependencies] build-only = { version = "1.0", features = ["cat"] } [dev-dependencies] dev-only = { path = "../dev-only", features = ["cat"] } + renamed-dev-only01 = { path = "../renamed-dev-only", features = ["cat"], package = "renamed-dev-only" } normal-and-dev = { version = "1.0", features = ["cat"] } [target.'cfg(unix)'.dependencies] @@ -1690,6 +1702,26 @@ fn publish_dev_dep_stripping() { pub fn cat() {} "#, ) + .file( + "renamed-dev-only/Cargo.toml", + r#" + [package] + name = "renamed-dev-only" + version = "0.1.0" + edition = "2015" + authors = [] + + [features] + cat = [] + "#, + ) + .file( + "renamed-dev-only/src/lib.rs", + r#" + #[cfg(feature = "cat")] + pub fn cat() {} + "#, + ) .build(); p.cargo("publish --no-verify") @@ -1738,6 +1770,28 @@ You may press ctrl-c to skip waiting; the crate should be available shortly. "target": null, "version_req": "^1.0" }, + { + "default_features": true, + "features": [ + "cat" + ], + "kind": "normal", + "name": "optional-dep-feature", + "optional": true, + "target": null, + "version_req": "^1.0" + }, + { + "default_features": true, + "features": [ + "cat" + ], + "kind": "normal", + "name": "optional-namespaced", + "optional": true, + "target": null, + "version_req": "^1.0" + }, { "default_features": true, "features": [ @@ -1814,7 +1868,9 @@ You may press ctrl-c to skip waiting; the crate should be available shortly. "normal-and-dev/cat", "target-normal-only/cat", "target-build-only/cat", - "target-normal-and-dev/cat" + "target-normal-and-dev/cat", + "optional-dep-feature/cat", + "dep:optional-namespaced" ] }, "homepage": "foo", @@ -1865,6 +1921,16 @@ features = ["cat"] version = "1.0" features = ["cat"] +[dependencies.optional-dep-feature] +version = "1.0" +features = ["cat"] +optional = true + +[dependencies.optional-namespaced] +version = "1.0" +features = ["cat"] +optional = true + [dev-dependencies.normal-and-dev] version = "1.0" features = ["cat"] @@ -1881,6 +1947,8 @@ foo_feature = [ "target-normal-only/cat", "target-build-only/cat", "target-normal-and-dev/cat", + "optional-dep-feature/cat", + "dep:optional-namespaced", ] [target."cfg(unix)".dependencies.target-normal-and-dev]