You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
adonovan opened this issue
Mar 10, 2025
· 3 comments
Labels
BugReportIssues describing a possible bug in the Go implementation.goplsIssues related to the Go language server, gopls.ToolsThis label describes issues relating to any tools in the x/tools repository.
A test ends when its Test function returns or calls any of the methods FailNow, Fatal, Fatalf, SkipNow, Skip, or Skipf. Those methods, as well as the Parallel method, must be called only from the goroutine running the Test function.
However, this precondition is violated by gopls' integration test framework. The integration.Env captures the root testing.T, and uses it for many assertions (calls to t.Fatal) performed by the Env itself. But it is common for integration tests to create new subtests using t.Run and then call methods of Env that call Env.T.Fatal.
I don't know whether this is a real problem--perhaps the testing package must already be robust to this kind of misuse--but it does result in the testing package emitting messages like this one:
testing.go:1682: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test
I wonder whether this is something we need to be more careful about.
The text was updated successfully, but these errors were encountered:
gopherbot
added
Tools
This label describes issues relating to any tools in the x/tools repository.
gopls
Issues related to the Go language server, gopls.
labels
Mar 10, 2025
This is, of course, why you're not supposed to close over testing.T. I think it would be reasonable to revert this decision: yes all helpers would have to accept a T, but especially with most new tests being marker tests, that's probably fine.
all helpers would have to accept a T, but especially with most new tests being marker tests, that's probably fine.
I agree that would be a reasonable fix. I'm still not sure this is actually a problem in practice. (While studying the crash in the log above, I thought at first it might be relevant, but I'm not so sure now.)
BugReportIssues describing a possible bug in the Go implementation.goplsIssues related to the Go language server, gopls.ToolsThis label describes issues relating to any tools in the x/tools repository.
The documentation of testing.T says:
However, this precondition is violated by gopls' integration test framework. The
integration.Env
captures the root testing.T, and uses it for many assertions (calls to t.Fatal) performed by the Env itself. But it is common for integration tests to create new subtests using t.Run and then call methods of Env that call Env.T.Fatal.I don't know whether this is a real problem--perhaps the testing package must already be robust to this kind of misuse--but it does result in the testing package emitting messages like this one:
(source: https://logs.chromium.org/logs/golang/buildbucket/cr-buildbucket/8720772441964325377/+/u/step/22/log/2)
I wonder whether this is something we need to be more careful about.
The text was updated successfully, but these errors were encountered: