mfridman / tparse

CLI tool for summarizing go test output. Pipe friendly. CI/CD friendly.
MIT License
948 stars 22 forks source link

Add partial `-progress` implementation #95

Closed mfridman closed 1 year ago

mfridman commented 1 year ago

This PR adds a -progress flag, which enables printing Package-level summary output as tests are still running.

For example, the PASS|FAIL|SKIP lines are printed as soon as the package tests are finished. This is useful for long-running test suites with a lot of output where -progress is too noisy.

$ go test ./... -json | tparse -progress
[PASS]      0.200s      github.com/pressly/goose/v4/internal/migrationstats
[FAIL]      0.362s      github.com/pressly/goose/v4/internal/sqlparser
[SKIP]      0.412s      github.com/pressly/goose/v4/pkg/source [no tests to run]
[PASS]     22.866s      github.com/pressly/goose/v4
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃   FAIL  package: github.com/pressly/goose/v4/internal/sqlparser   ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

--- FAIL: TestSemicolons (0.00s)

    parser_test.go:43: incorrect semicolon. got true, want false

┌───────────────────────────────────────────────────────────────────────────────────────────────────────┐
│  STATUS │ ELAPSED │                       PACKAGE                       │ COVER │ PASS │ FAIL │ SKIP  │
│─────────┼─────────┼─────────────────────────────────────────────────────┼───────┼──────┼──────┼───────│
│  PASS   │ 22.87s  │ github.com/pressly/goose/v4                         │  --   │  18  │  0   │  0    │
│  PASS   │  0.20s  │ github.com/pressly/goose/v4/internal/migrationstats │  --   │  10  │  0   │  0    │
│  FAIL   │  0.36s  │ github.com/pressly/goose/v4/internal/sqlparser      │  --   │  11  │  1   │  0    │
└───────────────────────────────────────────────────────────────────────────────────────────────────────┘
mfridman commented 1 year ago

Going to merge this as-is, but would be nice to get color support. I don't love the output, but will wait for feedback:

[PASS]       0.51s      github.com/pressly/goose/v4/internal/migrationstats
[PASS]       0.68s      github.com/pressly/goose/v4/internal/sqlparser
[FAIL]       2.82s      github.com/pressly/goose/v4
[FAIL]       0.46s      github.com/pressly/goose/v4/tests/e2e/clickhouse
[FAIL]       0.67s      github.com/pressly/goose/v4/tests/e2e/mysql
[FAIL]       0.56s      github.com/pressly/goose/v4/tests/e2e/postgres
[FAIL]       0.78s      github.com/pressly/goose/v4/tests/e2e/vertica
[FAIL]       1.01s      github.com/pressly/goose/v4/tests/gomigrations/error
[FAIL]       1.04s      github.com/pressly/goose/v4/tests/gomigrations/success
ti-mo commented 1 year ago

Thanks! A touch of color in pass/fail/skip would be nice, yes. :+1: