Auto merge of #13880 - Muscraft:refactor-cargo-lint-tests, r=<try>
Refactor cargo lint tests In #13621, it was brought up that [the lints tests are nested more deeply than other UI tests](https://github.com/rust-lang/cargo/pull/13621#discussion_r1538065181). This got me wondering if there was a better way to structure all the lint tests. What I came up with was: - Lints should not have UI tests, only parts of the diagnostic system, i.e., how warnings, errors, notes, etc., look - This is because UI tests should focus on parts of the system that make up each lint's output - We can always add UI tests for each lint if desired - All tests related to the linting system should live in `tests/testsuite/lints/` - Tests related to `[lints.cargo]` should stay in `lints_table.rs` as it is for the whole lints table - Each lint will get a file in `lints/` for all of its tests - This makes `lints/mod.rs` smaller and targeted only at tests for the linting system itself - It makes it much easier to know where to place a test
|
@ -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"]);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<svg width="740px" height="164px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-bright-blue { fill: #5555FF }
|
||||
.fg-bright-green { fill: #55FF55 }
|
||||
.fg-bright-red { fill: #FF5555 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-bright-red bold">error</tspan><tspan>: </tspan><tspan class="bold">`im_a_teapot` is specified</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:9:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-bright-blue bold">9 |</tspan><tspan> im-a-teapot = true</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-bright-red bold"> ^^^^^^^^^^^^^^^^^^</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-green bold">note</tspan><tspan>: `cargo::im_a_teapot` is set to `deny` in `[lints]`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="154px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
|
@ -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();
|
||||
}
|
|
@ -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"]);
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<svg width="740px" height="110px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan class="fg-green bold"> Locking</tspan><tspan> 2 packages to latest compatible versions</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.1.0 ([ROOT]/foo)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-green bold"> Finished</tspan><tspan>[..]</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
Before Width: | Height: | Size: 1.1 KiB |
|
@ -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"]);
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
<svg width="944px" height="452px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-bright-blue { fill: #5555FF }
|
||||
.fg-bright-green { fill: #55FF55 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-yellow { fill: #AA5500 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:8:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-bright-blue bold">8 |</tspan><tspan> bar = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ---</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-green bold">note</tspan><tspan>: `cargo::implicit_features` is set to `warn` in `[lints]`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="154px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="172px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:11:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="190px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="208px"><tspan class="fg-bright-blue bold">11 |</tspan><tspan> baz = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="226px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ---</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="244px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="262px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="280px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:14:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="298px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="316px"><tspan class="fg-bright-blue bold">14 |</tspan><tspan> target-dep = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="334px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ----------</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="352px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="370px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="388px"><tspan class="fg-green bold"> Locking</tspan><tspan> 4 packages to latest compatible versions</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="406px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.1.0 ([ROOT]/foo)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="424px"><tspan class="fg-green bold"> Finished</tspan><tspan> [..]</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="442px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
Before Width: | Height: | Size: 3.8 KiB |
|
@ -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"]);
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<svg width="740px" height="110px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan class="fg-green bold"> Locking</tspan><tspan> 2 packages to latest Rust [..] compatible versions</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.1.0 ([ROOT]/foo)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-green bold"> Finished</tspan><tspan> [..]</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
Before Width: | Height: | Size: 1.1 KiB |
|
@ -1,3 +0,0 @@
|
|||
mod edition_2021;
|
||||
mod edition_2021_warn;
|
||||
mod edition_2024;
|
|
@ -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"]);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
<svg width="740px" height="308px" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg width="818px" height="290px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-bright-blue { fill: #5555FF }
|
||||
.fg-bright-cyan { fill: #55FFFF }
|
||||
.fg-bright-green { fill: #55FF55 }
|
||||
.fg-bright-red { fill: #FF5555 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-yellow { fill: #AA5500 }
|
||||
.fg-red { fill: #AA0000 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
|
@ -22,19 +22,19 @@
|
|||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">unknown lint: `this-lint-does-not-exist`</tspan>
|
||||
<tspan x="10px" y="28px"><tspan class="fg-bright-red bold">error</tspan><tspan>: </tspan><tspan class="bold">use of unstable lint `im_a_teapot`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:6:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-bright-blue bold">6 |</tspan><tspan> this-lint-does-not-exist = "warn"</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-bright-blue bold">6 |</tspan><tspan> im_a_teapot = { level = "warn", priority = 10 }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-bright-red bold"> ^^^^^^^^^^^^^^^^^^^^^^^^</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-bright-red bold"> ^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-bright-red bold">this is behind `test-dummy-unstable`, which is not enabled</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px"><tspan class="fg-bright-green bold">note</tspan><tspan>: </tspan><tspan class="bold">`cargo::this-lint-does-not-exist` was inherited</tspan>
|
||||
<tspan x="10px" y="136px"><tspan class="fg-bright-green bold">note</tspan><tspan>: </tspan><tspan class="bold">`cargo::im_a_teapot` was inherited</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="154px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> foo/Cargo.toml:9:1</tspan>
|
||||
</tspan>
|
||||
|
@ -46,13 +46,11 @@
|
|||
</tspan>
|
||||
<tspan x="10px" y="226px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="244px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-green bold">note</tspan><tspan>: `cargo::unknown_lints` is set to `warn` by default</tspan>
|
||||
<tspan x="10px" y="244px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-cyan bold">help</tspan><tspan>: consider adding `cargo-features = ["test-dummy-unstable"]` to the top of the manifest</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="262px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.0.1 ([ROOT]/foo/foo)</tspan>
|
||||
<tspan x="10px" y="262px"><tspan class="fg-red bold">error</tspan><tspan class="bold">:</tspan><tspan> encountered 1 errors(s) while verifying lints</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="280px"><tspan class="fg-green bold"> Finished</tspan><tspan> [..]</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="298px">
|
||||
<tspan x="10px" y="280px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
@ -1,3 +1,333 @@
|
|||
use cargo_test_support::project;
|
||||
use cargo_test_support::registry::Package;
|
||||
|
||||
mod error;
|
||||
mod implicit_features;
|
||||
mod inherited;
|
||||
mod unknown_lints;
|
||||
mod unused_optional_dependencies;
|
||||
mod warning;
|
||||
|
||||
#[cargo_test]
|
||||
fn dashes_dont_get_rewritten() {
|
||||
let foo = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
cargo-features = ["test-dummy-unstable"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
im-a-teapot = true
|
||||
|
||||
[lints.cargo]
|
||||
im-a-teapot = "warn"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
foo.cargo("check -Zcargo-lints")
|
||||
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
|
||||
.with_stderr(
|
||||
"\
|
||||
warning: unknown lint: `im-a-teapot`
|
||||
--> Cargo.toml:12:1
|
||||
|
|
||||
12 | im-a-teapot = \"warn\"
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: `cargo::unknown_lints` is set to `warn` by default
|
||||
= help: there is a lint with a similar name: `im_a_teapot`
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn forbid_not_overridden() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
cargo-features = ["test-dummy-unstable"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
im-a-teapot = true
|
||||
|
||||
[lints.cargo]
|
||||
im_a_teapot = { level = "warn", priority = 10 }
|
||||
test_dummy_unstable = { level = "forbid", priority = -1 }
|
||||
"#,
|
||||
)
|
||||
.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:9:1
|
||||
|
|
||||
9 | im-a-teapot = true
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `cargo::im_a_teapot` is set to `forbid` in `[lints]`
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn workspace_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` in `[lints]`
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn dont_always_inherit_workspace_lints() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[workspace]
|
||||
members = ["foo"]
|
||||
|
||||
[workspace.lints.cargo]
|
||||
im_a_teapot = "warn"
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"foo/Cargo.toml",
|
||||
r#"
|
||||
cargo-features = ["test-dummy-unstable"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
im-a-teapot = true
|
||||
"#,
|
||||
)
|
||||
.file("foo/src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("check -Zcargo-lints")
|
||||
.masquerade_as_nightly_cargo(&["cargo-lints"])
|
||||
.with_stderr(
|
||||
"\
|
||||
[CHECKING] foo v0.0.1 ([CWD]/foo)
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn cap_lints() {
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
Package::new("bar", "0.1.0")
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1.0", optional = true }
|
||||
|
||||
[lints.cargo]
|
||||
implicit_features = "warn"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.publish();
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bar = "0.1.0"
|
||||
|
||||
[lints.cargo]
|
||||
implicit_features = "warn"
|
||||
"#,
|
||||
)
|
||||
.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
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] bar v0.1.0 ([..])
|
||||
[CHECKING] bar v0.1.0
|
||||
[CHECKING] foo v0.1.0 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn check_feature_gated() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
|
||||
[lints.cargo]
|
||||
im_a_teapot = "warn"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("check -Zcargo-lints")
|
||||
.masquerade_as_nightly_cargo(&["cargo-lints"])
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: use of unstable lint `im_a_teapot`
|
||||
--> Cargo.toml:9:1
|
||||
|
|
||||
9 | im_a_teapot = \"warn\"
|
||||
| ^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
|
||||
|
|
||||
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
|
||||
error: encountered 1 errors(s) while verifying lints
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn check_feature_gated_workspace() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[workspace]
|
||||
members = ["foo"]
|
||||
|
||||
[workspace.lints.cargo]
|
||||
im_a_teapot = { level = "warn", priority = 10 }
|
||||
test_dummy_unstable = { level = "forbid", priority = -1 }
|
||||
"#,
|
||||
)
|
||||
.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_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: use of unstable lint `im_a_teapot`
|
||||
--> Cargo.toml:6:1
|
||||
|
|
||||
6 | im_a_teapot = { level = \"warn\", priority = 10 }
|
||||
| ^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
|
||||
|
|
||||
note: `cargo::im_a_teapot` was inherited
|
||||
--> foo/Cargo.toml:9:1
|
||||
|
|
||||
9 | workspace = true
|
||||
| ----------------
|
||||
|
|
||||
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
|
||||
error: use of unstable lint `test_dummy_unstable`
|
||||
--> Cargo.toml:7:1
|
||||
|
|
||||
7 | test_dummy_unstable = { level = \"forbid\", priority = -1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
|
||||
|
|
||||
note: `cargo::test_dummy_unstable` was inherited
|
||||
--> foo/Cargo.toml:9:1
|
||||
|
|
||||
9 | workspace = true
|
||||
| ----------------
|
||||
|
|
||||
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
|
||||
error: encountered 2 errors(s) while verifying lints
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
use cargo_test_support::project;
|
||||
|
||||
#[cargo_test]
|
||||
fn default() {
|
||||
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();
|
||||
|
||||
p.cargo("check -Zcargo-lints")
|
||||
.masquerade_as_nightly_cargo(&["cargo-lints"])
|
||||
.with_stderr(
|
||||
"\
|
||||
warning: unknown lint: `this-lint-does-not-exist`
|
||||
--> Cargo.toml:9:1
|
||||
|
|
||||
9 | this-lint-does-not-exist = \"warn\"
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `cargo::unknown_lints` is set to `warn` by default
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn 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();
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
mod default;
|
||||
mod inherited;
|
|
@ -0,0 +1,159 @@
|
|||
use cargo_test_support::project;
|
||||
use cargo_test_support::registry::Package;
|
||||
|
||||
#[cargo_test(nightly, reason = "edition2024 is not stable")]
|
||||
fn default() {
|
||||
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();
|
||||
|
||||
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.1.0\", 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();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn 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 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();
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<svg width="740px" height="110px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan class="fg-green bold"> Locking</tspan><tspan> 2 packages to latest compatible versions</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.1.0 ([ROOT]/foo)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-green bold"> Finished</tspan><tspan> [..]</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
Before Width: | Height: | Size: 1.1 KiB |
|
@ -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);
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<svg width="740px" height="470px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-bright-blue { fill: #5555FF }
|
||||
.fg-bright-cyan { fill: #55FFFF }
|
||||
.fg-bright-green { fill: #55FF55 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-yellow { fill: #AA5500 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">unused optional dependency</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:9:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-bright-blue bold">9 |</tspan><tspan> bar = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ---</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-green bold">note</tspan><tspan>: `cargo::unused_optional_dependency` is set to `warn` by default</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="154px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-cyan bold">help</tspan><tspan>: remove the dependency or activate it in a feature with `dep:bar`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="172px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">unused optional dependency</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="190px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:12:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="208px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="226px"><tspan class="fg-bright-blue bold">12 |</tspan><tspan> baz = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="244px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ---</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="262px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="280px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-cyan bold">help</tspan><tspan>: remove the dependency or activate it in a feature with `dep:baz`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="298px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">unused optional dependency</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="316px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:15:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="334px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="352px"><tspan class="fg-bright-blue bold">15 |</tspan><tspan> target-dep = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="370px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ----------</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="388px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="406px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-cyan bold">help</tspan><tspan>: remove the dependency or activate it in a feature with `dep:target-dep`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="424px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.1.0 ([ROOT]/foo)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="442px"><tspan class="fg-green bold"> Finished</tspan><tspan> [..]</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="460px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
Before Width: | Height: | Size: 4.1 KiB |
|
@ -1,3 +0,0 @@
|
|||
mod edition_2021;
|
||||
mod edition_2024;
|
||||
mod renamed_deps;
|
|
@ -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"]);
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<svg width="740px" height="470px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-bright-blue { fill: #5555FF }
|
||||
.fg-bright-cyan { fill: #55FFFF }
|
||||
.fg-bright-green { fill: #55FF55 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-yellow { fill: #AA5500 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">unused optional dependency</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:9:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-bright-blue bold">9 |</tspan><tspan> bar = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ---</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-green bold">note</tspan><tspan>: `cargo::unused_optional_dependency` is set to `warn` by default</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="154px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-cyan bold">help</tspan><tspan>: remove the dependency or activate it in a feature with `dep:bar`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="172px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">unused optional dependency</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="190px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:12:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="208px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="226px"><tspan class="fg-bright-blue bold">12 |</tspan><tspan> baz = { version = "0.2.0", package = "bar", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="244px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ---</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="262px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="280px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-cyan bold">help</tspan><tspan>: remove the dependency or activate it in a feature with `dep:baz`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="298px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">unused optional dependency</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="316px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:15:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="334px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="352px"><tspan class="fg-bright-blue bold">15 |</tspan><tspan> target-dep = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="370px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ----------</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="388px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="406px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-cyan bold">help</tspan><tspan>: remove the dependency or activate it in a feature with `dep:target-dep`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="424px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.1.0 ([ROOT]/foo)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="442px"><tspan class="fg-green bold"> Finished</tspan><tspan> [..]</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="460px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
Before Width: | Height: | Size: 4.1 KiB |
|
@ -8,21 +8,24 @@ fn case() {
|
|||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
cargo-features = ["test-dummy-unstable"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
im-a-teapot = true
|
||||
|
||||
[lints.cargo]
|
||||
this-lint-does-not-exist = "warn"
|
||||
"#,
|
||||
im_a_teapot = "warn"
|
||||
"#,
|
||||
)
|
||||
.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")
|
|
@ -4,7 +4,6 @@
|
|||
.bg { background: #000000 }
|
||||
.fg-bright-blue { fill: #5555FF }
|
||||
.fg-bright-green { fill: #55FF55 }
|
||||
.fg-bright-red { fill: #FF5555 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-yellow { fill: #AA5500 }
|
||||
.container {
|
||||
|
@ -22,19 +21,19 @@
|
|||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">unknown lint: `this-lint-does-not-exist`</tspan>
|
||||
<tspan x="10px" y="28px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">`im_a_teapot` is specified</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:9:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-bright-blue bold">9 |</tspan><tspan> this-lint-does-not-exist = "warn"</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-bright-blue bold">9 |</tspan><tspan> im-a-teapot = true</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-bright-red bold"> ^^^^^^^^^^^^^^^^^^^^^^^^</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ------------------</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-green bold">note</tspan><tspan>: `cargo::unknown_lints` is set to `warn` by default</tspan>
|
||||
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="fg-bright-blue bold">=</tspan><tspan> </tspan><tspan class="fg-bright-green bold">note</tspan><tspan>: `cargo::im_a_teapot` is set to `warn` in `[lints]`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="154px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.0.1 ([ROOT]/foo)</tspan>
|
||||
</tspan>
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
@ -856,327 +856,3 @@ warning: `im_a_teapot` is specified
|
|||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn cargo_lints_dashes_dont_get_rewritten() {
|
||||
let foo = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
cargo-features = ["test-dummy-unstable"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
im-a-teapot = true
|
||||
|
||||
[lints.cargo]
|
||||
im-a-teapot = "warn"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
foo.cargo("check -Zcargo-lints")
|
||||
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
|
||||
.with_stderr(
|
||||
"\
|
||||
warning: unknown lint: `im-a-teapot`
|
||||
--> Cargo.toml:12:1
|
||||
|
|
||||
12 | im-a-teapot = \"warn\"
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: `cargo::unknown_lints` is set to `warn` by default
|
||||
= help: there is a lint with a similar name: `im_a_teapot`
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn forbid_not_overridden() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
cargo-features = ["test-dummy-unstable"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
im-a-teapot = true
|
||||
|
||||
[lints.cargo]
|
||||
im_a_teapot = { level = "warn", priority = 10 }
|
||||
test_dummy_unstable = { level = "forbid", priority = -1 }
|
||||
"#,
|
||||
)
|
||||
.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:9:1
|
||||
|
|
||||
9 | im-a-teapot = true
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `cargo::im_a_teapot` is set to `forbid` in `[lints]`
|
||||
",
|
||||
)
|
||||
.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` in `[lints]`
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn dont_always_inherit_workspace_lints() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[workspace]
|
||||
members = ["foo"]
|
||||
|
||||
[workspace.lints.cargo]
|
||||
im_a_teapot = "warn"
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"foo/Cargo.toml",
|
||||
r#"
|
||||
cargo-features = ["test-dummy-unstable"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
im-a-teapot = true
|
||||
"#,
|
||||
)
|
||||
.file("foo/src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("check -Zcargo-lints")
|
||||
.masquerade_as_nightly_cargo(&["cargo-lints"])
|
||||
.with_stderr(
|
||||
"\
|
||||
[CHECKING] foo v0.0.1 ([CWD]/foo)
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn cargo_lints_cap_lints() {
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
Package::new("bar", "0.1.0")
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1.0", optional = true }
|
||||
|
||||
[lints.cargo]
|
||||
implicit_features = "warn"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.publish();
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bar = "0.1.0"
|
||||
|
||||
[lints.cargo]
|
||||
implicit_features = "warn"
|
||||
"#,
|
||||
)
|
||||
.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
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] bar v0.1.0 ([..])
|
||||
[CHECKING] bar v0.1.0
|
||||
[CHECKING] foo v0.1.0 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn check_feature_gated() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
|
||||
[lints.cargo]
|
||||
im_a_teapot = "warn"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("check -Zcargo-lints")
|
||||
.masquerade_as_nightly_cargo(&["cargo-lints"])
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: use of unstable lint `im_a_teapot`
|
||||
--> Cargo.toml:9:1
|
||||
|
|
||||
9 | im_a_teapot = \"warn\"
|
||||
| ^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
|
||||
|
|
||||
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
|
||||
error: encountered 1 errors(s) while verifying lints
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn check_feature_gated_workspace() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[workspace]
|
||||
members = ["foo"]
|
||||
|
||||
[workspace.lints.cargo]
|
||||
im_a_teapot = { level = "warn", priority = 10 }
|
||||
test_dummy_unstable = { level = "forbid", priority = -1 }
|
||||
"#,
|
||||
)
|
||||
.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_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: use of unstable lint `im_a_teapot`
|
||||
--> Cargo.toml:6:1
|
||||
|
|
||||
6 | im_a_teapot = { level = \"warn\", priority = 10 }
|
||||
| ^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
|
||||
|
|
||||
note: `cargo::im_a_teapot` was inherited
|
||||
--> foo/Cargo.toml:9:1
|
||||
|
|
||||
9 | workspace = true
|
||||
| ----------------
|
||||
|
|
||||
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
|
||||
error: use of unstable lint `test_dummy_unstable`
|
||||
--> Cargo.toml:7:1
|
||||
|
|
||||
7 | test_dummy_unstable = { level = \"forbid\", priority = -1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
|
||||
|
|
||||
note: `cargo::test_dummy_unstable` was inherited
|
||||
--> foo/Cargo.toml:9:1
|
||||
|
|
||||
9 | workspace = true
|
||||
| ----------------
|
||||
|
|
||||
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
|
||||
error: encountered 2 errors(s) while verifying lints
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
|