Skip to content

Commit 6cd09b3

Browse files
Merge #941
941: replace walkdir with ripgreps ignore crate r=Alexhuszagh a=Emilgardis Co-authored-by: Emil Gardström <[email protected]>
2 parents 37d4252 + fc98fcc commit 6cd09b3

File tree

6 files changed

+84
-11
lines changed

6 files changed

+84
-11
lines changed

.github/actions/setup-rust/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ inputs:
1515
runs:
1616
using: composite
1717
steps:
18+
# Work around for sporadic issues with rustup self-update on windows
19+
- run: rustup set auto-self-update disable
20+
if: contains(runner.os, 'windows')
21+
shell: bash
1822
- name: Install Rust toolchain
1923
uses: actions-rs/toolchain@v1
2024
with:

Cargo.lock

+66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ lto = true
6363
[dev-dependencies]
6464
regex = "1"
6565
once_cell = "1"
66-
walkdir = "2"
66+
ignore = "0.4"
6767

6868
[package.metadata.release]
6969
dev-version = false

ci/test-bisect.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ main() {
3232
# shellcheck disable=SC2016
3333
echo '#!/usr/bin/env bash
3434
export CROSS_CUSTOM_TOOLCHAIN=1
35-
exec "${CROSS}" run --target '"${TARGET}" > bisect.sh
35+
"${CROSS}" run --target '"${TARGET}"'
36+
cargo -V | grep 2022-06
37+
' > bisect.sh
3638
chmod +x bisect.sh
3739

38-
if ! err=$(cargo bisect-rustc --script=./bisect.sh --target "${TARGET}" 2>&1 >/dev/null); then
40+
if ! err=$(cargo bisect-rustc --start 2022-07-01 --end 2022-07-03 --script=./bisect.sh --target "${TARGET}" 2>&1); then
3941
if [[ "${err}" != *"does not reproduce the regression"* ]]; then
4042
echo "${err}"
4143
exit 1

src/tests.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ pub fn get_cargo_workspace() -> &'static Path {
2727

2828
pub fn walk_dir<'a>(
2929
root: &'_ Path,
30-
skip: &'a [impl AsRef<OsStr>],
31-
ext: impl for<'s> Fn(Option<&'s std::ffi::OsStr>) -> bool + 'static,
32-
) -> impl Iterator<Item = Result<walkdir::DirEntry, walkdir::Error>> + 'a {
33-
walkdir::WalkDir::new(root)
34-
.into_iter()
30+
skip: &'static [impl AsRef<OsStr> + Send + Sync + 'a],
31+
ext: impl for<'s> Fn(Option<&'s std::ffi::OsStr>) -> bool + Sync + Send + 'static,
32+
) -> impl Iterator<Item = Result<ignore::DirEntry, ignore::Error>> {
33+
ignore::WalkBuilder::new(root)
3534
.filter_entry(move |e| {
3635
if skip
3736
.iter()
3837
.map(|s| -> &std::ffi::OsStr { s.as_ref() })
3938
.any(|dir| e.file_name() == dir)
4039
{
4140
return false;
42-
} else if e.file_type().is_dir() {
41+
} else if e.file_type().map_or(false, |f| f.is_dir()) {
4342
return true;
4443
}
4544
ext(e.path().extension())
4645
})
46+
.build()
4747
}
4848

4949
#[test]
@@ -134,9 +134,10 @@ release: {version}
134134
fn check_newlines() -> crate::Result<()> {
135135
for file in walk_dir(get_cargo_workspace(), &[".git", "target"], |_| true) {
136136
let file = file?;
137-
if !file.file_type().is_file() {
137+
if !file.file_type().map_or(true, |f| f.is_file()) {
138138
continue;
139139
}
140+
eprintln!("File: {:?}", file.path());
140141
assert!(
141142
crate::file::read(file.path())
142143
.unwrap_or_else(|_| String::from("\n"))

src/tests/toml.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn toml_check() -> Result<(), Box<dyn std::error::Error>> {
3030

3131
for dir_entry in walk {
3232
let dir_entry = dir_entry?;
33-
if dir_entry.file_type().is_dir() {
33+
if dir_entry.file_type().map_or(true, |f| f.is_dir()) {
3434
continue;
3535
}
3636
eprintln!("File: {:?}", dir_entry.path());

0 commit comments

Comments
 (0)