test/goDebug.test.ts: terminate running dlv process after each test

Since dlv dap is running as a server, calling dc.stop() does not
kill the running process. This change makes sure to get rid of the
running server after each test since it is not being reused.

Change-Id: Iaff8d649e8f483a9faf6a7222cbe2f670aadf5b0
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/303236
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts
index 0157c71..ddff37c 100644
--- a/test/integration/goDebug.test.ts
+++ b/test/integration/goDebug.test.ts
@@ -295,6 +295,7 @@
 	const dlvDapSkipsEnabled = true;
 	const debugConfigProvider = new GoDebugConfigurationProvider();
 	const DEBUG_ADAPTER = path.join('.', 'out', 'src', 'debugAdapter', 'goDebug.js');
+	let dlvDapProcess: cp.ChildProcess;
 
 	const PROJECT_ROOT = path.normalize(path.join(__dirname, '..', '..', '..'));
 	const DATA_ROOT = path.join(PROJECT_ROOT, 'test', 'testdata');
@@ -333,6 +334,10 @@
 
 	teardown(async () => {
 		await dc.stop();
+		if (dlvDapProcess) {
+			await killProcessTree(dlvDapProcess);
+			dlvDapProcess = null;
+		}
 		sinon.restore();
 	});
 
@@ -1687,7 +1692,8 @@
 
 		const debugConfig = await debugConfigProvider.resolveDebugConfiguration(undefined, config);
 		if (isDlvDap) {
-			const { port } = await startDapServer(debugConfig);
+			const { port, dlvDapServer } = await startDapServer(debugConfig);
+			dlvDapProcess = dlvDapServer;
 			await dc.start(port);
 		}
 		return debugConfig;