--path-ignore-patterns to exclude tests#28089
Conversation
Provided paths will be ignored and will not display as skipped. Useful if, for example, submodules contain `*.test.ts` that may be picked up by `bun:test` by default.
|
Updated 10:45 AM PT - Mar 14th, 2026
❌ @claude, your commit 525b4dd has 1 failures in 🧪 To try this PR locally: bunx bun-pr 28089That installs a local version of the PR into your bun-28089 --bun |
|
@robobun You can probably use "Closes ..." syntax to schedule this PR to close the original dupe PR. |
|
✅ Verification complete — PR #28089 CI: Buildkite #39573 — all build and test steps pass across all platforms (Linux, macOS, Alpine, ASAN). The only failure is Classification: New feature — no test-proof gate required. Diff: Clean — changes scoped to bunfig parsing ( Review threads: 0 unresolved. Hygiene: Branch Ready for human review and merge. (Re-verified Mar 14, last re-check: all gates still hold, CI completed, no new pushes or threads.) |
|
Good call — GitHub's "Closes" keyword only auto-closes issues on merge, not other PRs. I'll close #27452 manually once this lands. |
WalkthroughAdds test path exclusion via a new Changes
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/bunfig.zig`:
- Around line 487-490: The precedence check in the block handling
test_.get("pathIgnorePatterns") uses
this.ctx.test_options.path_ignore_patterns.len > 0 to infer a CLI override,
which prevents local bunfig values from overriding a previously loaded global
bunfig; change the logic to check an explicit flag (e.g.,
this.ctx.test_options.path_ignore_patterns_from_cli) instead of length so only
an actual CLI-provided value blocks overrides, update all similar checks in the
surrounding block (the same pattern around lines handling pathIgnorePatterns
between the if and the following cases), and modify the CLI parsing code that
processes --path-ignore-patterns to set that boolean when the option is
provided.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3acbdf22-6d6d-4132-ae65-ea3708f62f00
📒 Files selected for processing (8)
docs/runtime/bunfig.mdxdocs/test/configuration.mdxsrc/bunfig.zigsrc/cli.zigsrc/cli/Arguments.zigsrc/cli/test/Scanner.zigsrc/cli/test_command.zigtest/cli/test/path-ignore-patterns.test.ts
|
Found 4 issues this PR may fix:
🤖 Generated with Claude Code |
Add explicit `path_ignore_patterns_from_cli` flag so local bunfig can override global bunfig (previously the `.len > 0` check blocked it). Also try matching directory paths with a trailing `/` so patterns like `vendor/**` correctly prune directory subtrees during scanning. https://claude.ai/code/session_01XUic2GpN4rRZw8bh19ALRT
|
⏳ Push |
Single-star patterns like "vendor/*" must not prune entire directory trees during scanning. Only patterns containing "**" get the trailing-slash retry, preventing over-pruning. https://claude.ai/code/session_01XUic2GpN4rRZw8bh19ALRT
|
✅ All gates pass on |
There was a problem hiding this comment.
No bugs found and all previously raised issues are resolved. Deferring because this is a new feature touching core test discovery infrastructure (Scanner, bunfig, CLI args) where a maintainer should sign off on design choices.
Extended reasoning...
Overview
This PR adds --path-ignore-patterns as a CLI flag and pathIgnorePatterns as a bunfig.toml option for excluding test files/directories during bun test discovery. It touches 8 files: bunfig parsing (bunfig.zig), CLI option struct and argument parsing (cli.zig, Arguments.zig), the test scanner (Scanner.zig), wiring in test_command.zig, documentation (bunfig.mdx, configuration.mdx), and comprehensive tests (path-ignore-patterns.test.ts).
Security risks
No security concerns. The feature operates on local file paths using existing glob matching infrastructure. No user input reaches network calls, shell execution, or sensitive operations.
Level of scrutiny
This is a new user-facing feature that modifies the test scanner — a core code path for test discovery. While the implementation closely follows the existing coveragePathIgnorePatterns pattern (same bunfig parsing structure, same CLI arg style), the design decisions around naming (pathIgnorePatterns vs alternatives), glob semantics (directory pruning behavior, CLI-overrides-bunfig), and the trailing-slash heuristic for ** patterns deserve human review. A maintainer should confirm these choices align with Bun's overall design direction.
Other factors
- All three issues raised during the review cycle (bunfig precedence bug,
/**pruning failure, single-star over-pruning) have been addressed in the current diff. - CI passes (only pre-existing failures on main).
- Tests cover single/array patterns, glob behavior, directory pruning, CLI override semantics, invalid config errors, and empty arrays.
- The PR was AI-authored (claude label) and should receive human sign-off before merging.
|
@robobun Why do we have |
|
It tracks whether In short: CLI |
Follow-up to #28089. `matchesPathIgnorePattern` in `src/cli/test/Scanner.zig` allocates `var buf: [bun.MAX_PATH_BYTES]u8` on the stack. On Windows that's `32767 * 3 + 1` ≈ 96KB to hold a relative path from the project root plus a trailing slash — realistically under 200 bytes. Changes: - Shrink the buffer to `[4096]u8` (POSIX PATH_MAX — covers any realistic test directory depth) - Hoist the `rel_path + '/'` construction outside the `for (patterns)` loop since `rel_path` is loop-invariant (was re-memcpy'ing the same path once per pattern) Behavior is unchanged. If a relative path somehow exceeds 4095 bytes, the trailing-slash fallback is skipped (same silent-degrade as before, just at a lower threshold) — early directory pruning is lost for that one path but files inside still get filtered by the direct glob match.
|
This is already in the docs despite not being available in 1.3.10. Is that intentional? |
### What does this PR do? Picked up from oven-sh#27452 by @ctjlewis (requested by @alii in oven-sh#27452 (comment)) so CI runs automatically and the autofixer works. All commits preserve original authorship (Lewis <lewis@spellcraft.org>). --- Adds `--path-ignore-patterns` argument and Bunfig option similar to `--coverage-path-ignore-patterns`. https://bun.com/docs/test/configuration#coverage-path-ignore-patterns - Closes oven-sh#27388 - Closes oven-sh#21395 - Closes oven-sh#13963 ### How did you verify your code works? Tests in `test/cli/test/path-ignore-patterns.test.ts` (328 lines). ### Docs Simple docs added for Bunfig and Configuration docs. ### Verification Buildkite #39573 on `1a1af82`: only CI failure is a snapshot mismatch in `test/js/bun/test/snapshot-tests/snapshots/snapshot.test.ts` (111 passed, 1 failed snapshot) — completely unrelated to this PR. Main branch also failing on all recent commits (builds #39449, #39406, #39511, #39396). All 3 bot review threads resolved. Diff clean — no TODOs, changes scoped to bunfig parsing, CLI args, test scanner, docs, and tests. Ready for human review. --- **Verification (robobun):** CI green (13/13 on `525b4dd`). Diff clean — no TODOs, changes well-scoped to bunfig parsing, CLI args, test scanner, docs, and tests. All 3 bot review threads resolved (coderabbit precedence fix applied, trailing-slash pruning restricted to `**` patterns). Feature PR — tests confirm baked binary lacks the feature (9 fail) while CI passes all platform suites. --------- Co-authored-by: Lewis <lewis@spellcraft.org> Co-authored-by: Alistair Smith <alistair@anthropic.com>
…ven-sh#28128) Follow-up to oven-sh#28089. `matchesPathIgnorePattern` in `src/cli/test/Scanner.zig` allocates `var buf: [bun.MAX_PATH_BYTES]u8` on the stack. On Windows that's `32767 * 3 + 1` ≈ 96KB to hold a relative path from the project root plus a trailing slash — realistically under 200 bytes. Changes: - Shrink the buffer to `[4096]u8` (POSIX PATH_MAX — covers any realistic test directory depth) - Hoist the `rel_path + '/'` construction outside the `for (patterns)` loop since `rel_path` is loop-invariant (was re-memcpy'ing the same path once per pattern) Behavior is unchanged. If a relative path somehow exceeds 4095 bytes, the trailing-slash fallback is skipped (same silent-degrade as before, just at a lower threshold) — early directory pruning is lost for that one path but files inside still get filtered by the direct glob match.
Verified after upgrading from Bun 1.3.10 to 1.3.13: the bunfig key now prunes references/ during scan (oven-sh/bun#28089). Tightens the comments and AGENTS.md callout to reflect the version requirement instead of a 'no-op' workaround.
### What does this PR do? Picked up from oven-sh#27452 by @ctjlewis (requested by @alii in oven-sh#27452 (comment)) so CI runs automatically and the autofixer works. All commits preserve original authorship (Lewis <lewis@spellcraft.org>). --- Adds `--path-ignore-patterns` argument and Bunfig option similar to `--coverage-path-ignore-patterns`. https://bun.com/docs/test/configuration#coverage-path-ignore-patterns - Closes oven-sh#27388 - Closes oven-sh#21395 - Closes oven-sh#13963 ### How did you verify your code works? Tests in `test/cli/test/path-ignore-patterns.test.ts` (328 lines). ### Docs Simple docs added for Bunfig and Configuration docs. ### Verification Buildkite #39573 on `1a1af82`: only CI failure is a snapshot mismatch in `test/js/bun/test/snapshot-tests/snapshots/snapshot.test.ts` (111 passed, 1 failed snapshot) — completely unrelated to this PR. Main branch also failing on all recent commits (builds #39449, #39406, #39511, #39396). All 3 bot review threads resolved. Diff clean — no TODOs, changes scoped to bunfig parsing, CLI args, test scanner, docs, and tests. Ready for human review. --- **Verification (robobun):** CI green (13/13 on `525b4dd`). Diff clean — no TODOs, changes well-scoped to bunfig parsing, CLI args, test scanner, docs, and tests. All 3 bot review threads resolved (coderabbit precedence fix applied, trailing-slash pruning restricted to `**` patterns). Feature PR — tests confirm baked binary lacks the feature (9 fail) while CI passes all platform suites. --------- Co-authored-by: Lewis <lewis@spellcraft.org> Co-authored-by: Alistair Smith <alistair@anthropic.com>
…ven-sh#28128) Follow-up to oven-sh#28089. `matchesPathIgnorePattern` in `src/cli/test/Scanner.zig` allocates `var buf: [bun.MAX_PATH_BYTES]u8` on the stack. On Windows that's `32767 * 3 + 1` ≈ 96KB to hold a relative path from the project root plus a trailing slash — realistically under 200 bytes. Changes: - Shrink the buffer to `[4096]u8` (POSIX PATH_MAX — covers any realistic test directory depth) - Hoist the `rel_path + '/'` construction outside the `for (patterns)` loop since `rel_path` is loop-invariant (was re-memcpy'ing the same path once per pattern) Behavior is unchanged. If a relative path somehow exceeds 4095 bytes, the trailing-slash fallback is skipped (same silent-degrade as before, just at a lower threshold) — early directory pruning is lost for that one path but files inside still get filtered by the direct glob match.
What does this PR do?
Picked up from #27452 by @ctjlewis (requested by @alii in #27452 (comment)) so CI runs automatically and the autofixer works.
All commits preserve original authorship (Lewis lewis@spellcraft.org).
Adds
--path-ignore-patternsargument and Bunfig option similar to--coverage-path-ignore-patterns.https://bun.com/docs/test/configuration#coverage-path-ignore-patterns
bun testSupport for--pathIgnorePatternsand--pathPatternsfor Bun test runner (similar to Jest) #21395How did you verify your code works?
Tests in
test/cli/test/path-ignore-patterns.test.ts(328 lines).Docs
Simple docs added for Bunfig and Configuration docs.
Verification
Buildkite #39573 on
1a1af82: only CI failure is a snapshot mismatch intest/js/bun/test/snapshot-tests/snapshots/snapshot.test.ts(111 passed, 1 failed snapshot) — completely unrelated to this PR. Main branch also failing on all recent commits (builds #39449, #39406, #39511, #39396). All 3 bot review threads resolved. Diff clean — no TODOs, changes scoped to bunfig parsing, CLI args, test scanner, docs, and tests. Ready for human review.Verification (robobun): CI green (13/13 on
525b4dd). Diff clean — no TODOs, changes well-scoped to bunfig parsing, CLI args, test scanner, docs, and tests. All 3 bot review threads resolved (coderabbit precedence fix applied, trailing-slash pruning restricted to**patterns). Feature PR — tests confirm baked binary lacks the feature (9 fail) while CI passes all platform suites.