Overview
RTK provides token-optimized test runners for multiple ecosystems. All test commands achieve 90%+ token savings by showing only failures while preserving:- Exit codes for CI/CD
- Failure details (stack traces, assertions)
- Test counts and duration
- Full output via tee recovery
Supported Test Runners
Cargo
rtk cargo test - Rust tests via cargoVitest
rtk vitest - JavaScript/TypeScript via VitestPytest
rtk pytest - Python tests via pytestGo
rtk go test - Go tests with NDJSON streamingrtk test (Generic)
Generic test runner wrapper that filters any test command.Usage
Examples
Features
- Failures only: Skips passing tests
- Stack traces: Preserves failure details
- Counts: Shows passed/failed/skipped
- Tee recovery: Full output saved to file
Implementation
Fromsrc/runner.rs:run_test():
- Executes command via shell
- Parses stdout/stderr for test results
- Filters out passing tests
- Preserves exit codes
rtk cargo test
Rust test runner via cargo.Usage
Options
--lib: Test library only--bins: Test binaries--tests: Test integration tests--doc: Test documentation--all-features: Enable all features--no-fail-fast: Don’t stop on first failure
Examples
Token Savings
| Tests | Standard | RTK | Savings |
|---|---|---|---|
| 10 passing | 1,000 | 50 | -95% |
| 8 pass, 2 fail | 2,500 | 250 | -90% |
rtk vitest
JavaScript/TypeScript test runner via Vitest.Usage
Commands
run: Run tests once (default)watch: Watch mode (passthrough)dev: Dev mode (passthrough)
Examples
Features
- JSON parsing: Parses
--reporter=jsonoutput - ANSI stripping: Removes color codes
- Package manager detection: Auto-detects pnpm/npm/yarn
- Tee recovery: Saves full output on failure
Implementation
Fromsrc/vitest_cmd.rs:VitestParser:
- Forces
--reporter=jsonfor structured output - Parses JSON line-by-line (handles pnpm prefixes)
- Extracts failures with stack traces
- Falls back to regex if JSON parsing fails
rtk pytest
Python test runner via pytest.Usage
Options
-v: Verbose (passthrough)-k <pattern>: Run tests matching pattern-x: Stop on first failure--tb=short: Short traceback (default)
Examples
Features
- State machine parser: Parses text output (no JSON needed)
- Auto-flags: Forces
--tb=short -qfor compact output - Import errors: Preserves stderr for import failures
- Tee recovery: Saves full output on failure
Implementation
Fromsrc/pytest_cmd.rs:filter_pytest_output():
- State machine: Header → TestProgress → Failures → Summary
- Extracts failure sections with traceback
- Filters out passing tests (
.dots) - Preserves exit codes
rtk go test
Go test runner with NDJSON streaming.Usage
Flags
-v: Verbose (passthrough)-run <regexp>: Run tests matching pattern-short: Run short tests only-timeout <duration>: Test timeout
Examples
Features
- NDJSON parsing: Parses
-jsonoutput line-by-line - Streaming: Handles interleaved package events
- Build errors: Captures build failures separately
- Tee recovery: Saves full output on failure
Implementation
Fromsrc/go_cmd.rs:filter_go_test_json():
- Forces
-jsonflag for structured output - Parses
GoTestEventNDJSON structs - Groups by package (handles multiple packages)
- Tracks pass/fail/skip counts per package
- Preserves exit codes
Tee Output Recovery
All test commands use tee recovery to save full output on failure.How It Works
- Test runs and produces output
- RTK filters to failures only
- If exit code != 0, saves raw output to
~/.local/share/rtk/tee/ - Prints hint:
[full output: ~/.../1707753600_cargo_test.log] - LLM reads file instead of re-running test
Configuration
From~/.config/rtk/config.toml:
Environment Overrides
CI/CD Integration
All test commands preserve exit codes:Token Savings Summary
| Test Runner | Standard Tokens | RTK Tokens | Savings |
|---|---|---|---|
| cargo test (15 tests, 2 fail) | 2,500 | 250 | -90% |
| vitest (18 tests, 5 fail) | 3,000 | 300 | -90% |
| pytest (12 tests, 1 fail) | 800 | 80 | -90% |
| go test (10 tests, 1 fail) | 600 | 60 | -90% |
Next Steps
JavaScript
Modern JS/TS stack tools
Python
Python development tools
