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.
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:
test.nameand value of the full test-name (the same as fromt.Name()(orf.Name()for fuzz tests, andb.Name()for benchmarks)test.iterwhich is set for the second and later iterations of a test that's run with-count.bench.namefor benchmarks (including sub-benchmarks)bench.run.iterfor benchmarks with later calls (from-countas well)fuzz.nameas the only label for direct fuzz tests (-fuzz FuzzFoo)fuzz.corpus.namefor fuzz tests run as normal tests based on corpus (both seed and testdata)fuzz.corpus.iterfor 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.