Skip to content

Commit a320846

Browse files
committed
feat(php): add PHPUnit filter with compact output (65%+ token savings)
- New `rtk phpunit` command: state-machine filter that captures test names, assertion messages, and file locations from PHPUnit output, stripping version banner, progress dots, timing, and memory noise - Supports all invocation variants: `phpunit`, `vendor/bin/phpunit`, `bin/phpunit` (Symfony), `php vendor/bin/phpunit`, `php bin/phpunit` - Binary detection priority: global phpunit → bin/phpunit → vendor/bin/phpunit - Registers in discover/rules.rs for `rtk discover` and hook rewriting - 17 tests: 7 filter tests (including token savings ≥60%), 10 registry tests for classify/rewrite across all variants; real fixture in tests/fixtures/phpunit_raw.txt - "OK (X tests, Y assertions)" → already worked, now also shows counts for the generic fallback path - "OK, but incomplete, skipped, or risky tests!" → new handler shows skipped count (e.g. "PHPUnit: 9 tests, 15 assertions, 2 skipped") - Generic fallback now calls parse_counts to show test/assertion counts instead of bare "PHPUnit: OK" - parse_counts returns 4-tuple (tests, assertions, failures, skipped) to support Skipped: field with trailing-period stripping - 3 new tests covering each success variant - catch segfault + Fatal error
1 parent 2efe860 commit a320846

File tree

9 files changed

+589
-0
lines changed

9 files changed

+589
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ rtk go test # Go tests (NDJSON, -90%)
176176
rtk cargo test # Cargo tests (-90%)
177177
rtk rake test # Ruby minitest (-90%)
178178
rtk rspec # RSpec tests (JSON, -60%+)
179+
rtk phpunit # PHPUnit tests (failures only, -65%+)
179180
```
180181

181182
### Build & Lint
@@ -418,6 +419,7 @@ Blocked on upstream BeforeToolCallback support ([mistral-vibe#531](https://githu
418419
| `rake test` / `rails test` | `rtk rake test` |
419420
| `rspec` / `bundle exec rspec` | `rtk rspec` |
420421
| `rubocop` / `bundle exec rubocop` | `rtk rubocop` |
422+
| `phpunit` / `vendor/bin/phpunit` / `bin/phpunit` | `rtk phpunit` |
421423
| `bundle install/update` | `rtk bundle ...` |
422424
| `docker ps/images/logs` | `rtk docker ...` |
423425
| `kubectl get/logs` | `rtk kubectl ...` |

scripts/test-all.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,16 @@ section "Hook check (#344)"
564564

565565
assert_contains "rtk init --show hook version" "version" rtk init --show
566566

567+
# ── 42. PHP (conditional) ───────────────────────────
568+
569+
section "PHP (conditional)"
570+
571+
if command -v phpunit &>/dev/null || [ -f vendor/bin/phpunit ] || [ -f bin/phpunit ]; then
572+
assert_help "rtk phpunit" rtk phpunit --help
573+
else
574+
skip_test "rtk phpunit" "phpunit not installed"
575+
fi
576+
567577
# ══════════════════════════════════════════════════════
568578
# Report
569579
# ══════════════════════════════════════════════════════

src/cmds/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub mod dotnet;
55
pub mod git;
66
pub mod go;
77
pub mod js;
8+
pub mod php;
89
pub mod python;
910
pub mod ruby;
1011
pub mod rust;

src/cmds/php/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! PHP ecosystem filters.
2+
3+
pub mod phpunit_cmd;

0 commit comments

Comments
 (0)