From 649a14d47057efaa5d76dbd23283b5fec1703a71 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 1 Nov 2023 14:12:25 -0700 Subject: [PATCH] Add regression test for issue 6915: features and transitive dev deps --- tests/testsuite/features.rs | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index 557fab14ab2..236b6f65181 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -1143,6 +1143,61 @@ fn activating_feature_activates_dep() { p.cargo("check --features a -v").run(); } +#[cargo_test] +fn activating_feature_does_not_activate_transitive_dev_dependency() { + let p = project() + .no_manifest() + .file( + "a/Cargo.toml", + r#" + [package] + name = "a" + version = "0.0.0" + edition = "2021" + + [features] + f = ["b/f"] + + [dependencies] + b = { path = "../b" } + "#, + ) + .file( + "b/Cargo.toml", + r#" + [package] + name = "b" + version = "0.0.0" + edition = "2021" + + [features] + f = ["c/f"] + + [dev-dependencies] + c = { path = "../c" } + "#, + ) + .file( + "c/Cargo.toml", + r#" + [package] + name = "c" + version = "0.0.0" + edition = "2021" + + [features] + f = [] + "#, + ) + .file("a/src/lib.rs", "") + .file("b/src/lib.rs", "") + .file("c/src/lib.rs", "compile_error!") + .build(); + + p.cargo("check --manifest-path a/Cargo.toml --features f") + .run(); +} + #[cargo_test] fn dep_feature_in_cmd_line() { let p = project()