Skip to content

filter(go): add go test filter #42

@mpecan

Description

@mpecan

Goal

Expand Go filters to cover go test -v — the verbose test output mode widely used in CI and agent contexts. Currently go/build.toml and go/vet.toml exist but test output has no filter.

Background

go test -v ./... on a large repo emits:

  • === RUN TestFunctionName for every test
  • --- PASS: TestFunctionName (0.00s) for every passing test
  • All t.Log() / t.Logf() output captured during passing tests
  • ok package/path 0.123s for every passing package

The Go team has an open proposal (golang/go#59201) for a -vf (verbose-when-fail) flag that would only show details for failing tests — a feature the community has wanted for years. gotestsum exists as a community workaround.

Filters to Add

go/test.tomlgo test -v / go test -v ./...

  • Skip: === RUN ... lines for passing tests, --- PASS: ... lines, t.Log output lines for passing tests, ok package summary lines when all pass
  • Keep:
    • --- FAIL: ... lines
    • === RUN header for the failing test
    • All output lines between a failing === RUN and its --- FAIL (error details, stack traces)
    • FAIL\tpackage/path lines
    • panic: lines
    • The final FAIL or ok summary

Consider section parsing: track === RUN as section open, --- PASS as discard-section, --- FAIL as keep-section.

go/test-race.tomlgo test -race

  • Same as go/test.toml but also keep data race detector output (WARNING: DATA RACE blocks)

Fixture Files Needed

  • tests/fixtures/go/test-all-pass.txt — verbose output with 50+ passing tests
  • tests/fixtures/go/test-failure.txt — mixed passing and failing tests, failures with assertion details
  • tests/fixtures/go/test-panic.txt — test that panics mid-execution

Acceptance Criteria

  • --- PASS and === RUN lines for passing tests removed
  • Failed test === RUN / --- FAIL lines and their captured output preserved
  • panic: output always preserved
  • Integration tests pass for all fixture files

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions