Skip to content

Commit 3b3fffa

Browse files
committed
gopls/internal/cmd: fix directory cleanup issue in flaky test
The gopls command uses a temporary directory to run. We need to kill the gopls process before the test finishes so that the testing framework can clean up the temp directory. The call to goplsCmd.Kill() is asynchronous, so this might be causing a race condition where the testing framework attempts to cleanup the directory before the gopls process has been killed. Adding a call to cmd.Wait() should fix this. For golang/go#74257 Change-Id: I5334fced0eec402dbccf25164d7ddfda950737e6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/683695 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent f28cf99 commit 3b3fffa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

gopls/internal/cmd/mcp_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ func MyFun() {}
182182
t.Fatalf("killing gopls: %v", err)
183183
}
184184
}
185+
// Wait for the gopls process to exit before we return and the test framework
186+
// attempts to clean up the temporary directory.
187+
// We expect an error because we killed the process.
188+
goplsCmd.Wait()
185189
}
186190

187191
// getRandomPort returns the number of a random available port. Inherently racy:

0 commit comments

Comments
 (0)