rtk-ai / rtk-ai/rtk

rtk go test -v ignores the explicit -v flag and drops all passing-test output, breaking grep-based gates

Open
#3,985 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli bug priority:high
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

rtk go test -v ignores the explicit -v flag and drops all passing-test output, breaking grep-based gates

Version: rtk 0.49.0
Platform: Linux x86_64 (musl build, installed via install.sh), Go 1.26.4

Summary

-v on go test is an explicit request for per-test output. rtk go test -v still collapses passing tests to a count, so any line a passing test logged is absent from stdout.

Failure bodies are preserved (good — this appears to have improved in recent versions), but passing-test output is gone. That silently breaks the common agent/CI pattern of gating a follow-up step on a marker grep.

Reproduction

T=$(mktemp -d); cd "$T"
cat > go.mod <<'EOF'
module rtkprobe

go 1.26
EOF
cat > m_test.go <<'EOF'
package m

import "testing"

func TestPasses(t *testing.T) { t.Log("PASS_MARKER_A") }
func TestFails(t *testing.T) {
	t.Log("PROBE_MARKER_UNIQUE")
	t.Errorf("ASSERT_BODY: expected %d got %d", 42, 7)
}
EOF

for m in PROBE_MARKER_UNIQUE ASSERT_BODY PASS_MARKER_A; do
  printf '%-22s raw=%s rtk=%s\n' "$m" \
    "$(go test -v ./... 2>&1 | grep -c "$m")" \
    "$(rtk go test -v ./... 2>&1 | grep -c "$m")"
done
Actual
PROBE_MARKER_UNIQUE    raw=1 rtk=1
ASSERT_BODY            raw=1 rtk=1
PASS_MARKER_A          raw=1 rtk=0     <-- lost

rtk go test -v output:

Go test: 1 passed, 1 failed in 1 packages

rtkprobe (1 passed, 1 failed)
  [FAIL] TestFails
     m_test.go:7: PROBE_MARKER_UNIQUE
     m_test.go:8: ASSERT_BODY: expected 42 got 7
[full output: rtk recall 2aa88fa8b4f0]
Expected

With -v explicitly passed, per-test output passes through (or at least passing tests' t.Log lines are retained). The docs state filters are flag-aware and back off when the user requests verbosity; that back-off does not happen here.

Why this is a correctness problem, not a preference

A very common agent pattern is to gate the next action on a marker in test output:

rtk go test -v ./... | grep -q READY_MARKER && ./deploy.sh

Under rtk the grep finds nothing even though the raw output contained the marker, so the gate silently takes the wrong branch. In local session history this exact class of failure was recorded verbatim by an agent: "The grep check returned 0 because rtk reformats test output, which broke the && chain and prevented the commit."

Note also that rtk recall cannot recover this case when the suite passes, because the recall store only retains failures (exit != 0) — so on a green run the dropped output is unrecoverable.

Same class as #1499 (rtk git branch -vv has no -vv awareness), but for go test.

Suggested fix

In the go test filter, detect -v / -test.v / -json and pass output through unfiltered (or retain per-test log lines for passing tests). More generally, treating an explicit verbosity flag as an opt-out of compression would fix this whole family.

Discovery context

Found while auditing ~14,700 real RTK_DISABLED=1 bypasses in local agent session history: every go test -v -count=1 -run ... invocation in that corpus carried a manual bypass, which is consistent with the back-off never firing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the go test filter entry point and reproduce the issue using the temporary module's m_test.go and the shown go test -v ./... commands. Verify that passing-test output, including PASS_MARKER_A, is retained for -v, -test.v, or -json, and add regression coverage for the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, rust
Domain
cli, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.