GoTestTools / gotestfmt

go test output for humans
The Unlicense
515 stars 9 forks source link

gotestfmt should work without -v #2

Closed Holek closed 3 years ago

Holek commented 3 years ago

When parser encounters output from github.com/stretchr/testify/assert, it panics with:

panic: unexpected output after fail event:         extract_usage_test.go:188:

goroutine 7 [running]:
github.com/haveyoudebuggedit/gotestfmt/parser.parse(0xc00001e4e0, 0xc00001e540, 0xc00001e5a0, 0xc00001e600)
        /home/runner/go/pkg/mod/github.com/haveyoudebuggedit/gotestfmt@v1.0.1/parser/parse.go:169 +0x1397
created by github.com/haveyoudebuggedit/gotestfmt/parser.Parse
        /home/runner/go/pkg/mod/github.com/haveyoudebuggedit/gotestfmt@v1.0.1/parser/parse.go:21 +0xca

Example output from go test -coverprofile=tmp/c.out ./...:

?       github.com/xxx/service/packages/manager [no test files]
ok      github.com/xxx/service/packages/notes   0.030s  coverage: 11.0% of statements
ok      github.com/xxx/service/packages/notifications   0.597s  coverage: 78.9% of statements
ok      github.com/xxx/service/packages/profiles    0.088s  coverage: 21.9% of statements
ok      github.com/xxx/service/packages/push_notifications  0.024s  coverage: 62.5% of statements
ok      github.com/xxx/service/packages/reports 0.098s  coverage: 62.3% of statements
--- FAIL: TestExtractUsageTestSuite (0.29s)
    --- FAIL: TestExtractUsageTestSuite/TestGetActiveUsers_CreatesReports (0.10s)
        extract_usage_test.go:188: 
                Error Trace:    extract_usage_test.go:188
                Error:          Not equal: 
                                expected: 20
                                actual  : 34
                Test:           TestExtractUsageTestSuite/TestGetActiveUsers_CreatesReports
    --- FAIL: TestExtractUsageTestSuite/TestGetGenderAndAge_CreatesReports (0.10s)
        extract_usage_test.go:258: 
                Error Trace:    extract_usage_test.go:258
                Error:          Not equal: 
                                expected: 40
                                actual  : 58
                Test:           TestExtractUsageTestSuite/TestGetGenderAndAge_CreatesReports
    --- FAIL: TestExtractUsageTestSuite/TestGetNumberOfUsers_CreatesReports (0.09s)
        extract_usage_test.go:124: 
                Error Trace:    extract_usage_test.go:124
                Error:          Not equal: 
                                expected: 20
                                actual  : 50
                Test:           TestExtractUsageTestSuite/TestGetNumberOfUsers_CreatesReports
FAIL
coverage: 78.5% of statements
FAIL    github.com/xxx/service/packages/reports/etl 0.309s
?       github.com/xxx/service/packages/roles   [no test files]
FAIL
ghost commented 3 years ago

Hey @Holek thank you very much for reporting this.

I'm trying to narrow down why this is happening, could you please try to run this again with go test -v ./... | gotestfmt? The -v might make the difference in my parsing.

ghost commented 3 years ago

@Holek I managed to track it down: without the -v parameter the parser is missing the === RUN line. If you add -v it should work. Nevertheless, I think this should be fixed for less verbose output. You may also be interested in #1 which contains a description on how to add a less verbose output until this gets fixed.

Holek commented 3 years ago

Nice! I've managed to fix this in my project by using -v flag. Looks good now! Thanks for a quick response and for work on #3 :)

ghost commented 3 years ago

Thanks, @Holek ! I'll add support for running without -v so people have an easier time to make the output less verbose.

ghost commented 3 years ago

Hey @Holek, could you please try to use the binaries from this build? They should work without -v now. https://github.com/haveyoudebuggedit/gotestfmt/actions/runs/1448047829