internal/lsp/regtest: increase the time allowed for shutdown

Now that we await ongoing work during shutdown, we are seeing regtest
flakes simply due to outstanding go command invocations.

Allow more time for cleanup. If this is insufficient, we can be more
aggressive about terminating go command processes when context is
cancelled.

For golang/go#53820

Change-Id: I3df3c5510dae34cb14a6efeb02c2963a71e64f3a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/417583
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dylan Le <dungtuanle@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Findley 2022-07-15 11:11:52 -04:00
parent 32129bf2c9
commit ce6ce76626
1 changed files with 6 additions and 2 deletions

View File

@ -341,9 +341,13 @@ func (r *Runner) Run(t *testing.T, files string, test TestFunc, opts ...RunOptio
}
// For tests that failed due to a timeout, don't fail to shutdown
// because ctx is done.
closeCtx, cancel := context.WithTimeout(xcontext.Detach(ctx), 5*time.Second)
//
// golang/go#53820: now that we await the completion of ongoing work in
// shutdown, we must allow a significant amount of time for ongoing go
// command invocations to exit.
ctx, cancel := context.WithTimeout(xcontext.Detach(ctx), 30*time.Second)
defer cancel()
if err := env.Editor.Close(closeCtx); err != nil {
if err := env.Editor.Close(ctx); err != nil {
pprof.Lookup("goroutine").WriteTo(os.Stderr, 1)
t.Errorf("closing editor: %v", err)
}