Skip to content

testing: failure messages should be easier to find #47080

@rogpeppe

Description

@rogpeppe
$ go version
go version devel go1.17-dc00dc6c6b Thu Jun 10 12:41:37 2021 +0000 linux/amd64

I've spent a lot of time poring over CI test output trying to find exactly why a given test has failed.
Often the output of a high level test includes info-level logs that may end up very useful to determine
the cause of failure but are just noise when looking for the actual failure message.

There is currently no easy way to distinguish between info-level and error-level messages which makes
it hard to find the actual cause of a given failure. Often I end up editing the test output and excluding
all lines that match some regular expression, ending up with a smaller number of candidate lines which
include the culprit I'm searching for.

This is made harder by the fact that some failure messages are generated by calling T.Log and then
T.Fail so it's not necessarily clear that the logged message represents a failure.

Perhaps we could include an extra action type in the JSON test output that represents a call to T.Fail or T.FailNow; for example:

{"Time":"2021-07-05T12:16:14.184591685Z","Action":"fail","Package":"example.com/foo","Test":"TestFoo"}

Perhaps the line we could also include a stack trace of the failure, making it easier for tooling to point directly to the offending code.

This doesn't help with regular non-JSON test output, but that's perhaps hard to fix without breaking people's expected test messages, though we could add a flag to enable an explicit "test failed here" output line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions