From bcc5a1f51bdefcfe0acd2bc6c9f85026d6eac09a Mon Sep 17 00:00:00 2001 From: Suzy Mueller Date: Tue, 11 May 2021 10:56:58 -0400 Subject: [PATCH] [release] test/integration/goDebug.test.ts: use dc.on to wait for output event dc.on calls the listener for every output event. This should fix the flakiness of the cwd tests. Updates golang/vscode-go#1439 Change-Id: I5a44708dc294561408335b3f8baff5cd1b63461a Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/318810 Trust: Suzy Mueller Run-TryBot: Suzy Mueller TryBot-Result: kokoro Reviewed-by: Hyang-Ah Hana Kim (cherry picked from commit 41c5ee930c78692d69ec084b38fd7507a72cfe9a) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/318892 --- test/integration/goDebug.test.ts | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts index 73b9b5f423..5ef2e2d0e7 100644 --- a/test/integration/goDebug.test.ts +++ b/test/integration/goDebug.test.ts @@ -783,23 +783,13 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => { async function waitForHelloGoodbyeOutput(dc: DebugClient): Promise { return await new Promise((resolve, reject) => { - const listen = () => { - dc.waitForEvent('output', 5_000) - .then((event) => { - // Run listen again to make sure we can get the next events. - listen(); - if (event.body.output === 'Hello, World!\n' || event.body.output === 'Goodbye, World.\n') { - // Resolve when we have found the event that we want. - resolve(event); - return; - } - }) - .catch((reason) => reject(reason)); - }; - // Start listening for an output event. Especially because - // logging is enabled in dlv-dap, there are many output events, and it is - // possible to miss them if we are not prepared to handle them. - listen(); + dc.on('output', (event) => { + if (event.body.output === 'Hello, World!\n' || event.body.output === 'Goodbye, World.\n') { + // Resolve when we have found the event that we want. + resolve(event); + return; + } + }); }); }