Skip to content

go test JSON filter reports a cut-off stream as all passed #4693

Open

Description

@KuSh

filter_go_test_json counts terminal pass/fail events and ignores tests that started but never finished. When the stream stops before a failing test's fail event, the summary is green.

Take a real go test -json ./... stream with one failing test (Go 1.24.6, 27 packages) and keep the lines before {"Action":"fail","Package":"example.com/proj/zz","Test":"TestX"}. That is what timeout, a killed CI step or | head -n N leaves behind. rtk pipe -f go-test prints:

Go test: 50 passed in 27 packages

The stream contains --- FAIL: TestX and z_test.go:5: expected 1, got 2 in output events, and both are dropped. Related: #958 (a timed-out run reported as No tests found).

Reproduced on develop 5538d72 and on #4455's head.

Activity

  1. added
    bug
    on Oct 20, 2026
  2. rtk-wshm-sync-bot commented on Oct 20, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 93%

    Summary

    filter_go_test_json only counts terminal pass/fail events, so a truncated stream (timeout/kill/head) before a fail event reports all-green instead of surfacing in-flight failures.

    📁 Relevant files
    • src/filters/go_test_json.rs

    Suggested Actions

    1. Track in-progress tests (started but no terminal event) and surface them as unknown/incomplete, not passed
    2. Parse output-type events (--- FAIL:, file:line: msg) as fallback signal when stream is cut off
    3. Cross-check with go test timeout reported as 'No tests found' with exit code 0 #958 — same root cause (truncated stream misreported) in a different filter path
    4. Add a regression test using a truncated go test -json fixture ending mid-failure

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

  3. added a commit that references this issue on Oct 22, 2026
    e6e9278
  4. busraayaksiz commented on Oct 22, 2026

    @busraayaksiz

    Hitting this in real use, not only with a cut stream: rtk go test truncates the filter's own input at 10 MiB, so on a large go test -race run over several packages the summary is computed from a partial stream.

    Seen on 0.49.0 with a large Go codebase, three runs in one session:

    [rtk] warning: output exceeds 10 MiB — filter input truncated
    Go test: 1685 passed in 8 packages
    
    [rtk] warning: output exceeds 10 MiB — filter input truncated
    Go test: 798 passed in 7 packages
    

    The counts cover only the events before the cap. A test that fails after it is not in the summary, so the output reads as a green run. The warning is there, but the line under it is the one an agent acts on.

    Minimal repro on 1.0.1 (rtk-oss, macOS arm64, go 1.26.1). One noisy passing test pushes the -json stream past 10 MiB, then a failing test:

    package rtkbig
    
    import (
    	"strings"
    	"testing"
    )
    
    func TestAaaNoisy(t *testing.T) {
    	line := strings.Repeat("x", 100)
    	for i := 0; i < 150000; i++ {
    		t.Log(line)
    	}
    }
    
    func TestZzzFails(t *testing.T) {
    	t.Fatalf("expected 1, got 2")
    }
    $ rtk go test -count=1 ./...
    [rtk] warning: output exceeds 10 MiB — filter input truncated
    Go test: No tests found
    [full output: ".../rtk/tee/<ts>_go_test.log"]
    $ echo $?
    1
    

    The exit code is right (1), but the summary says nothing failed and does not name TestZzzFails.

    Suggestion: when the input is truncated, don't print a pass/fail count as if it were complete. Either say result unknown: input truncated at 10 MiB, exit code N or fall back to the ok/FAIL package lines and --- FAIL lines, which are small even on huge runs.

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:cibuggopriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions