From 3c9df90fb39211995f720204580028abb561e479 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 24 Apr 2024 13:49:43 -0600 Subject: [PATCH] test(cargo-lints): Add a test for workspace inheritance --- tests/testsuite/lints_table.rs | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/testsuite/lints_table.rs b/tests/testsuite/lints_table.rs index 451a3dc59c9f..ad55849e4f23 100644 --- a/tests/testsuite/lints_table.rs +++ b/tests/testsuite/lints_table.rs @@ -939,3 +939,46 @@ error: `im_a_teapot` is specified ) .run(); } + +#[cargo_test] +fn workspace_cargo_lints() { + let p = project() + .file( + "Cargo.toml", + r#" +cargo-features = ["test-dummy-unstable"] + +[workspace.lints.cargo] +im-a-teapot = { level = "warn", priority = 10 } +test-dummy-unstable = { level = "forbid", priority = -1 } + +[package] +name = "foo" +version = "0.0.1" +edition = "2015" +authors = [] +im-a-teapot = true + +[lints] +workspace = true + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check -Zcargo-lints") + .masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"]) + .with_status(101) + .with_stderr( + "\ +error: `im_a_teapot` is specified + --> Cargo.toml:13:1 + | +13 | im-a-teapot = true + | ^^^^^^^^^^^^^^^^^^ + | + = note: `cargo::im_a_teapot` is set to `forbid` +", + ) + .run(); +}