Skip to content

Commit b79fd59

Browse files
committed
test: Add UI tests showing parts of diagnostic system
1 parent 6f81cff commit b79fd59

File tree

7 files changed

+262
-0
lines changed

7 files changed

+262
-0
lines changed

tests/testsuite/lints/error/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use cargo_test_support::prelude::*;
2+
use cargo_test_support::str;
3+
use cargo_test_support::{file, project};
4+
5+
#[cargo_test]
6+
fn case() {
7+
let p = project()
8+
.file(
9+
"Cargo.toml",
10+
r#"
11+
cargo-features = ["test-dummy-unstable"]
12+
13+
[package]
14+
name = "foo"
15+
version = "0.0.1"
16+
edition = "2015"
17+
authors = []
18+
im-a-teapot = true
19+
20+
[lints.cargo]
21+
im_a_teapot = "deny"
22+
"#,
23+
)
24+
.file("src/lib.rs", "")
25+
.build();
26+
27+
snapbox::cmd::Command::cargo_ui()
28+
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
29+
.current_dir(p.root())
30+
.arg("check")
31+
.arg("-Zcargo-lints")
32+
.assert()
33+
.code(101)
34+
.stdout_matches(str![""])
35+
.stderr_matches(file!["stderr.term.svg"]);
36+
}
Lines changed: 41 additions & 0 deletions
Loading
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
use cargo_test_support::prelude::*;
2+
use cargo_test_support::str;
3+
use cargo_test_support::{file, project};
4+
5+
#[cargo_test]
6+
fn case() {
7+
let p = project()
8+
.file(
9+
"Cargo.toml",
10+
r#"
11+
[workspace]
12+
members = ["foo"]
13+
14+
[workspace.lints.cargo]
15+
im_a_teapot = { level = "warn", priority = 10 }
16+
"#,
17+
)
18+
.file(
19+
"foo/Cargo.toml",
20+
r#"
21+
[package]
22+
name = "foo"
23+
version = "0.0.1"
24+
edition = "2015"
25+
authors = []
26+
27+
[lints]
28+
workspace = true
29+
"#,
30+
)
31+
.file("foo/src/lib.rs", "")
32+
.build();
33+
34+
snapbox::cmd::Command::cargo_ui()
35+
.masquerade_as_nightly_cargo(&["cargo-lints"])
36+
.current_dir(p.root())
37+
.arg("check")
38+
.arg("-Zcargo-lints")
39+
.assert()
40+
.code(101)
41+
.stdout_matches(str![""])
42+
.stderr_matches(file!["stderr.term.svg"]);
43+
}
Lines changed: 57 additions & 0 deletions
Loading

tests/testsuite/lints/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
use cargo_test_support::project;
22
use cargo_test_support::registry::Package;
33

4+
mod error;
45
mod implicit_features;
6+
mod inherited;
57
mod unknown_lints;
68
mod unused_optional_dependencies;
9+
mod warning;
710

811
#[cargo_test]
912
fn dashes_dont_get_rewritten() {

tests/testsuite/lints/warning/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use cargo_test_support::prelude::*;
2+
use cargo_test_support::str;
3+
use cargo_test_support::{file, project};
4+
5+
#[cargo_test]
6+
fn case() {
7+
let p = project()
8+
.file(
9+
"Cargo.toml",
10+
r#"
11+
cargo-features = ["test-dummy-unstable"]
12+
13+
[package]
14+
name = "foo"
15+
version = "0.0.1"
16+
edition = "2015"
17+
authors = []
18+
im-a-teapot = true
19+
20+
[lints.cargo]
21+
im_a_teapot = "warn"
22+
"#,
23+
)
24+
.file("src/lib.rs", "")
25+
.build();
26+
27+
snapbox::cmd::Command::cargo_ui()
28+
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
29+
.current_dir(p.root())
30+
.arg("check")
31+
.arg("-Zcargo-lints")
32+
.assert()
33+
.success()
34+
.stdout_matches(str![""])
35+
.stderr_matches(file!["stderr.term.svg"]);
36+
}
Lines changed: 46 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)