Skip to content

Commit dc68451

Browse files
committed
extension/test/runTest.ts: set GOTOOLCHAIN=local
This script runs in CI with the go version under testing. Prevent the go toolchain switch from getting influenced by extension/go.mod's choice of go version. Add a go.mod file with go1.12 to extension/test/testdata/envTest to make this not part of the extension module. That prevents go toolchain switch to go1.23 to meet the extension module's requirement during test (which will fail due to GOTOOLCHAIN=local) after we update extension/go.mod to require go1.23.1+ in CL 616677. Adjust goExplorer.test.ts env tree items test that assumed GOTOOLCHAIN is empty. Now the test runs with GOTOOLCHAIN=local. Update .vscode/launch.json to pass GOTOOLCHAIN=local for integration testing. For #3411 Change-Id: I02f1cd6512a0030a729668221b163f6cc3e26b0f Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/619715 Reviewed-by: Robert Findley <[email protected]> kokoro-CI: kokoro <[email protected]> Commit-Queue: Hyang-Ah Hana Kim <[email protected]>
1 parent b78b78e commit dc68451

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

.vscode/launch.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"999999"
4747
],
4848
"env": {
49+
"GOTOOLCHAIN": "local", // Avoid toolchain switch caused by extension/go.mod.
4950
"VSCODE_GO_IN_TEST": "1", // Disable code that shouldn't be used in test
5051
"MOCHA_TIMEOUT": "999999",
5152
},
@@ -72,6 +73,7 @@
7273
"--timeout", "999999",
7374
],
7475
"env": {
76+
"GOTOOLCHAIN": "local", // Avoid toolchain switch caused by extension/go.mod.
7577
"VSCODE_GO_IN_TEST": "1" // Disable code that shouldn't be used in test
7678
},
7779
"outFiles": [

extension/test/integration/goExplorer.test.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,36 @@ suite('GoExplorerProvider', () => {
2929
ctx.teardown();
3030
});
3131

32+
// The GoExplorerProvider extends vscode.TreeDataProvider,
33+
// and presents tree view consisting of:
34+
// + env (env variable tree)
35+
// + GOENV
36+
// + GOMOD
37+
// + ....
38+
// + tools (tools info tree)
39+
// + various tools
40+
// + ....
41+
// The ordering of children is deterministric. Env tree comes
42+
// before Tools tree in the current implementation.
43+
//
44+
// Env tree changes depending on the open file.
45+
// Tools tree is the list of tools used for the window and remains static.
3246
test('env tree', async () => {
33-
const [env] = await explorer.getChildren()!;
47+
const [env] = await explorer.getChildren()!; // the first level has two children [env, tool]
3448
assert.strictEqual(env.label, 'env');
3549
assert.strictEqual(env.contextValue, 'go:explorer:envtree');
3650
});
3751

3852
test('env tree items', async () => {
3953
const [env] = await explorer.getChildren()!;
40-
const [goenv, gomod] = (await explorer.getChildren(env)) as { key: string; value: string }[];
41-
assert.strictEqual(goenv.key, 'GOENV');
42-
assert.strictEqual(gomod.key, 'GOMOD');
43-
assert.strictEqual(resolveHomeDir(gomod.value), path.join(fixtureDir, 'go.mod'));
54+
const items = (await explorer.getChildren(env)) as { key: string; value: string }[];
55+
for (const key of ['GOENV', 'GOTOOLCHAIN', 'GOMOD']) {
56+
const item = items.find((item) => item.key === key);
57+
assert(item, `missing ${key}: ${JSON.stringify(items)}`);
58+
if (key === 'GOMOD') {
59+
assert.strictEqual(resolveHomeDir(item.value), path.join(fixtureDir, 'go.mod'));
60+
}
61+
}
4462
});
4563

4664
test('tools tree', async () => {

extension/test/runTest.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import * as path from 'path';
44
import { SilentReporter, runTests } from '@vscode/test-electron';
55

66
async function main() {
7+
// Use the local toolchain by default
8+
// instead of getting affected by the extension/go.mod go or toolchain directives.
9+
process.env['GOTOOLCHAIN'] = 'local';
10+
711
// We are in test mode.
812
process.env['VSCODE_GO_IN_TEST'] = '1';
913
if (process.argv.length > 2) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module example.com/envTest
2+
3+
go 1.12

0 commit comments

Comments
 (0)