Skip to content

Commit ebd3352

Browse files
Deny having src/test exisiting in tidy
1 parent b22c152 commit ebd3352

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/tools/tidy/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub mod pal;
6464
pub mod primitive_docs;
6565
pub mod style;
6666
pub mod target_specific_tests;
67+
pub mod tests_placement;
6768
pub mod ui_tests;
6869
pub mod unit_tests;
6970
pub mod unstable_book;

src/tools/tidy/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ fn main() {
7676
check!(extdeps, &root_path);
7777

7878
// Checks over tests.
79+
check!(tests_placement, &root_path);
7980
check!(debug_artifacts, &tests_path);
8081
check!(ui_tests, &tests_path);
8182
check!(mir_opt_tests, &tests_path, bless);

src/tools/tidy/src/tests_placement.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use std::path::Path;
2+
3+
const FORBIDDEN_PATH: &str = "src/test";
4+
const ALLOWED_PATH: &str = "tests";
5+
6+
pub fn check(root_path: impl AsRef<Path>, bad: &mut bool) {
7+
if root_path.as_ref().join(FORBIDDEN_PATH).exists() {
8+
tidy_error!(
9+
bad,
10+
"Tests have been moved, please move them from {} to {}",
11+
root_path.as_ref().join(FORBIDDEN_PATH).display(),
12+
root_path.as_ref().join(ALLOWED_PATH).display()
13+
)
14+
}
15+
}

0 commit comments

Comments
 (0)