diff --git a/tests/testsuite/lints/unused_optional_dependencies/edition_2021/mod.rs b/tests/testsuite/lints/error/mod.rs similarity index 56% rename from tests/testsuite/lints/unused_optional_dependencies/edition_2021/mod.rs rename to tests/testsuite/lints/error/mod.rs index 9a454b19131..c80c38313ca 100644 --- a/tests/testsuite/lints/unused_optional_dependencies/edition_2021/mod.rs +++ b/tests/testsuite/lints/error/mod.rs @@ -1,37 +1,36 @@ use cargo_test_support::prelude::*; -use cargo_test_support::project; -use cargo_test_support::registry::Package; -use cargo_test_support::{file, str}; +use cargo_test_support::str; +use cargo_test_support::{file, project}; #[cargo_test] fn case() { - Package::new("bar", "0.1.0").publish(); let p = project() .file( "Cargo.toml", r#" +cargo-features = ["test-dummy-unstable"] + [package] name = "foo" -version = "0.1.0" -edition = "2021" - -[dependencies] -bar = { version = "0.1.0", optional = true } +version = "0.0.1" +edition = "2015" +authors = [] +im-a-teapot = true [lints.cargo] -implicit_features = "allow" -"#, +im_a_teapot = "deny" + "#, ) .file("src/lib.rs", "") .build(); snapbox::cmd::Command::cargo_ui() - .masquerade_as_nightly_cargo(&["cargo-lints"]) + .masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"]) .current_dir(p.root()) .arg("check") .arg("-Zcargo-lints") .assert() - .success() + .code(101) .stdout_matches(str![""]) .stderr_matches(file!["stderr.term.svg"]); } diff --git a/tests/testsuite/lints/error/stderr.term.svg b/tests/testsuite/lints/error/stderr.term.svg new file mode 100644 index 00000000000..1dba018ceac --- /dev/null +++ b/tests/testsuite/lints/error/stderr.term.svg @@ -0,0 +1,41 @@ + + + + + + + error: `im_a_teapot` is specified + + --> Cargo.toml:9:1 + + | + + 9 | im-a-teapot = true + + | ^^^^^^^^^^^^^^^^^^ + + | + + = note: `cargo::im_a_teapot` is set to `deny` in `[lints]` + + + + + + diff --git a/tests/testsuite/lints/implicit_features.rs b/tests/testsuite/lints/implicit_features.rs new file mode 100644 index 00000000000..56d70243b96 --- /dev/null +++ b/tests/testsuite/lints/implicit_features.rs @@ -0,0 +1,137 @@ +use cargo_test_support::project; +use cargo_test_support::registry::Package; + +#[cargo_test] +fn default() { + 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] +fn warn() { + 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(); + + p.cargo("check -Zcargo-lints") + .masquerade_as_nightly_cargo(&["cargo-lints"]) + .with_stderr( + "\ +warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition + --> Cargo.toml:8:1 + | +8 | bar = { version = \"0.1.0\", optional = true } + | --- + | + = note: `cargo::implicit_features` is set to `warn` in `[lints]` +warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition + --> Cargo.toml:11:1 + | +11 | baz = { version = \"0.1.0\", optional = true } + | --- + | +warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition + --> Cargo.toml:14:1 + | +14 | target-dep = { version = \"0.1.0\", optional = true } + | ---------- + | +[UPDATING] [..] +[LOCKING] 4 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(); +} 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 7ab75c6c7b8..00000000000 --- 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 f0726266833..00000000000 --- 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 45f29b029fa..00000000000 --- 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_2021_warn/stderr.term.svg b/tests/testsuite/lints/implicit_features/edition_2021_warn/stderr.term.svg deleted file mode 100644 index 11affcc2ee0..00000000000 --- a/tests/testsuite/lints/implicit_features/edition_2021_warn/stderr.term.svg +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition - - --> Cargo.toml:8:1 - - | - - 8 | bar = { version = "0.1.0", optional = true } - - | --- - - | - - = note: `cargo::implicit_features` is set to `warn` in `[lints]` - - warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition - - --> Cargo.toml:11:1 - - | - - 11 | baz = { version = "0.1.0", optional = true } - - | --- - - | - - warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition - - --> Cargo.toml:14:1 - - | - - 14 | target-dep = { version = "0.1.0", optional = true } - - | ---------- - - | - - Updating `dummy-registry` index - - Locking 4 packages to latest compatible versions - - Checking foo v0.1.0 ([ROOT]/foo) - - Finished [..] - - - - - - 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 ca682aa8a5a..00000000000 --- 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 6c0f3b67a55..00000000000 --- 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 deleted file mode 100644 index 3865b14a2ee..00000000000 --- a/tests/testsuite/lints/implicit_features/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod edition_2021; -mod edition_2021_warn; -mod edition_2024; diff --git a/tests/testsuite/lints/unknown_lints/inherited/mod.rs b/tests/testsuite/lints/inherited/mod.rs similarity index 91% rename from tests/testsuite/lints/unknown_lints/inherited/mod.rs rename to tests/testsuite/lints/inherited/mod.rs index 4138ab4f5f3..5085bea3748 100644 --- a/tests/testsuite/lints/unknown_lints/inherited/mod.rs +++ b/tests/testsuite/lints/inherited/mod.rs @@ -12,7 +12,7 @@ fn case() { members = ["foo"] [workspace.lints.cargo] -this-lint-does-not-exist = "warn" +im_a_teapot = { level = "warn", priority = 10 } "#, ) .file( @@ -26,7 +26,7 @@ authors = [] [lints] workspace = true - "#, +"#, ) .file("foo/src/lib.rs", "") .build(); @@ -37,7 +37,7 @@ workspace = true .arg("check") .arg("-Zcargo-lints") .assert() - .success() + .code(101) .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/inherited/stderr.term.svg similarity index 65% rename from tests/testsuite/lints/unknown_lints/inherited/stderr.term.svg rename to tests/testsuite/lints/inherited/stderr.term.svg index aef9e175faf..a37bba4c1c7 100644 --- a/tests/testsuite/lints/unknown_lints/inherited/stderr.term.svg +++ b/tests/testsuite/lints/inherited/stderr.term.svg @@ -1,12 +1,12 @@ - +