Skip to content

Commit

Permalink
[release] test/integration/goDebug.test.ts: use dc.on to wait for out…
Browse files Browse the repository at this point in the history
…put event

dc.on calls the listener for every output event. This should fix the
flakiness of the cwd tests.

Updates golang#1439

Change-Id: I5a44708dc294561408335b3f8baff5cd1b63461a
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/318810
Trust: Suzy Mueller <[email protected]>
Run-TryBot: Suzy Mueller <[email protected]>
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
(cherry picked from commit 41c5ee9)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/318892
  • Loading branch information
suzmue committed May 11, 2021
1 parent e8b1ba5 commit bcc5a1f
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions test/integration/goDebug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,23 +783,13 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {

async function waitForHelloGoodbyeOutput(dc: DebugClient): Promise<DebugProtocol.Event> {
return await new Promise<DebugProtocol.Event>((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;
}
});
});
}

Expand Down

0 comments on commit bcc5a1f

Please sign in to comment.