add unit test

This commit is contained in:
Jane Lusby 2019-08-08 16:39:00 -07:00
parent 79480cc21c
commit 42a00c1d39

View File

@ -38,3 +38,37 @@ fn clippy_force_rebuild() {
.with_stderr_contains("[..]assert!(true)[..]")
.run();
}
#[cargo_test]
fn clippy_passes_args() {
if !clippy_is_available() {
return;
}
// This is just a random clippy lint (assertions_on_constants) that
// hopefully won't change much in the future.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
"#,
)
.file("src/lib.rs", "pub fn f() { assert!(true); }")
.build();
p.cargo("clippy-preview -Zunstable-options -v -- -Aclippy::assertions_on_constants")
.masquerade_as_nightly_cargo()
.with_stderr_does_not_contain("[..]assert!(true)[..]")
.run();
// Make sure it runs again.
p.cargo("clippy-preview -Zunstable-options -v")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[..]assert!(true)[..]")
.run();
}