Skip to content

proposal: testing: add goroutine labels to tests #75047

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.

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.name and value of the full test-name (the same as from t.Name() (or f.Name() for fuzz tests, and b.Name() for benchmarks)
  • a label with the key test.iter which is set for the second and later iterations of a test that's run with -count.
  • a label with the key bench.name for benchmarks (including sub-benchmarks)
  • a label with the key bench.run.iter for benchmarks with later calls (from -count as well)
  • a label with the key fuzz.name as the only label for direct fuzz tests (-fuzz FuzzFoo)
  • a label with the key fuzz.corpus.name for fuzz tests run as normal tests based on corpus (both seed and testdata)
  • a label with the key fuzz.corpus.iter for later corpus fuzz test iterations (-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.

https://go.dev/cl/740301 and https://go.dev/cl/740320 would implement this proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions