test(toml): Show default features inheritance on 2024 Edition

This commit is contained in:
Ed Page 2024-05-01 11:26:24 -05:00
parent 656107a173
commit 2e686d46f3

View File

@ -1518,6 +1518,59 @@ true for `workspace.dependencies.dep`, this could become a hard error in the fut
.run();
}
#[cargo_test(nightly, reason = "edition2024 is not stable")]
fn warn_inherit_def_feat_true_member_def_feat_false_2024_edition() {
Package::new("dep", "0.1.0")
.feature("default", &["fancy_dep"])
.add_dep(Dependency::new("fancy_dep", "0.2").optional(true))
.file("src/lib.rs", "")
.publish();
Package::new("fancy_dep", "0.2.4").publish();
let p = project()
.file(
"Cargo.toml",
r#"
cargo-features = ["edition2024"]
[package]
name = "bar"
version = "0.2.0"
edition = "2024"
authors = []
[dependencies]
dep = { workspace = true, default-features = false }
[workspace]
members = []
[workspace.dependencies]
dep = { version = "0.1.0", default-features = true }
"#,
)
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("check")
.masquerade_as_nightly_cargo(&["edition2024"])
.with_stderr(
"\
[WARNING] [CWD]/Cargo.toml: `default-features` is ignored for dep, since `default-features` was \
true for `workspace.dependencies.dep`, this could become a hard error in the future
[UPDATING] `dummy-registry` index
[LOCKING] 3 packages to latest Rust [..] compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] fancy_dep v0.2.4 ([..])
[DOWNLOADED] dep v0.1.0 ([..])
[CHECKING] fancy_dep v0.2.4
[CHECKING] dep v0.1.0
[CHECKING] bar v0.2.0 ([CWD])
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
}
#[cargo_test]
fn warn_inherit_simple_member_def_feat_false() {
Package::new("dep", "0.1.0")
@ -1568,6 +1621,59 @@ not specified for `workspace.dependencies.dep`, this could become a hard error i
.run();
}
#[cargo_test(nightly, reason = "edition2024 is not stable")]
fn warn_inherit_simple_member_def_feat_false_2024_edition() {
Package::new("dep", "0.1.0")
.feature("default", &["fancy_dep"])
.add_dep(Dependency::new("fancy_dep", "0.2").optional(true))
.file("src/lib.rs", "")
.publish();
Package::new("fancy_dep", "0.2.4").publish();
let p = project()
.file(
"Cargo.toml",
r#"
cargo-features = ["edition2024"]
[package]
name = "bar"
version = "0.2.0"
edition = "2024"
authors = []
[dependencies]
dep = { workspace = true, default-features = false }
[workspace]
members = []
[workspace.dependencies]
dep = "0.1.0"
"#,
)
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("check")
.masquerade_as_nightly_cargo(&["edition2024"])
.with_stderr(
"\
[WARNING] [CWD]/Cargo.toml: `default-features` is ignored for dep, since `default-features` was \
not specified for `workspace.dependencies.dep`, this could become a hard error in the future
[UPDATING] `dummy-registry` index
[LOCKING] 3 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] fancy_dep v0.2.4 ([..])
[DOWNLOADED] dep v0.1.0 ([..])
[CHECKING] fancy_dep v0.2.4
[CHECKING] dep v0.1.0
[CHECKING] bar v0.2.0 ([CWD])
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
}
#[cargo_test]
fn inherit_def_feat_false_member_def_feat_true() {
Package::new("dep", "0.1.0")