Skip to content

Commit

Permalink
test/integration/goDebug: enable set breakpoints while running tests
Browse files Browse the repository at this point in the history
These tests are working with dlv-dap at tip.

Change-Id: Idf811a7f3dd9c473bb86f8e1dd3201c11344ece6
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/332389
Trust: Suzy Mueller <[email protected]>
Run-TryBot: Suzy Mueller <[email protected]>
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
  • Loading branch information
suzmue committed Jul 2, 2021
1 parent c3516da commit 48418d4
Showing 1 changed file with 84 additions and 8 deletions.
92 changes: 84 additions & 8 deletions test/integration/goDebug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,8 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {
await new Promise((resolve) => setTimeout(resolve, 2_000));
});

test('should set breakpoints during continue', async function () {
if (isDlvDap && dlvDapSkipsEnabled) {
test('should set breakpoints during continue (legacy)', async function () {
if (isDlvDap) {
this.skip(); // not working in dlv-dap.
}

Expand Down Expand Up @@ -1062,6 +1062,82 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {
]);
});

async function setBreakpointsWhileRunning(resumeFunc: () => void) {
const PROGRAM = path.join(DATA_ROOT, 'sleep');

const FILE = path.join(DATA_ROOT, 'sleep', 'sleep.go');
const SLEEP_LINE = 11;
const setupBreakpoint = getBreakpointLocation(FILE, SLEEP_LINE);

const HELLO_LINE = 10;
const resumeBreakpoint = getBreakpointLocation(FILE, HELLO_LINE);

const config = {
name: 'Launch file',
type: 'go',
request: 'launch',
mode: 'debug',
program: PROGRAM
};
const debugConfig = await initializeDebugConfig(config);
await dc.hitBreakpoint(debugConfig, setupBreakpoint);

// The program is now stopped at the line containing time.Sleep().
// Issue a next request, followed by a setBreakpointsRequest.
resumeFunc();

// Note: the current behavior of setting a breakpoint during a next
// request will cause the step to be interrupted, so it may not be
// stopped on the next line.
await Promise.all([
dc.setBreakpointsRequest({
lines: [resumeBreakpoint.line],
breakpoints: [{ line: resumeBreakpoint.line, column: 0 }],
source: { path: resumeBreakpoint.path }
}),
dc.assertStoppedLocation('pause', {})
]);

// Once the 'step' has completed, continue the program and
// make sure the breakpoint set while the program was nexting
// is succesfully hit.
await Promise.all([
dc.continueRequest({ threadId: 1 }),
dc.assertStoppedLocation('breakpoint', resumeBreakpoint)
]);
}

test('should set breakpoints during continue', async function () {
if (!isDlvDap) {
this.skip();
}
await setBreakpointsWhileRunning(async () => {
const nextResponse = await dc.continueRequest({ threadId: 1 });
assert.ok(nextResponse.success);
});
});

test('should set breakpoints during next', async function () {
if (!isDlvDap) {
this.skip();
}
await setBreakpointsWhileRunning(async () => {
const nextResponse = await dc.nextRequest({ threadId: 1 });
assert.ok(nextResponse.success);
});
});

test('should set breakpoints during step out', async function () {
if (!isDlvDap) {
this.skip();
}

await setBreakpointsWhileRunning(async () => {
const stepOutResponse = await dc.stepOutRequest({ threadId: 1 });
assert.ok(stepOutResponse.success);
});
});

async function setBreakpointsDuringStep(nextFunc: () => void) {
const PROGRAM = path.join(DATA_ROOT, 'sleep');

Expand Down Expand Up @@ -1107,19 +1183,19 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {
]);
}

test('should set breakpoints during next', async function () {
if (isDlvDap && dlvDapSkipsEnabled) {
this.skip(); // Skipped due to github.com/golang/vscode-go/issues/1390
test('should set breakpoints during next (legacy)', async function () {
if (isDlvDap) {
this.skip();
}
await setBreakpointsDuringStep(async () => {
const nextResponse = await dc.nextRequest({ threadId: 1 });
assert.ok(nextResponse.success);
});
});

test('should set breakpoints during step out', async function () {
if (isDlvDap && dlvDapSkipsEnabled) {
this.skip(); // Skipped due to github.com/golang/vscode-go/issues/1390
test('should set breakpoints during step out (legacy)', async function () {
if (isDlvDap) {
this.skip();
}

await setBreakpointsDuringStep(async () => {
Expand Down

0 comments on commit 48418d4

Please sign in to comment.