Skip to content

Conversation

@KoheiMatsuno99
Copy link
Contributor

Summary

This PR adds a new -fail-only flag that filters tparse output to show only failed tests and packages.

Motivation

Closes #90

Example

With failures (filtered output)

  tparse % go test -json ./tests | go run main.go -fail-only
  ╭────────┬─────────┬───────────────────────────────────┬──────────────────────────────────╮
  │ Status │ Elapsed │               Test                │             Package              │
  ├────────┼─────────┼───────────────────────────────────┼──────────────────────────────────┤
  │  FAIL  │  0.01   │ TestFollow                        │ github.com/mfridman/tparse/tests │
  │  FAIL  │  0.01   │ TestFollow/follow_verbose         │ github.com/mfridman/tparse/tests │
  │  FAIL  │  0.00   │ TestFollow/follow_verbose/test_06 │ github.com/mfridman/tparse/tests │
  ╰────────┴─────────┴───────────────────────────────────┴──────────────────────────────────╯
  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
  ┃   FAIL  package: github.com/mfridman/tparse/tests   ┃
  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

  --- FAIL: TestFollow (0.01s)
  --- FAIL: TestFollow/follow_verbose (0.01s)
  --- FAIL: TestFollow/follow_verbose/test_06 (0.00s)

      follow_test.go:52:
                  Error Trace:    /Users/koheimatsuno/tparse/tests/follow_test.go:52
                  Error:          Not equal:
                                  expected: 2
                                  actual  : 1
                  Test:           TestFollow/follow_verbose/test_06

  ╭────────┬─────────┬──────────────────────────────────┬───────┬──────┬──────┬──────╮
  │ Status │ Elapsed │             Package              │ Cover │ Pass │ Fail │ Skip │
  ├────────┼─────────┼──────────────────────────────────┼───────┼──────┼──────┼──────┤
  │  FAIL  │  0.27s  │ github.com/mfridman/tparse/tests │  --   │ 142  │  3   │  0   │
  ╰────────┴─────────┴──────────────────────────────────┴───────┴──────┴──────┴──────╯
  exit status 1

Flag precedence warning

  • When -fail-only is combined with -pass, -skip, or -all, it takes precedence and shows a warning.
  • This design choice reflects the explicit user intent: if someone specifies -fail-only, they want to see only failures regardless of other flags.
  tparse % go test -json ./tests | go run main.go -fail-only -all
  warning: -fail-only takes precedence over -pass, -skip, and -all flags
  ╭────────┬─────────┬───────────────────────────────────┬──────────────────────────────────╮
  │ Status │ Elapsed │               Test                │             Package              │
  ├────────┼─────────┼───────────────────────────────────┼──────────────────────────────────┤
  │  FAIL  │  0.01   │ TestFollow                        │ github.com/mfridman/tparse/tests │
  │  FAIL  │  0.01   │ TestFollow/follow_verbose         │ github.com/mfridman/tparse/tests │
  │  FAIL  │  0.00   │ TestFollow/follow_verbose/test_06 │ github.com/mfridman/tparse/tests │
  ╰────────┴─────────┴───────────────────────────────────┴──────────────────────────────────╯
  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
  ┃   FAIL  package: github.com/mfridman/tparse/tests   ┃
  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

  --- FAIL: TestFollow (0.01s)
  --- FAIL: TestFollow/follow_verbose (0.01s)
  --- FAIL: TestFollow/follow_verbose/test_06 (0.00s)

      follow_test.go:52:
                  Error Trace:    /Users/koheimatsuno/tparse/tests/follow_test.go:52
                  Error:          Not equal:
                                  expected: 2
                                  actual  : 1
                  Test:           TestFollow/follow_verbose/test_06

  ╭────────┬─────────┬──────────────────────────────────┬───────┬──────┬──────┬──────╮
  │ Status │ Elapsed │             Package              │ Cover │ Pass │ Fail │ Skip │
  ├────────┼─────────┼──────────────────────────────────┼───────┼──────┼──────┼──────┤
  │  FAIL  │  0.27s  │ github.com/mfridman/tparse/tests │  --   │ 142  │  3   │  0   │
  ╰────────┴─────────┴──────────────────────────────────┴───────┴──────┴──────┴──────╯
  exit status 1

All tests passing

  tparse % go test -json ./tests | go run main.go -fail-only
  No tests failed.

Testing

Added TestFailOnly with golden file tests covering:

  • Mixed success/failure scenario (shows only failures)
  • All tests passing scenario (shows "No tests failed.")

@KoheiMatsuno99 KoheiMatsuno99 marked this pull request as draft November 16, 2025 11:37
@KoheiMatsuno99 KoheiMatsuno99 marked this pull request as ready for review November 16, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to not show summary

1 participant