Skip to content

Commit

Permalink
test/integration/goDebug: verify goroutines running before switch
Browse files Browse the repository at this point in the history
The test to make sure switch goroutines works by stepping between
two different goroutines. However, it was possible that when the
breakpoint in one goroutine was hit, the other had not started
running, so we were unable to get the threadID. This change sets
a breakpoint in each goroutine, to ensure that both are in the
appropriate functions before starting the tests.

Change-Id: I157a7d73a83722545db0878892e61079915043c8
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/313530
Trust: Suzy Mueller <[email protected]>
Run-TryBot: Suzy Mueller <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
TryBot-Result: kokoro <[email protected]>
  • Loading branch information
suzmue committed Apr 26, 2021
1 parent 5e9eef4 commit 78b5f53
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/integration/goDebug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,8 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {
async function runSwitchGoroutineTest(stepFunction: string) {
const PROGRAM = path.join(DATA_ROOT, 'goroutineTest');
const FILE = path.join(PROGRAM, 'main.go');
const BREAKPOINT_LINE = 14;
const BREAKPOINT_LINE_MAIN_RUN1 = 6;
const BREAKPOINT_LINE_MAIN_RUN2 = 14;

const config = {
name: 'Launch',
Expand All @@ -1577,13 +1578,24 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {
program: PROGRAM
};
const debugConfig = await initializeDebugConfig(config);
await dc.hitBreakpoint(debugConfig, getBreakpointLocation(FILE, BREAKPOINT_LINE));
// Clear breakpoints to make sure they do not interrupt the stepping.
await dc.hitBreakpoint(debugConfig, getBreakpointLocation(FILE, BREAKPOINT_LINE_MAIN_RUN1));

// Set a breakpoint in run 2. By setting breakpoints in both goroutine, we can make sure that both goroutines
// are running before continuing.
const bp2 = getBreakpointLocation(FILE, BREAKPOINT_LINE_MAIN_RUN2);
const breakpointsResult = await dc.setBreakpointsRequest({
source: { path: bp2.path },
breakpoints: [{ line: bp2.line }]
});
assert.ok(breakpointsResult.success);
await Promise.all([dc.continueRequest({ threadId: 1 }), dc.assertStoppedLocation('breakpoint', bp2)]);

// Clear breakpoints to make sure they do not interrupt the stepping.
const clearBreakpointsResult = await dc.setBreakpointsRequest({
source: { path: FILE },
breakpoints: []
});
assert.ok(breakpointsResult.success);
assert.ok(clearBreakpointsResult.success);

const threadsResponse = await dc.threadsRequest();
assert.ok(threadsResponse.success);
Expand Down

0 comments on commit 78b5f53

Please sign in to comment.