Skip to content

Commit

Permalink
Add ui test for include_file_outside_project lint
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 20, 2024
1 parent a6ab226 commit d6dc48d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/ui/include_file_outside_project.rs
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 15 additions & 0 deletions tests/ui/include_file_outside_project.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d6dc48d

Please sign in to comment.