Skip to content

proposal: testing: add goroutine labels to tests #75047

@dfinkel

Description

@dfinkel

Proposal Details

Debugging tests timeouts can be frustrating when multiple tests fail to complete.

This was improved recently with the code that prints the set of tests that were still running, but that doesn't tell you which goroutines were associate with which test.

I propose adding one or two goroutine labels to all test invocations to make it easy to see which goroutine is for which test and make it easy to see which tests spawn a ton of goroutines.

Earlier today, I posted a CL to #23458 which would update runtime tracebacks (e.g. printed for recovered panics) to include goroutine labels in the status-line. (we can leave any discussion about where to put the labels on that bug)

My initial (straw-man) proposal for the labels:

  • a label with the key test and value of the full test-name (the same as from t.Name() (or f.Name() for fuzz tests)
  • a label with the key test_iter which is set for the second and later iterations of a test that's run with -count.

I don't feel strongly about either label-name, but including the test iteration makes it easy to see how far a test got before timing out. However, omitting the iteration on the iteration number on the first run eliminates visual noise in the common-case.

They need a little work, but, https://go.dev/cl/696117 and https://go.dev/cl/696595 would implement this proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions