From 5fa4a3527c4fbc13657f630cc082f792fa3e54d1 Mon Sep 17 00:00:00 2001 From: Suzy Mueller Date: Sat, 15 May 2021 01:34:59 -0400 Subject: [PATCH] service/dap: fix flaky TestPreSetBreakpoint test (#2483) --- service/dap/server_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/service/dap/server_test.go b/service/dap/server_test.go index 063673e3..4dec14af 100644 --- a/service/dap/server_test.go +++ b/service/dap/server_test.go @@ -502,8 +502,12 @@ func TestPreSetBreakpoint(t *testing.T) { msg := client.ExpectMessage(t) switch m := msg.(type) { case *dap.ThreadsResponse: - if len(m.Body.Threads) != 1 || m.Body.Threads[0].Id != -1 || m.Body.Threads[0].Name != "Current" { - t.Errorf("\ngot %#v\nwant Id=-1, Name=\"Current\"", m.Body.Threads) + // If the thread request arrived while the program was running, we expect to get the dummy response + // with a single goroutine "Current". + // If the thread request arrived after the stop, we should get the goroutine stopped at main.Increment. + if (len(m.Body.Threads) != 1 || m.Body.Threads[0].Id != -1 || m.Body.Threads[0].Name != "Current") && + (len(m.Body.Threads) < 1 || m.Body.Threads[0].Id != 1 || !strings.HasPrefix(m.Body.Threads[0].Name, "* [Go 1] main.Increment")) { + t.Errorf("\ngot %#v\nwant Id=-1, Name=\"Current\" or Id=1, Name=\"* [Go 1] main.Increment ...\"", m.Body.Threads) } case *dap.StoppedEvent: if m.Body.Reason != "breakpoint" || m.Body.ThreadId != 1 || !m.Body.AllThreadsStopped { -- GitLab