Skip to content

Commit 84b30a6

Browse files
committed
fix: resolve clippy warning and separate performance tests from CI
1 parent 9aa5c4f commit 84b30a6

2 files changed

Lines changed: 67 additions & 27 deletions

File tree

.github/workflows/test.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ jobs:
114114
- name: Build native module
115115
run: npm run build
116116

117-
- name: Run tests
118-
run: npm test
117+
- name: Run tests (excluding performance tests)
118+
run: npm test -- --exclude '**/{benchmark,performance-regression}.test.ts'
119119

120120
- name: Upload test artifacts on failure
121121
if: failure()
@@ -161,3 +161,46 @@ jobs:
161161

162162
- name: Clippy
163163
run: cargo clippy -- -D warnings
164+
165+
benchmark:
166+
name: Performance Benchmarks (${{ matrix.os }})
167+
runs-on: ${{ matrix.os }}
168+
continue-on-error: true
169+
strategy:
170+
fail-fast: false
171+
matrix:
172+
os: [ubuntu-latest, macos-latest]
173+
174+
steps:
175+
- uses: actions/checkout@v4
176+
177+
- name: Setup Node.js
178+
uses: actions/setup-node@v4
179+
with:
180+
node-version: 22
181+
cache: 'npm'
182+
183+
- name: Install Rust
184+
uses: dtolnay/rust-toolchain@stable
185+
186+
- name: Cache cargo
187+
uses: actions/cache@v4
188+
with:
189+
path: |
190+
~/.cargo/bin/
191+
~/.cargo/registry/index/
192+
~/.cargo/registry/cache/
193+
~/.cargo/git/db/
194+
target/
195+
key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
196+
restore-keys: |
197+
${{ runner.os }}-cargo-bench-
198+
199+
- name: Install dependencies
200+
run: npm ci
201+
202+
- name: Build native module
203+
run: npm run build
204+
205+
- name: Run performance tests (informational)
206+
run: npm test -- tests/benchmark.test.ts tests/performance-regression.test.ts --testTimeout=120000

src/walker.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -314,34 +314,31 @@ impl Walker {
314314
// Apply pruning filter if set
315315
if let Some(ref prune_filter) = self.dir_prune_filter {
316316
let root = self.root.clone();
317-
entries = entries
318-
.into_iter()
319-
.filter(|entry| {
320-
if let Ok(rel_path) = entry.path().strip_prefix(&root) {
321-
let rel_lossy = rel_path.to_string_lossy();
322-
let rel_str = normalize_path_str(&rel_lossy);
323-
// Root directory always passes
324-
if rel_str.is_empty() {
325-
return true;
326-
}
327-
// For directories, check if they should be included
328-
if entry.is_dir() && !prune_filter(&rel_str) {
329-
return false;
330-
}
331-
// For files, check if their parent directory passes the filter
332-
if !entry.is_dir() {
333-
if let Some(parent) = rel_path.parent() {
334-
let parent_lossy = parent.to_string_lossy();
335-
let parent_str = normalize_path_str(&parent_lossy);
336-
if !parent_str.is_empty() && !prune_filter(&parent_str) {
337-
return false;
338-
}
317+
entries.retain(|entry| {
318+
if let Ok(rel_path) = entry.path().strip_prefix(&root) {
319+
let rel_lossy = rel_path.to_string_lossy();
320+
let rel_str = normalize_path_str(&rel_lossy);
321+
// Root directory always passes
322+
if rel_str.is_empty() {
323+
return true;
324+
}
325+
// For directories, check if they should be included
326+
if entry.is_dir() && !prune_filter(&rel_str) {
327+
return false;
328+
}
329+
// For files, check if their parent directory passes the filter
330+
if !entry.is_dir() {
331+
if let Some(parent) = rel_path.parent() {
332+
let parent_lossy = parent.to_string_lossy();
333+
let parent_str = normalize_path_str(&parent_lossy);
334+
if !parent_str.is_empty() && !prune_filter(&parent_str) {
335+
return false;
339336
}
340337
}
341338
}
342-
true
343-
})
344-
.collect();
339+
}
340+
true
341+
});
345342
}
346343

347344
Box::new(entries.into_iter())

0 commit comments

Comments
 (0)