Remove the `rtk test` subcommand: let native `test` fall through to passthrough (0/526 vs 212/526)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 81.1k
- Forks
- 5.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 35
Description
Summary
rtk test is both RTK's generic test-runner wrapper and a shadow of the POSIX test utility. That collision is what #2515 fixed: rtk test -d graphify-out was joined into a shell string and run as sh -c "-d graphify-out", producing sh: 0: Illegal option -d.
#2515 resolves it with a predicate that decides, per invocation, whether the arguments look like a native test expression. It is a real improvement, but it is a heuristic, and the heuristic is the whole problem — it can only ever be approximately right.
Removing the subcommand is exact instead. RTK already passes unknown subcommands through to the real binary (rtk basename /a/b.txt → b.txt), so with Commands::Test gone, rtk test <expr> reaches /usr/bin/test and behaves identically to it.
Measurement
526 generated test expressions, exit code diffed against /usr/bin/test:
| build | mismatches |
|---|---|
| before #2515 | 411 / 526 |
| #2515 as merged | 212 / 526 |
Commands::Test removed |
0 / 526 |
The 212 that survive #2515 are the cases its predicate cannot reach: every operand-first form (rtk test 1 -eq 1, rtk test abc = abc → sh: 1: 1: not found, exit 127) and rtk test -h FILE, which clap consumes as its help flag and answers 0 for every path. Removal fixes both, along with the !/( ambiguity that needed a follow-up commit on #2515.
What it deletes
is_native_test_expression and its unit tests, run_test,
extract_test_summary, and MAX_RUNNER_FAILURES / MAX_RUNNER_LINES in
src/cmds/rust/runner.rs all become dead once the arm is gone.
What needs a decision, not just a deletion
It drops off the integrity whitelist. Commands::Test is listed in is_operational_command (src/main.rs:2543), which gates
hooks::integrity::runtime_check() at src/main.rs:1486. The passthrough catch-all is not on that list, and the whitelist's own comment says a command missing from it "fails open (no check)". So removal silently ends runtime hook verification for this path. That should be a deliberate call rather than a side effect.
What is lost
rtk test <cmd> as a generic wrapper, documented at README.md:201 and docs/usage/FEATURES.md:563-571. Every ecosystem named in those docs already has a dedicated filter (rtk cargo test, rtk pytest, rtk go test, rtk vitest, rtk rspec, …) and rtk err <cmd> remains as the generic fallback, so the real loss is ecosystems with neither. No rewrite rule emits bare rtk test — the ("test", 90.0) entries in discover/rules.rs are subcommand savings for rtk cargo test and friends — so the hook generates no traffic that this breaks.
Notes
Filed from the review of #2515, which should merge on its own merits first; this supersedes rather than blocks it.
The agent guidance that generates rtk test invocations — the "prefix every shell command" rule and the wording that makes it false for builtins — moved to #3969, which covers the same three instruction files for every builtin, not just test. Removal here and the wording fix there are independent: read and help have no binary to pass through to, so only the wording reaches them.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Commands::Test definition and its handling in the CLI, then inspect the dead-code candidates in src/cmds/rust/runner.rs and the integrity whitelist at src/main.rs:2543. Review README.md:201 and docs/usage/FEATURES.md:563-571 for the documented generic wrapper. Done means the native test expressions match /usr/bin/test across the reported corpus, the integrity behavior is deliberately addressed, and stale code and documentation are handled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, shell
- Domain
- cli
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100