test/integration/goDebug: enable set breakpoints while running tests

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 <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts
index 3fdaa65..89a48cd 100644
--- a/test/integration/goDebug.test.ts
+++ b/test/integration/goDebug.test.ts
@@ -1031,8 +1031,8 @@
 			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.
 			}
 
@@ -1062,6 +1062,82 @@
 			]);
 		});
 
+		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');
 
@@ -1107,9 +1183,9 @@
 			]);
 		}
 
-		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 });
@@ -1117,9 +1193,9 @@
 			});
 		});
 
-		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 () => {