test: copy files recursively instead of hardcoding

There are still a few more special test cases that need to be copied
directly, but those tests should probably be restructured. This is a
good starting point though.

Change-Id: I88b9e36035bde4fcf62d9593ee085901db4989b3
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/235497
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/goModules.ts b/src/goModules.ts
index a9b644e..1714066 100644
--- a/src/goModules.ts
+++ b/src/goModules.ts
@@ -65,7 +65,6 @@
 		logModuleUsage();
 		goModEnvResult = path.dirname(goModEnvResult);
 		const goConfig = getGoConfig(fileuri);
-		let promptFormatTool = goConfig['formatTool'] === 'goreturns';
 
 		if (goConfig['inferGopath'] === true) {
 			goConfig.update('inferGopath', false, vscode.ConfigurationTarget.WorkspaceFolder);
@@ -73,20 +72,18 @@
 				'The "inferGopath" setting is disabled for this workspace because Go modules are being used.'
 			);
 		}
+
+		// TODO(rstambler): This will offer multiple prompts to the user, but
+		// it's still better than waiting for user input. Ideally, this should
+		// be combined into one prompt.
 		if (goConfig['useLanguageServer'] === false) {
 			const promptMsg =
 				'For better performance using Go modules, you can try the experimental Go language server, gopls.';
-			const choseToUpdateLS = await promptToUpdateToolForModules('gopls', promptMsg, goConfig);
-			promptFormatTool = promptFormatTool && !choseToUpdateLS;
-		} else if (promptFormatTool) {
-			const languageServerExperimentalFeatures: any = goConfig.get('languageServerExperimentalFeatures');
-			promptFormatTool = languageServerExperimentalFeatures['format'] === false;
+			promptToUpdateToolForModules('gopls', promptMsg, goConfig);
 		}
-
-		if (promptFormatTool) {
-			const promptMsgForFormatTool =
-				'`goreturns` doesnt support auto-importing missing imports when using Go modules yet. Please update the "formatTool" setting to `goimports`.';
-			await promptToUpdateToolForModules('switchFormatToolToGoimports', promptMsgForFormatTool, goConfig);
+		if (goConfig['formatTool'] === 'goreturns') {
+			const promptMsgForFormatTool = `The goreturns tool does not support Go modules. Please update the "formatTool" setting to goimports.`;
+			promptToUpdateToolForModules('switchFormatToolToGoimports', promptMsgForFormatTool, goConfig);
 		}
 	}
 	packagePathToGoModPathMap[pkgPath] = goModEnvResult;
diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts
index 7b747d9..f0ed8a7 100644
--- a/test/integration/extension.test.ts
+++ b/test/integration/extension.test.ts
@@ -74,19 +74,17 @@
 		toolsGopath = getToolsGopath() || gopath;
 
 		fs.removeSync(repoPath);
-		fs.copySync(path.join(fixtureSourcePath, 'baseTest', 'test.go'), path.join(fixturePath, 'baseTest', 'test.go'));
-		fs.copySync(
-			path.join(fixtureSourcePath, 'baseTest', 'sample_test.go'),
-			path.join(fixturePath, 'baseTest', 'sample_test.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'errorsTest', 'errors.go'),
-			path.join(fixturePath, 'errorsTest', 'errors.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'gogetdocTestData', 'test.go'),
-			path.join(fixturePath, 'gogetdocTestData', 'test.go')
-		);
+		fs.copySync(fixtureSourcePath, fixturePath, {
+			recursive: true,
+			// All of the tests run in GOPATH mode for now.
+			// TODO(rstambler): Run tests in GOPATH and module mode.
+			filter: (src: string): boolean => {
+				if (path.basename(src) === 'go.mod') {
+					return false;
+				}
+				return true;
+			},
+		});
 		fs.copySync(
 			path.join(fixtureSourcePath, 'generatetests', 'generatetests.go'),
 			path.join(generateTestsSourcePath, 'generatetests.go')
@@ -115,82 +113,6 @@
 			path.join(fixtureSourcePath, 'diffTestData', 'file2.go'),
 			path.join(fixturePath, 'diffTest2Data', 'file2.go')
 		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'linterTest', 'linter_1.go'),
-			path.join(fixturePath, 'linterTest', 'linter_1.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'linterTest', 'linter_2.go'),
-			path.join(fixturePath, 'linterTest', 'linter_2.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'buildTags', 'hello.go'),
-			path.join(fixturePath, 'buildTags', 'hello.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'testTags', 'hello_test.go'),
-			path.join(fixturePath, 'testTags', 'hello_test.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'completions', 'unimportedPkgs.go'),
-			path.join(fixturePath, 'completions', 'unimportedPkgs.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'completions', 'unimportedMultiplePkgs.go'),
-			path.join(fixturePath, 'completions', 'unimportedMultiplePkgs.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'completions', 'snippets.go'),
-			path.join(fixturePath, 'completions', 'snippets.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'completions', 'nosnippets.go'),
-			path.join(fixturePath, 'completions', 'nosnippets.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'completions', 'exportedMemberDocs.go'),
-			path.join(fixturePath, 'completions', 'exportedMemberDocs.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'importTest', 'noimports.go'),
-			path.join(fixturePath, 'importTest', 'noimports.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'importTest', 'groupImports.go'),
-			path.join(fixturePath, 'importTest', 'groupImports.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'importTest', 'singleImports.go'),
-			path.join(fixturePath, 'importTest', 'singleImports.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'importTest', 'cgoImports.go'),
-			path.join(fixturePath, 'importTest', 'cgoImports.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'fillStruct', 'input_1.go'),
-			path.join(fixturePath, 'fillStruct', 'input_1.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'fillStruct', 'golden_1.go'),
-			path.join(fixturePath, 'fillStruct', 'golden_1.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'fillStruct', 'input_2.go'),
-			path.join(fixturePath, 'fillStruct', 'input_2.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'fillStruct', 'golden_2.go'),
-			path.join(fixturePath, 'fillStruct', 'golden_2.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'fillStruct', 'input_2.go'),
-			path.join(fixturePath, 'fillStruct', 'input_3.go')
-		);
-		fs.copySync(
-			path.join(fixtureSourcePath, 'outlineTest', 'test.go'),
-			path.join(fixturePath, 'outlineTest', 'test.go')
-		);
 	});
 
 	suiteTeardown(() => {