Skip to content

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

Open

Description

@mgpai22

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.

Activity

  1. rtk-wshm-sync-bot commented on Sep 11, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 88%

    Summary

    rtk go test -v still collapses passing-test output despite explicit -v, breaking grep-based marker gates on green runs where recall can't recover it; add -v/-test.v/-json detection to back off compression in the go test filter


    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. arthurk commented on Oct 13, 2026

    @arthurk

    Same problem here. My agent is burning 3 turns on a problem that has nothing to do with the task:

    $ go test -race -count=1 -v ./internal/strutil/... 2>&1 | tail -25
    Go test: 8 passed in 1 packages
    
    $ go test -race -count=1 -v -run TestTruncate ./internal/strutil/ 2>&1 | head -40
    Go test: 8 passed in 1 packages
    
    The test runner output is being summarized by a wrapper — let me get the real verbose output.
    
    $ go test -race -count=1 -v -run TestTruncate ./internal/strutil/ > /tmp/opencode/truncate_out.txt 2>&1; echo "EXIT:$?"; wc -l /tmp/opencode/truncate_out.txt
    
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

    area:clibugpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions