mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Don't walk the tests/
directories in checks that always skip it
`WalkBuilder` handles top-level paths differently than `fn walk` used to: it doesn't run the `skip` function to determine if it should be skipped, instead assuming the top-level function is always included. This is a reasonable assumption; adapt our code so it doesn't make pointless calls to `walk`.
This commit is contained in:
parent
97cffd5295
commit
98334f6a2d
@ -9,27 +9,20 @@ fn is_edition_2021(mut line: &str) -> bool {
|
||||
}
|
||||
|
||||
pub fn check(path: &Path, bad: &mut bool) {
|
||||
walk(
|
||||
path,
|
||||
|path| {
|
||||
filter_dirs(path)
|
||||
|| (path.ends_with("tests") && path.join("COMPILER_TESTS.md").exists())
|
||||
},
|
||||
&mut |entry, contents| {
|
||||
let file = entry.path();
|
||||
let filename = file.file_name().unwrap();
|
||||
if filename != "Cargo.toml" {
|
||||
return;
|
||||
}
|
||||
walk(path, |path| filter_dirs(path), &mut |entry, contents| {
|
||||
let file = entry.path();
|
||||
let filename = file.file_name().unwrap();
|
||||
if filename != "Cargo.toml" {
|
||||
return;
|
||||
}
|
||||
|
||||
let is_2021 = contents.lines().any(is_edition_2021);
|
||||
if !is_2021 {
|
||||
tidy_error!(
|
||||
bad,
|
||||
"{} doesn't have `edition = \"2021\"` on a separate line",
|
||||
file.display()
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
let is_2021 = contents.lines().any(is_edition_2021);
|
||||
if !is_2021 {
|
||||
tidy_error!(
|
||||
bad,
|
||||
"{} doesn't have `edition = \"2021\"` on a separate line",
|
||||
file.display()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ fn main() {
|
||||
|
||||
// Checks that need to be done for both the compiler and std libraries.
|
||||
check!(unit_tests, &src_path);
|
||||
check!(unit_tests, &tests_path);
|
||||
check!(unit_tests, &compiler_path);
|
||||
check!(unit_tests, &library_path);
|
||||
|
||||
@ -107,7 +106,6 @@ fn main() {
|
||||
check!(edition, &src_path);
|
||||
check!(edition, &compiler_path);
|
||||
check!(edition, &library_path);
|
||||
check!(edition, &tests_path);
|
||||
|
||||
check!(alphabetical, &src_path);
|
||||
check!(alphabetical, &tests_path);
|
||||
|
@ -24,7 +24,6 @@ pub fn check(root_path: &Path, bad: &mut bool) {
|
||||
let file_name = path.file_name().unwrap_or_default();
|
||||
if path.is_dir() {
|
||||
filter_dirs(path)
|
||||
|| path.ends_with("tests")
|
||||
|| path.ends_with("src/doc")
|
||||
|| (file_name == "tests" || file_name == "benches") && !is_core(path)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user