Skip to content

Conversation

@robobun
Copy link
Collaborator

@robobun robobun commented Nov 25, 2025

Summary

This PR adds the --resolve-extensions CLI flag and resolveExtensions bunfig.toml property to allow users to customize which file name patterns are recognized as test files.

Motivation

Different projects and teams have different naming conventions for test files. While Bun's defaults (.test, _test, .spec, _spec) work well for most cases, some projects may prefer alternative patterns like .check, .verify, or other custom suffixes.

Features

CLI Flag

# Single custom extension
bun test --resolve-extensions .check

# Multiple custom extensions  
bun test --resolve-extensions .check --resolve-extensions .verify

bunfig.toml Configuration

[test]
# Single extension
resolveExtensions = ".check"

# Multiple extensions
resolveExtensions = [".check", ".verify"]

CLI Override

The CLI flag takes precedence over bunfig.toml configuration, allowing per-run customization.

Implementation Details

  • Modified Scanner.zig to accept optional custom test name suffixes
  • Added resolve_extensions field to TestOptions struct
  • Implemented CLI argument parsing with support for multiple values
  • Implemented bunfig.toml parsing with proper CLI override logic
  • Updated error messages to dynamically show configured extensions
  • All existing default behavior remains unchanged

Testing

Added comprehensive test suite covering:

  • ✅ CLI flag with single extension
  • ✅ CLI flag with multiple extensions
  • ✅ bunfig.toml with string value
  • ✅ bunfig.toml with array value
  • ✅ CLI override of bunfig.toml
  • ✅ Custom extensions with underscore prefix
  • ✅ Error messages showing custom extensions
  • ✅ Nested directory support
  • ✅ Default behavior still works

All 9 tests pass successfully.

Documentation

  • Added detailed markdown documentation in test/cli/test-resolve-extensions.md
  • Includes usage examples and notes about precedence

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

…t file patterns

This change allows users to customize which file name patterns are recognized
as test files, providing flexibility for projects with different naming conventions.

Features:
- CLI flag: --resolve-extensions <STR>... (can specify multiple)
- bunfig.toml: [test] resolveExtensions = ".check" or [".check", ".verify"]
- CLI flag takes precedence over bunfig.toml configuration
- Dynamic error messages show configured extensions when no tests found
- Works with all JavaScript/TypeScript file extensions (.ts, .tsx, .js, .jsx, etc.)

Default behavior (unchanged):
- .test, _test, .spec, _spec suffixes continue to work when no custom config

Implementation:
- Modified Scanner.zig to accept custom test name suffixes
- Added resolve_extensions field to TestOptions in cli.zig
- Added CLI argument parsing in Arguments.zig
- Added bunfig.toml parsing in bunfig.zig with CLI override logic
- Updated error messages in test_command.zig to show custom extensions
- Added comprehensive test suite covering CLI, bunfig, and override scenarios

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@robobun
Copy link
Collaborator Author

robobun commented Nov 25, 2025

Updated 6:17 PM PT - Nov 24th, 2025

❌ Your commit 0dca0ee6 has 8 failures in Build #32365 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 25049

That installs a local version of the PR into your bun-25049 executable, so you can run:

bun-25049 --bun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants