goDebug.test: fix GOPATH and GOROOT restoration
The tool installation tests were failing because the GOROOT was being restored incorrectly.
Change-Id: Ia4d0d03f49db542b0597b361c4058b941ae0d390
GitHub-Last-Rev: 0a52da1a3b6ee3bcd92b450d867b2635d033f37b
GitHub-Pull-Request: golang/vscode-go#98
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/235357
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts
index 3fae910..23a9afa 100644
--- a/test/integration/goDebug.test.ts
+++ b/test/integration/goDebug.test.ts
@@ -2,8 +2,10 @@
import * as fs from 'fs';
import * as path from 'path';
import * as sinon from 'sinon';
-import { Delve, escapeGoModPath, GoDebugSession,
- PackageBuildInfo, RemoteSourcesAndPackages } from '../../src/debugAdapter/goDebug';
+import {
+ Delve, escapeGoModPath, GoDebugSession,
+ PackageBuildInfo, RemoteSourcesAndPackages
+} from '../../src/debugAdapter/goDebug';
suite('Path Manipulation Tests', () => {
test('escapeGoModPath works', () => {
@@ -14,13 +16,17 @@
suite('GoDebugSession Tests', () => {
const workspaceFolder = '/usr/workspacefolder';
const delve: Delve = {} as Delve;
- const previousGoPath = process.env.GOPATH;
- const previousGoRoot = process.env.GOROOT;
-
let goDebugSession: GoDebugSession;
let remoteSourcesAndPackages: RemoteSourcesAndPackages;
let fileSystem: typeof fs;
+
+ let previousGoPath: string;
+ let previousGoRoot: string;
+
setup(() => {
+ previousGoPath = process.env.GOPATH;
+ previousGoRoot = process.env.GOROOT;
+
process.env.GOPATH = '/usr/gopath';
process.env.GOROOT = '/usr/goroot';
remoteSourcesAndPackages = new RemoteSourcesAndPackages();
@@ -241,7 +247,7 @@
let remoteSourcesAndPackages: RemoteSourcesAndPackages;
let delve: Delve;
setup(() => {
- delve = {callPromise: () => ({}), isApiV1: false} as unknown as Delve;
+ delve = { callPromise: () => ({}), isApiV1: false } as unknown as Delve;
remoteSourcesAndPackages = new RemoteSourcesAndPackages();
});
@@ -251,10 +257,10 @@
test('initializeRemotePackagesAndSources retrieves remote packages and sources', async () => {
const stub = sinon.stub(delve, 'callPromise');
- stub.withArgs('ListPackagesBuildInfo', [{IncludeFiles: true}])
- .returns(Promise.resolve({List: [helloPackage, testPackage]}));
+ stub.withArgs('ListPackagesBuildInfo', [{ IncludeFiles: true }])
+ .returns(Promise.resolve({ List: [helloPackage, testPackage] }));
stub.withArgs('ListSources', [{}])
- .returns(Promise.resolve({Sources: sources}));
+ .returns(Promise.resolve({ Sources: sources }));
await remoteSourcesAndPackages.initializeRemotePackagesAndSources(delve);
assert.deepEqual(remoteSourcesAndPackages.remoteSourceFiles, sources);