Add ui test for include_file_outside_project lint

This commit is contained in:
Guillaume Gomez 2024-11-20 16:17:04 +01:00
parent a6ab226516
commit d6dc48d888
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,12 @@
//@ normalize-stderr-test: "located at `.+/.crates.toml`" -> "located at `$$DIR/.crates.toml`"
//@ normalize-stderr-test: "folder \(`.+`" -> "folder (`$$CLIPPY_DIR`"
#![deny(clippy::include_file_outside_project)]
// Should not lint.
include!("./auxiliary/external_consts.rs");
fn main() {
let x = include_str!(concat!(env!("CARGO_HOME"), "/.crates.toml"));
//~^ include_file_outside_project
}

View file

@ -0,0 +1,15 @@
error: attempted to include a file outside of the project
--> tests/ui/include_file_outside_project.rs:10:13
|
LL | let x = include_str!(concat!(env!("CARGO_HOME"), "/.crates.toml"));
| ^
|
= note: file is located at `$DIR/.crates.toml` which is outside of project folder (`$CLIPPY_DIR`)
note: the lint level is defined here
--> tests/ui/include_file_outside_project.rs:4:9
|
LL | #![deny(clippy::include_file_outside_project)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error