From 8841b2dfc8ef3f80a5feee1848a5c053de8ad75d Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Wed, 3 Sep 2025 10:51:01 -0500 Subject: [PATCH] dap: ensure test client is closed on cleanup The dap test wasn't waiting for the client's goroutines to complete before exiting which caused a race condition that could cause it to log to the dead test logger. This became apparent when `--count` of greater than one was used since it caused the test to run long enough to trigger the behavior. It would have also triggered if we had added more tests. Add the client close to the cleanup so it waits for the goroutine to finish before the test exits as it was properly supposed to do. Signed-off-by: Jonathan A. Sternberg --- dap/adapter_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dap/adapter_test.go b/dap/adapter_test.go index e732b932a..1017849c1 100644 --- a/dap/adapter_test.go +++ b/dap/adapter_test.go @@ -14,8 +14,6 @@ import ( ) func TestLaunch(t *testing.T) { - t.Skip("test fails with errgroup v0.16.0, that doesn't swallow panic in goroutine") - adapter, conn, client := NewTestAdapter[common.Config](t) ctx, cancel := context.WithTimeoutCause(context.Background(), 10*time.Second, context.DeadlineExceeded) @@ -83,14 +81,14 @@ func NewTestAdapter[C LaunchConfig](t *testing.T) (*Adapter[C], Conn, *Client) { }) clientConn := logConn(t, "client", NewConn(rd2, wr1)) - t.Cleanup(func() { - clientConn.Close() - }) + t.Cleanup(func() { clientConn.Close() }) adapter := New[C]() t.Cleanup(func() { adapter.Stop() }) client := NewClient(clientConn) + t.Cleanup(func() { client.Close() }) + return adapter, srvConn, client }