extension/test/integration: update debug config for remote mode

CL 643280 changed the behavior of debug adapter in remote mode from
always "legacy" to the result from command
`dlv substitute-path-guess-helper`.

This CL calls the method to find the right return value and test the
debug adapter with the command return.

In master branch, the integration test is running against preview
version of extension, so the debug adapter is always "dlv-dap"
regardless of the command return. So this test is not captured
in the master branch.

Change-Id: I5ce6e1040fa16f10b038265d7e0ab7a884a99141
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/684475
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Madeline Kalil <mkalil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 09dcadacf0311d3b519c5a143cdfddb6b7c56359)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/684018
diff --git a/extension/src/goDebugConfiguration.ts b/extension/src/goDebugConfiguration.ts
index 94c7e12..243a4a2 100644
--- a/extension/src/goDebugConfiguration.ts
+++ b/extension/src/goDebugConfiguration.ts
@@ -387,9 +387,11 @@
 	/**
 	 * Calls `dlv substitute-path-guess-helper` to get a set of parameters used by Delve to guess the substitutePath configuration after also examining the executable.
 	 *
+	 * Exported for testing.
+	 *
 	 * See https://github.com/go-delve/delve/blob/d5fb3bee427202f0d4b1683bf743bfd2adb41757/service/debugger/debugger.go#L2466
 	 */
-	private async guessSubstitutePath(): Promise<object | null> {
+	public async guessSubstitutePath(): Promise<object | null> {
 		return new Promise((resolve) => {
 			const child = spawn(getBinPath('dlv'), ['substitute-path-guess-helper']);
 			let stdoutData = '';
diff --git a/extension/test/integration/goDebugConfiguration.test.ts b/extension/test/integration/goDebugConfiguration.test.ts
index 877e72c..6141764 100644
--- a/extension/test/integration/goDebugConfiguration.test.ts
+++ b/extension/test/integration/goDebugConfiguration.test.ts
@@ -979,7 +979,7 @@
 		assert.strictEqual(resolvedConfig['debugAdapter'], 'dlv-dap');
 	});
 
-	test("default debugAdapter for remote mode should be 'legacy' when not in Preview mode", async () => {
+	test('default debugAdapter for remote mode should be determined by `dlv substitute-path-guess-helper`', async () => {
 		const config = {
 			name: 'Attach',
 			type: 'go',
@@ -989,9 +989,14 @@
 			cwd: '/path'
 		};
 
-		const want = extensionInfo.isPreview ? 'dlv-dap' : 'legacy';
 		await debugConfigProvider.resolveDebugConfiguration(undefined, config);
 		const resolvedConfig = config as any;
+
+		const substitutePathGuess = await debugConfigProvider.guessSubstitutePath();
+		let want = 'dlv-dap';
+		if (substitutePathGuess === null) {
+			want = 'legacy';
+		}
 		assert.strictEqual(resolvedConfig['debugAdapter'], want);
 	});