diff --git a/tests/testsuite/cargo_lints.rs b/tests/testsuite/cargo_lints.rs index ed0fea3720ee..9df65071d7ac 100644 --- a/tests/testsuite/cargo_lints.rs +++ b/tests/testsuite/cargo_lints.rs @@ -1,3 +1,12 @@ +//! Tests for `[lint.cargo]`, Cargo's linting system, and Cargo's lints +//! +//! The first section is general tests of `[lint.cargo]` and the linting system +//! itself. +//! +//! The second section is tests for specific lints. +//! Search for `LINT_SPECIFIC_TESTS` to find this section, or search for the +//! lint name to find tests for a specific lint. + use cargo_test_support::project; use cargo_test_support::registry::Package; @@ -432,3 +441,237 @@ error: encountered 2 errors(s) while verifying lints ) .run(); } + +// LINT_SPECIFIC_TESTS +// +// Below this is where tests for specific lints should be added. Tests should +// be organized by lint, kept in alphabetical order, by lint name. A comment +// should be added above each lint's tests with the uppercased name of the lint + +// IMPLICIT_FEATURES + +#[cargo_test] +fn implicit_features_default_allow() { + Package::new("bar", "0.1.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" +[package] +name = "foo" +version = "0.1.0" +edition = "2021" + +[dependencies] +bar = { version = "0.1.0", optional = true } +"#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check -Zcargo-lints") + .masquerade_as_nightly_cargo(&["cargo-lints"]) + .with_stderr( + "\ +[UPDATING] [..] +[LOCKING] 2 packages to latest compatible versions +[CHECKING] foo v0.1.0 ([CWD]) +[FINISHED] [..] +", + ) + .run(); +} + +#[cargo_test(nightly, reason = "edition2024 is not stable")] +fn implicit_features_edition_2024() { + Package::new("bar", "0.1.0").publish(); + Package::new("baz", "0.1.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" +cargo-features = ["edition2024"] +[package] +name = "foo" +version = "0.1.0" +edition = "2024" + +[dependencies] +bar = { version = "0.1.0", optional = true } +baz = { version = "0.1.0", optional = true } + +[features] +baz = ["dep:baz"] + +[lints.cargo] +unused_optional_dependency = "allow" +"#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check -Zcargo-lints") + .masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"]) + .with_stderr( + "\ +[UPDATING] [..] +[LOCKING] 2 packages to latest Rust [..] compatible versions +[CHECKING] foo v0.1.0 ([CWD]) +[FINISHED] [..] +", + ) + .run(); +} + +// UNKNOWN_LINTS + +#[cargo_test] +fn unknown_lints_inherited() { + let p = project() + .file( + "Cargo.toml", + r#" +[workspace] +members = ["foo"] + +[workspace.lints.cargo] +this-lint-does-not-exist = "warn" +"#, + ) + .file( + "foo/Cargo.toml", + r#" +[package] +name = "foo" +version = "0.0.1" +edition = "2015" +authors = [] + +[lints] +workspace = true + "#, + ) + .file("foo/src/lib.rs", "") + .build(); + + p.cargo("check -Zcargo-lints") + .masquerade_as_nightly_cargo(&["cargo-lints"]) + .with_stderr( + "\ +warning: unknown lint: `this-lint-does-not-exist` + --> Cargo.toml:6:1 + | +6 | this-lint-does-not-exist = \"warn\" + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `cargo::this-lint-does-not-exist` was inherited + --> foo/Cargo.toml:9:1 + | +9 | workspace = true + | ---------------- + | + = note: `cargo::unknown_lints` is set to `warn` by default +[CHECKING] foo v0.0.1 ([CWD]/foo) +[FINISHED] [..] +", + ) + .run(); +} + +// UNUSED_OPTIONAL_DEPENDENCIES + +#[cargo_test] +fn unused_optional_dependencies_edition_2021() { + Package::new("bar", "0.1.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" +[package] +name = "foo" +version = "0.1.0" +edition = "2021" + +[dependencies] +bar = { version = "0.1.0", optional = true } + +[lints.cargo] +implicit_features = "allow" +"#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check -Zcargo-lints") + .masquerade_as_nightly_cargo(&["cargo-lints"]) + .with_stderr( + "\ +[UPDATING] [..] +[LOCKING] 2 packages to latest compatible versions +[CHECKING] foo v0.1.0 ([CWD]) +[FINISHED] [..] +", + ) + .run(); +} + +#[cargo_test(nightly, reason = "edition2024 is not stable")] +fn unused_optional_dependencies_renamed_deps() { + Package::new("bar", "0.1.0").publish(); + Package::new("bar", "0.2.0").publish(); + Package::new("target-dep", "0.1.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" +cargo-features = ["edition2024"] +[package] +name = "foo" +version = "0.1.0" +edition = "2024" + +[dependencies] +bar = { version = "0.1.0", optional = true } + +[build-dependencies] +baz = { version = "0.2.0", package = "bar", optional = true } + +[target.'cfg(target_os = "linux")'.dependencies] +target-dep = { version = "0.1.0", optional = true } +"#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check -Zcargo-lints") + .masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"]) + .with_stderr( + "\ +warning: unused optional dependency + --> Cargo.toml:9:1 + | +9 | bar = { version = \"0.1.0\", optional = true } + | --- + | + = note: `cargo::unused_optional_dependency` is set to `warn` by default + = help: remove the dependency or activate it in a feature with `dep:bar` +warning: unused optional dependency + --> Cargo.toml:12:1 + | +12 | baz = { version = \"0.2.0\", package = \"bar\", optional = true } + | --- + | + = help: remove the dependency or activate it in a feature with `dep:baz` +warning: unused optional dependency + --> Cargo.toml:15:1 + | +15 | target-dep = { version = \"0.1.0\", optional = true } + | ---------- + | + = help: remove the dependency or activate it in a feature with `dep:target-dep` +[CHECKING] foo v0.1.0 ([CWD]) +[FINISHED] [..] +", + ) + .run(); +} diff --git a/tests/testsuite/lints/implicit_features/edition_2021/mod.rs b/tests/testsuite/lints/implicit_features/edition_2021/mod.rs deleted file mode 100644 index 7ab75c6c7b8a..000000000000 --- a/tests/testsuite/lints/implicit_features/edition_2021/mod.rs +++ /dev/null @@ -1,32 +0,0 @@ -use cargo_test_support::prelude::*; -use cargo_test_support::project; -use cargo_test_support::registry::Package; -use cargo_test_support::{file, str}; - -#[cargo_test] -fn case() { - Package::new("bar", "0.1.0").publish(); - let p = project() - .file( - "Cargo.toml", - r#" -[package] -name = "foo" -version = "0.1.0" -edition = "2021" - -[dependencies] -bar = { version = "0.1.0", optional = true } -"#, - ) - .file("src/lib.rs", "") - .build(); - - snapbox::cmd::Command::cargo_ui() - .current_dir(p.root()) - .arg("check") - .assert() - .success() - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); -} diff --git a/tests/testsuite/lints/implicit_features/edition_2021/stderr.term.svg b/tests/testsuite/lints/implicit_features/edition_2021/stderr.term.svg deleted file mode 100644 index f07262668334..000000000000 --- a/tests/testsuite/lints/implicit_features/edition_2021/stderr.term.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - Updating `dummy-registry` index - - Locking 2 packages to latest compatible versions - - Checking foo v0.1.0 ([ROOT]/foo) - - Finished[..] - - - - - - diff --git a/tests/testsuite/lints/implicit_features/edition_2021_warn/mod.rs b/tests/testsuite/lints/implicit_features/edition_2021_warn/mod.rs deleted file mode 100644 index 45f29b029fab..000000000000 --- a/tests/testsuite/lints/implicit_features/edition_2021_warn/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -use cargo_test_support::prelude::*; -use cargo_test_support::registry::Package; -use cargo_test_support::str; -use cargo_test_support::{file, project}; - -#[cargo_test] -fn case() { - Package::new("bar", "0.1.0").publish(); - Package::new("baz", "0.1.0").publish(); - Package::new("target-dep", "0.1.0").publish(); - let p = project() - .file( - "Cargo.toml", - r#" -[package] -name = "foo" -version = "0.1.0" -edition = "2021" - -[dependencies] -bar = { version = "0.1.0", optional = true } - -[build-dependencies] -baz = { version = "0.1.0", optional = true } - -[target.'cfg(target_os = "linux")'.dependencies] -target-dep = { version = "0.1.0", optional = true } - -[lints.cargo] -implicit_features = "warn" -"#, - ) - .file("src/lib.rs", "") - .build(); - - snapbox::cmd::Command::cargo_ui() - .masquerade_as_nightly_cargo(&["cargo-lints"]) - .current_dir(p.root()) - .arg("check") - .arg("-Zcargo-lints") - .assert() - .success() - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); -} diff --git a/tests/testsuite/lints/implicit_features/edition_2024/mod.rs b/tests/testsuite/lints/implicit_features/edition_2024/mod.rs deleted file mode 100644 index ca682aa8a5af..000000000000 --- a/tests/testsuite/lints/implicit_features/edition_2024/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -use cargo_test_support::prelude::*; -use cargo_test_support::registry::Package; -use cargo_test_support::str; -use cargo_test_support::{file, project}; - -#[cargo_test(nightly, reason = "edition2024 is not stable")] -fn case() { - Package::new("bar", "0.1.0").publish(); - Package::new("baz", "0.1.0").publish(); - let p = project() - .file( - "Cargo.toml", - r#" -cargo-features = ["edition2024"] -[package] -name = "foo" -version = "0.1.0" -edition = "2024" - -[dependencies] -bar = { version = "0.1.0", optional = true } -baz = { version = "0.1.0", optional = true } - -[features] -baz = ["dep:baz"] - -[lints.cargo] -unused_optional_dependency = "allow" -"#, - ) - .file("src/lib.rs", "") - .build(); - - snapbox::cmd::Command::cargo_ui() - .masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"]) - .current_dir(p.root()) - .arg("check") - .arg("-Zcargo-lints") - .assert() - .success() - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); -} diff --git a/tests/testsuite/lints/implicit_features/edition_2024/stderr.term.svg b/tests/testsuite/lints/implicit_features/edition_2024/stderr.term.svg deleted file mode 100644 index 6c0f3b67a557..000000000000 --- a/tests/testsuite/lints/implicit_features/edition_2024/stderr.term.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - Updating `dummy-registry` index - - Locking 2 packages to latest Rust [..] compatible versions - - Checking foo v0.1.0 ([ROOT]/foo) - - Finished [..] - - - - - - diff --git a/tests/testsuite/lints/implicit_features/mod.rs b/tests/testsuite/lints/implicit_features/mod.rs index 3865b14a2ee1..45f29b029fab 100644 --- a/tests/testsuite/lints/implicit_features/mod.rs +++ b/tests/testsuite/lints/implicit_features/mod.rs @@ -1,3 +1,45 @@ -mod edition_2021; -mod edition_2021_warn; -mod edition_2024; +use cargo_test_support::prelude::*; +use cargo_test_support::registry::Package; +use cargo_test_support::str; +use cargo_test_support::{file, project}; + +#[cargo_test] +fn case() { + Package::new("bar", "0.1.0").publish(); + Package::new("baz", "0.1.0").publish(); + Package::new("target-dep", "0.1.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" +[package] +name = "foo" +version = "0.1.0" +edition = "2021" + +[dependencies] +bar = { version = "0.1.0", optional = true } + +[build-dependencies] +baz = { version = "0.1.0", optional = true } + +[target.'cfg(target_os = "linux")'.dependencies] +target-dep = { version = "0.1.0", optional = true } + +[lints.cargo] +implicit_features = "warn" +"#, + ) + .file("src/lib.rs", "") + .build(); + + snapbox::cmd::Command::cargo_ui() + .masquerade_as_nightly_cargo(&["cargo-lints"]) + .current_dir(p.root()) + .arg("check") + .arg("-Zcargo-lints") + .assert() + .success() + .stdout_matches(str![""]) + .stderr_matches(file!["stderr.term.svg"]); +} diff --git a/tests/testsuite/lints/implicit_features/edition_2021_warn/stderr.term.svg b/tests/testsuite/lints/implicit_features/stderr.term.svg similarity index 100% rename from tests/testsuite/lints/implicit_features/edition_2021_warn/stderr.term.svg rename to tests/testsuite/lints/implicit_features/stderr.term.svg diff --git a/tests/testsuite/lints/unknown_lints/default/mod.rs b/tests/testsuite/lints/unknown_lints/default/mod.rs deleted file mode 100644 index d17596255ac1..000000000000 --- a/tests/testsuite/lints/unknown_lints/default/mod.rs +++ /dev/null @@ -1,33 +0,0 @@ -use cargo_test_support::prelude::*; -use cargo_test_support::str; -use cargo_test_support::{file, project}; - -#[cargo_test] -fn case() { - let p = project() - .file( - "Cargo.toml", - r#" -[package] -name = "foo" -version = "0.0.1" -edition = "2015" -authors = [] - -[lints.cargo] -this-lint-does-not-exist = "warn" -"#, - ) - .file("src/lib.rs", "") - .build(); - - snapbox::cmd::Command::cargo_ui() - .masquerade_as_nightly_cargo(&["cargo-lints"]) - .current_dir(p.root()) - .arg("check") - .arg("-Zcargo-lints") - .assert() - .success() - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); -} diff --git a/tests/testsuite/lints/unknown_lints/inherited/mod.rs b/tests/testsuite/lints/unknown_lints/inherited/mod.rs deleted file mode 100644 index 4138ab4f5f35..000000000000 --- a/tests/testsuite/lints/unknown_lints/inherited/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -use cargo_test_support::prelude::*; -use cargo_test_support::str; -use cargo_test_support::{file, project}; - -#[cargo_test] -fn case() { - let p = project() - .file( - "Cargo.toml", - r#" -[workspace] -members = ["foo"] - -[workspace.lints.cargo] -this-lint-does-not-exist = "warn" -"#, - ) - .file( - "foo/Cargo.toml", - r#" -[package] -name = "foo" -version = "0.0.1" -edition = "2015" -authors = [] - -[lints] -workspace = true - "#, - ) - .file("foo/src/lib.rs", "") - .build(); - - snapbox::cmd::Command::cargo_ui() - .masquerade_as_nightly_cargo(&["cargo-lints"]) - .current_dir(p.root()) - .arg("check") - .arg("-Zcargo-lints") - .assert() - .success() - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); -} diff --git a/tests/testsuite/lints/unknown_lints/inherited/stderr.term.svg b/tests/testsuite/lints/unknown_lints/inherited/stderr.term.svg deleted file mode 100644 index aef9e175fafc..000000000000 --- a/tests/testsuite/lints/unknown_lints/inherited/stderr.term.svg +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - warning: unknown lint: `this-lint-does-not-exist` - - --> Cargo.toml:6:1 - - | - - 6 | this-lint-does-not-exist = "warn" - - | ^^^^^^^^^^^^^^^^^^^^^^^^ - - | - - note: `cargo::this-lint-does-not-exist` was inherited - - --> foo/Cargo.toml:9:1 - - | - - 9 | workspace = true - - | ---------------- - - | - - = note: `cargo::unknown_lints` is set to `warn` by default - - Checking foo v0.0.1 ([ROOT]/foo/foo) - - Finished [..] - - - - - - diff --git a/tests/testsuite/lints/unknown_lints/mod.rs b/tests/testsuite/lints/unknown_lints/mod.rs index 98324e981159..d17596255ac1 100644 --- a/tests/testsuite/lints/unknown_lints/mod.rs +++ b/tests/testsuite/lints/unknown_lints/mod.rs @@ -1,2 +1,33 @@ -mod default; -mod inherited; +use cargo_test_support::prelude::*; +use cargo_test_support::str; +use cargo_test_support::{file, project}; + +#[cargo_test] +fn case() { + let p = project() + .file( + "Cargo.toml", + r#" +[package] +name = "foo" +version = "0.0.1" +edition = "2015" +authors = [] + +[lints.cargo] +this-lint-does-not-exist = "warn" +"#, + ) + .file("src/lib.rs", "") + .build(); + + snapbox::cmd::Command::cargo_ui() + .masquerade_as_nightly_cargo(&["cargo-lints"]) + .current_dir(p.root()) + .arg("check") + .arg("-Zcargo-lints") + .assert() + .success() + .stdout_matches(str![""]) + .stderr_matches(file!["stderr.term.svg"]); +} diff --git a/tests/testsuite/lints/unknown_lints/default/stderr.term.svg b/tests/testsuite/lints/unknown_lints/stderr.term.svg similarity index 100% rename from tests/testsuite/lints/unknown_lints/default/stderr.term.svg rename to tests/testsuite/lints/unknown_lints/stderr.term.svg diff --git a/tests/testsuite/lints/unused_optional_dependencies/edition_2021/mod.rs b/tests/testsuite/lints/unused_optional_dependencies/edition_2021/mod.rs deleted file mode 100644 index 9a454b19131e..000000000000 --- a/tests/testsuite/lints/unused_optional_dependencies/edition_2021/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -use cargo_test_support::prelude::*; -use cargo_test_support::project; -use cargo_test_support::registry::Package; -use cargo_test_support::{file, str}; - -#[cargo_test] -fn case() { - Package::new("bar", "0.1.0").publish(); - let p = project() - .file( - "Cargo.toml", - r#" -[package] -name = "foo" -version = "0.1.0" -edition = "2021" - -[dependencies] -bar = { version = "0.1.0", optional = true } - -[lints.cargo] -implicit_features = "allow" -"#, - ) - .file("src/lib.rs", "") - .build(); - - snapbox::cmd::Command::cargo_ui() - .masquerade_as_nightly_cargo(&["cargo-lints"]) - .current_dir(p.root()) - .arg("check") - .arg("-Zcargo-lints") - .assert() - .success() - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); -} diff --git a/tests/testsuite/lints/unused_optional_dependencies/edition_2021/stderr.term.svg b/tests/testsuite/lints/unused_optional_dependencies/edition_2021/stderr.term.svg deleted file mode 100644 index ccbdeac1b7b2..000000000000 --- a/tests/testsuite/lints/unused_optional_dependencies/edition_2021/stderr.term.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - Updating `dummy-registry` index - - Locking 2 packages to latest compatible versions - - Checking foo v0.1.0 ([ROOT]/foo) - - Finished [..] - - - - - - diff --git a/tests/testsuite/lints/unused_optional_dependencies/edition_2024/mod.rs b/tests/testsuite/lints/unused_optional_dependencies/edition_2024/mod.rs deleted file mode 100644 index 3ff9504035d6..000000000000 --- a/tests/testsuite/lints/unused_optional_dependencies/edition_2024/mod.rs +++ /dev/null @@ -1,56 +0,0 @@ -use cargo_test_support::compare::assert_match_exact; -use cargo_test_support::prelude::*; -use cargo_test_support::registry::Package; -use cargo_test_support::str; -use cargo_test_support::{file, project}; - -#[cargo_test(nightly, reason = "edition2024 is not stable")] -fn case() { - Package::new("bar", "0.1.0").publish(); - Package::new("baz", "0.1.0").publish(); - Package::new("target-dep", "0.1.0").publish(); - let p = project() - .file( - "Cargo.toml", - r#" -cargo-features = ["edition2024"] -[package] -name = "foo" -version = "0.1.0" -edition = "2024" - -[dependencies] -bar = { version = "0.1.0", optional = true } - -[build-dependencies] -baz = { version = "0.1.0", optional = true } - -[target.'cfg(target_os = "linux")'.dependencies] -target-dep = { version = "0.1.0", optional = true } -"#, - ) - .file("src/lib.rs", "") - .build(); - - snapbox::cmd::Command::cargo_ui() - .masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"]) - .current_dir(p.root()) - .arg("check") - .arg("-Zcargo-lints") - .assert() - .success() - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); - - let expected_lockfile = r#"# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "foo" -version = "0.1.0" -"#; - - let lock = p.read_lockfile(); - assert_match_exact(expected_lockfile, &lock); -} diff --git a/tests/testsuite/lints/unused_optional_dependencies/mod.rs b/tests/testsuite/lints/unused_optional_dependencies/mod.rs index 9a22119becf3..3ff9504035d6 100644 --- a/tests/testsuite/lints/unused_optional_dependencies/mod.rs +++ b/tests/testsuite/lints/unused_optional_dependencies/mod.rs @@ -1,3 +1,56 @@ -mod edition_2021; -mod edition_2024; -mod renamed_deps; +use cargo_test_support::compare::assert_match_exact; +use cargo_test_support::prelude::*; +use cargo_test_support::registry::Package; +use cargo_test_support::str; +use cargo_test_support::{file, project}; + +#[cargo_test(nightly, reason = "edition2024 is not stable")] +fn case() { + Package::new("bar", "0.1.0").publish(); + Package::new("baz", "0.1.0").publish(); + Package::new("target-dep", "0.1.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" +cargo-features = ["edition2024"] +[package] +name = "foo" +version = "0.1.0" +edition = "2024" + +[dependencies] +bar = { version = "0.1.0", optional = true } + +[build-dependencies] +baz = { version = "0.1.0", optional = true } + +[target.'cfg(target_os = "linux")'.dependencies] +target-dep = { version = "0.1.0", optional = true } +"#, + ) + .file("src/lib.rs", "") + .build(); + + snapbox::cmd::Command::cargo_ui() + .masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"]) + .current_dir(p.root()) + .arg("check") + .arg("-Zcargo-lints") + .assert() + .success() + .stdout_matches(str![""]) + .stderr_matches(file!["stderr.term.svg"]); + + let expected_lockfile = r#"# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "foo" +version = "0.1.0" +"#; + + let lock = p.read_lockfile(); + assert_match_exact(expected_lockfile, &lock); +} diff --git a/tests/testsuite/lints/unused_optional_dependencies/renamed_deps/mod.rs b/tests/testsuite/lints/unused_optional_dependencies/renamed_deps/mod.rs deleted file mode 100644 index 08e871df2fc6..000000000000 --- a/tests/testsuite/lints/unused_optional_dependencies/renamed_deps/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -use cargo_test_support::prelude::*; -use cargo_test_support::registry::Package; -use cargo_test_support::str; -use cargo_test_support::{file, project}; - -#[cargo_test(nightly, reason = "edition2024 is not stable")] -fn case() { - Package::new("bar", "0.1.0").publish(); - Package::new("bar", "0.2.0").publish(); - Package::new("target-dep", "0.1.0").publish(); - let p = project() - .file( - "Cargo.toml", - r#" -cargo-features = ["edition2024"] -[package] -name = "foo" -version = "0.1.0" -edition = "2024" - -[dependencies] -bar = { version = "0.1.0", optional = true } - -[build-dependencies] -baz = { version = "0.2.0", package = "bar", optional = true } - -[target.'cfg(target_os = "linux")'.dependencies] -target-dep = { version = "0.1.0", optional = true } -"#, - ) - .file("src/lib.rs", "") - .build(); - - snapbox::cmd::Command::cargo_ui() - .masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"]) - .current_dir(p.root()) - .arg("check") - .arg("-Zcargo-lints") - .assert() - .success() - .stdout_matches(str![""]) - .stderr_matches(file!["stderr.term.svg"]); -} diff --git a/tests/testsuite/lints/unused_optional_dependencies/renamed_deps/stderr.term.svg b/tests/testsuite/lints/unused_optional_dependencies/renamed_deps/stderr.term.svg deleted file mode 100644 index 2f1c99bec30e..000000000000 --- a/tests/testsuite/lints/unused_optional_dependencies/renamed_deps/stderr.term.svg +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - warning: unused optional dependency - - --> Cargo.toml:9:1 - - | - - 9 | bar = { version = "0.1.0", optional = true } - - | --- - - | - - = note: `cargo::unused_optional_dependency` is set to `warn` by default - - = help: remove the dependency or activate it in a feature with `dep:bar` - - warning: unused optional dependency - - --> Cargo.toml:12:1 - - | - - 12 | baz = { version = "0.2.0", package = "bar", optional = true } - - | --- - - | - - = help: remove the dependency or activate it in a feature with `dep:baz` - - warning: unused optional dependency - - --> Cargo.toml:15:1 - - | - - 15 | target-dep = { version = "0.1.0", optional = true } - - | ---------- - - | - - = help: remove the dependency or activate it in a feature with `dep:target-dep` - - Checking foo v0.1.0 ([ROOT]/foo) - - Finished [..] - - - - - - diff --git a/tests/testsuite/lints/unused_optional_dependencies/edition_2024/stderr.term.svg b/tests/testsuite/lints/unused_optional_dependencies/stderr.term.svg similarity index 100% rename from tests/testsuite/lints/unused_optional_dependencies/edition_2024/stderr.term.svg rename to tests/testsuite/lints/unused_optional_dependencies/stderr.term.svg