Skip to content

Commit

Permalink
Deny having src/test exisiting in tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
albertlarsan68 committed Jan 11, 2023
1 parent b22c152 commit ebd3352
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tools/tidy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub mod pal;
pub mod primitive_docs;
pub mod style;
pub mod target_specific_tests;
pub mod tests_placement;
pub mod ui_tests;
pub mod unit_tests;
pub mod unstable_book;
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fn main() {
check!(extdeps, &root_path);

// Checks over tests.
check!(tests_placement, &root_path);
check!(debug_artifacts, &tests_path);
check!(ui_tests, &tests_path);
check!(mir_opt_tests, &tests_path, bless);
Expand Down
15 changes: 15 additions & 0 deletions src/tools/tidy/src/tests_placement.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::path::Path;

const FORBIDDEN_PATH: &str = "src/test";
const ALLOWED_PATH: &str = "tests";

pub fn check(root_path: impl AsRef<Path>, bad: &mut bool) {
if root_path.as_ref().join(FORBIDDEN_PATH).exists() {
tidy_error!(
bad,
"Tests have been moved, please move them from {} to {}",
root_path.as_ref().join(FORBIDDEN_PATH).display(),
root_path.as_ref().join(ALLOWED_PATH).display()
)
}
}

0 comments on commit ebd3352

Please sign in to comment.