Skip to content

Commit

Permalink
test: Add UI tests showing parts of diagnostic system
Browse files Browse the repository at this point in the history
  • Loading branch information
Muscraft committed May 9, 2024
1 parent 6f81cff commit b79fd59
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/testsuite/lints/error/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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#"
cargo-features = ["test-dummy-unstable"]
[package]
name = "foo"
version = "0.0.1"
edition = "2015"
authors = []
im-a-teapot = true
[lints.cargo]
im_a_teapot = "deny"
"#,
)
.file("src/lib.rs", "")
.build();

snapbox::cmd::Command::cargo_ui()
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
.current_dir(p.root())
.arg("check")
.arg("-Zcargo-lints")
.assert()
.code(101)
.stdout_matches(str![""])
.stderr_matches(file!["stderr.term.svg"]);
}
41 changes: 41 additions & 0 deletions tests/testsuite/lints/error/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions tests/testsuite/lints/inherited/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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]
im_a_teapot = { level = "warn", priority = 10 }
"#,
)
.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()
.code(101)
.stdout_matches(str![""])
.stderr_matches(file!["stderr.term.svg"]);
}
57 changes: 57 additions & 0 deletions tests/testsuite/lints/inherited/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/testsuite/lints/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
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() {
Expand Down
36 changes: 36 additions & 0 deletions tests/testsuite/lints/warning/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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#"
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();

snapbox::cmd::Command::cargo_ui()
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
.current_dir(p.root())
.arg("check")
.arg("-Zcargo-lints")
.assert()
.success()
.stdout_matches(str![""])
.stderr_matches(file!["stderr.term.svg"]);
}
46 changes: 46 additions & 0 deletions tests/testsuite/lints/warning/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b79fd59

Please sign in to comment.