test/integration: apply the right EOL char sequence

On windows, editors use \r\n as the default EOL character sequence,
so any tests that compare the results against expected string results
formulated with LF end of line will fail. Detect the EOL sequence
from document, and use it to compute the expected result.

Fixes imports tests.

There are still other tests failing on windows.

Updates golang/vscode-go#239

Change-Id: Ic54fbf8f777c811bf573edfc46f50ccb695ec871
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/242880
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts
index 5c2e0fe..d168983 100644
--- a/test/integration/extension.test.ts
+++ b/test/integration/extension.test.ts
@@ -1445,12 +1445,19 @@
 		assert.equal(result4, false);
 	});
 
+	function fixEOL(eol: vscode.EndOfLine, strWithLF: string): string {
+		if (eol === vscode.EndOfLine.LF) {
+			return strWithLF;
+		}
+		return strWithLF.split('\n').join('\r\n');  // replaceAll.
+	}
+
 	test('Add imports when no imports', async () => {
 		const uri = vscode.Uri.file(path.join(fixturePath, 'importTest', 'noimports.go'));
 		const document = await vscode.workspace.openTextDocument(uri);
 		await vscode.window.showTextDocument(document);
 
-		const expectedText = document.getText() + '\n' + 'import (\n\t"bytes"\n)\n';
+		const expectedText = document.getText() + fixEOL(document.eol, '\n' + 'import (\n\t"bytes"\n)\n');
 		const edits = getTextEditForAddImport('bytes');
 		const edit = new vscode.WorkspaceEdit();
 		edit.set(document.uri, edits);
@@ -1467,8 +1474,11 @@
 		const uri = vscode.Uri.file(path.join(fixturePath, 'importTest', 'groupImports.go'));
 		const document = await vscode.workspace.openTextDocument(uri);
 		await vscode.window.showTextDocument(document);
+		const eol = document.eol;
 
-		const expectedText = document.getText().replace('\t"fmt"\n\t"math"', '\t"bytes"\n\t"fmt"\n\t"math"');
+		const expectedText = document.getText().replace(
+			fixEOL(eol, '\t"fmt"\n\t"math"'),
+			fixEOL(eol, '\t"bytes"\n\t"fmt"\n\t"math"'));
 		const edits = getTextEditForAddImport('bytes');
 		const edit = new vscode.WorkspaceEdit();
 		edit.set(document.uri, edits);
@@ -1480,12 +1490,13 @@
 		const uri = vscode.Uri.file(path.join(fixturePath, 'importTest', 'singleImports.go'));
 		const document = await vscode.workspace.openTextDocument(uri);
 		await vscode.window.showTextDocument(document);
+		const eol = document.eol;
 
 		const expectedText = document
 			.getText()
 			.replace(
-				'import "fmt"\nimport . "math" // comment',
-				'import (\n\t"bytes"\n\t"fmt"\n\t. "math" // comment\n)'
+				fixEOL(eol, 'import "fmt"\nimport . "math" // comment'),
+				fixEOL(eol, 'import (\n\t"bytes"\n\t"fmt"\n\t. "math" // comment\n)')
 			);
 		const edits = getTextEditForAddImport('bytes');
 		const edit = new vscode.WorkspaceEdit();
@@ -1498,12 +1509,13 @@
 		const uri = vscode.Uri.file(path.join(fixturePath, 'importTest', 'cgoImports.go'));
 		const document = await vscode.workspace.openTextDocument(uri);
 		await vscode.window.showTextDocument(document);
+		const eol = document.eol;
 
 		const expectedText = document
 			.getText()
 			.replace(
-				'import "math"',
-				'import (\n\t"bytes"\n\t"math"\n)'
+				fixEOL(eol, 'import "math"'),
+				fixEOL(eol, 'import (\n\t"bytes"\n\t"math"\n)')
 			);
 		const edits = getTextEditForAddImport('bytes');
 		const edit = new vscode.WorkspaceEdit();