Skip to content

Remove the rtk test subcommand: let native test fall through to passthrough (0/526 vs 212/526) #3932

Open

Description

@KuSh

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.

Activity

  1. added
    bug
    help wanted
    on Sep 8, 2026
  2. removed
    bug
    help wanted
    on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions