Skip to content

Commit 41c5ee9

Browse files
committed
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 #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]>
1 parent 50efa73 commit 41c5ee9

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

test/integration/goDebug.test.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -783,23 +783,13 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {
783783

784784
async function waitForHelloGoodbyeOutput(dc: DebugClient): Promise<DebugProtocol.Event> {
785785
return await new Promise<DebugProtocol.Event>((resolve, reject) => {
786-
const listen = () => {
787-
dc.waitForEvent('output', 5_000)
788-
.then((event) => {
789-
// Run listen again to make sure we can get the next events.
790-
listen();
791-
if (event.body.output === 'Hello, World!\n' || event.body.output === 'Goodbye, World.\n') {
792-
// Resolve when we have found the event that we want.
793-
resolve(event);
794-
return;
795-
}
796-
})
797-
.catch((reason) => reject(reason));
798-
};
799-
// Start listening for an output event. Especially because
800-
// logging is enabled in dlv-dap, there are many output events, and it is
801-
// possible to miss them if we are not prepared to handle them.
802-
listen();
786+
dc.on('output', (event) => {
787+
if (event.body.output === 'Hello, World!\n' || event.body.output === 'Goodbye, World.\n') {
788+
// Resolve when we have found the event that we want.
789+
resolve(event);
790+
return;
791+
}
792+
});
803793
});
804794
}
805795

0 commit comments

Comments
 (0)