51 lines
2.4 KiB
Markdown
51 lines
2.4 KiB
Markdown
# Plan for adding single file and glob pattern execution support to tstest
|
|
|
|
!! FIRST: Reread /home/philkunz/.claude/CLAUDE.md to ensure following all guidelines !!
|
|
|
|
## Goal - ✅ COMPLETED
|
|
- ✅ Make `tstest test/test.abc.ts` run the specified file directly
|
|
- ✅ Support glob patterns like `tstest test/*.spec.ts` or `tstest test/**/*.test.ts`
|
|
- ✅ Maintain backward compatibility with directory argument
|
|
|
|
## Current behavior - UPDATED
|
|
- ✅ tstest now supports three modes: directory, single file, and glob patterns
|
|
- ✅ Directory mode now searches recursively using `**/test*.ts` pattern
|
|
- ✅ Single file mode runs a specific test file
|
|
- ✅ Glob mode runs files matching the pattern
|
|
|
|
## Completed changes
|
|
|
|
### 1. ✅ Update cli argument handling in index.ts
|
|
- ✅ Detect argument type: file path, glob pattern, or directory
|
|
- ✅ Check if argument contains glob characters (*, **, ?, [], etc.)
|
|
- ✅ Pass appropriate mode to TsTest constructor
|
|
- ✅ Added TestExecutionMode enum
|
|
|
|
### 2. ✅ Modify TsTest constructor and class
|
|
- ✅ Add support for three modes: directory, file, glob
|
|
- ✅ Update constructor to accept pattern/path and mode
|
|
- ✅ Added executionMode property to track the mode
|
|
|
|
### 3. ✅ Update TestDirectory class
|
|
- ✅ Used `listFileTree` for glob pattern support
|
|
- ✅ Used `SmartFile.fromFilePath` for single file loading
|
|
- ✅ Refactored to support all three modes in `_init` method
|
|
- ✅ Return appropriate file array based on mode
|
|
- ✅ Changed default directory behavior to recursive search
|
|
- ✅ When directory argument: use `**/test*.ts` pattern for recursive search
|
|
- ✅ This ensures subdirectories are included in test discovery
|
|
|
|
### 4. ✅ Test the implementation
|
|
- ✅ Created test file `test/test.single.ts` for single file functionality
|
|
- ✅ Created test file `test/test.glob.ts` for glob pattern functionality
|
|
- ✅ Created test in subdirectory `test/subdir/test.sub.ts` for recursive search
|
|
- ✅ Tested with existing test files for backward compatibility
|
|
- ✅ Tested glob patterns: `test/test.*.ts` works correctly
|
|
- ✅ Verified that default behavior now includes subdirectories
|
|
|
|
## Implementation completed
|
|
1. ✅ CLI argument type detection implemented
|
|
2. ✅ TsTest class supports all three modes
|
|
3. ✅ TestDirectory handles files, globs, and directories
|
|
4. ✅ Default pattern changed from `test*.ts` to `**/test*.ts` for recursive search
|
|
5. ✅ Comprehensive tests added and all modes verified |