Skip to content

Commit 143b6d9

Browse files
committed
workflow: enable tests with go1.18beta1
* disable dlv's go version check for legacy debug adapter testing. (when delve supporting go1.18 go-delve/delve#2831 is released, this is unnecessary). * adjust various tests that were affected by go1.18's change to replace interface{} with any. Tested by running the github workflows from my fork. Fixes #1950 Change-Id: I4e4bceaf9ad2c89f421ad4cb4da04e96a69ac7cb Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/374055 Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Suzy Mueller <suzmue@golang.org>
1 parent 691e15f commit 143b6d9

File tree

5 files changed

+81
-16
lines changed

5 files changed

+81
-16
lines changed

.github/workflows/test-long-all.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
matrix:
1818
os: [ubuntu-latest, windows-latest, macos-latest]
1919
version: ['stable', 'insiders']
20-
go: ['1.15', '1.16', '1.17']
20+
go: ['1.15', '1.16', '1.17', '1.18.0-beta1']
2121

2222
steps:
2323
- name: Clone repository

.github/workflows/test-long.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
os: [ubuntu-latest, windows-latest] # TODO: reenable macos-latest
1818
version: ['stable']
19-
go: ['1.15', '1.16', '1.17']
19+
go: ['1.15', '1.16', '1.17', '1.18.0-beta1']
2020

2121
steps:
2222
- name: Clone repository

test/gopls/extension.test.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { LanguageClient } from 'vscode-languageclient/node';
1111
import { getGoConfig } from '../../src/config';
1212
import { buildLanguageClient, BuildLanguageClientOption, buildLanguageServerConfig } from '../../src/goLanguageServer';
1313
import sinon = require('sinon');
14+
import { getGoVersion, GoVersion } from '../../src/util';
1415

1516
// FakeOutputChannel is a fake output channel used to buffer
1617
// the output of the tested language client in an in-memory
@@ -132,7 +133,11 @@ suite('Go Extension Tests With Gopls', function () {
132133
const testdataDir = path.join(projectDir, 'test', 'testdata');
133134
const env = new Env();
134135

135-
suiteSetup(async () => await env.setup(path.resolve(testdataDir, 'gogetdocTestData', 'test.go')));
136+
let goVersion: GoVersion;
137+
suiteSetup(async () => {
138+
await env.setup(path.resolve(testdataDir, 'gogetdocTestData', 'test.go'));
139+
goVersion = await getGoVersion();
140+
});
136141
suiteTeardown(() => env.teardown());
137142

138143
this.afterEach(function () {
@@ -155,7 +160,9 @@ suite('Go Extension Tests With Gopls', function () {
155160
[
156161
'func Println()',
157162
new vscode.Position(19, 6),
158-
'func fmt.Println(a ...interface{}) (n int, err error)',
163+
goVersion.lt('1.18')
164+
? 'func fmt.Println(a ...interface{}) (n int, err error)'
165+
: 'func fmt.Println(a ...any) (n int, err error)',
159166
'Println formats '
160167
],
161168
['func print()', new vscode.Position(23, 4), 'func print(txt string)', 'This is an unexported function ']

test/integration/extension.test.ts

+55-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ import { testCurrentFile } from '../../src/goTest';
3737
import {
3838
getBinPath,
3939
getCurrentGoPath,
40+
getGoVersion,
4041
getImportPath,
42+
GoVersion,
4143
handleDiagnosticErrors,
4244
ICheckResult,
4345
isVendorSupported
@@ -57,6 +59,7 @@ const testAll = (isModuleMode: boolean) => {
5759
let generateFunctionTestSourcePath: string;
5860
let generatePackageTestSourcePath: string;
5961
let previousEnv: any;
62+
let goVersion: GoVersion;
6063

6164
suiteSetup(async () => {
6265
previousEnv = Object.assign({}, process.env);
@@ -69,6 +72,8 @@ const testAll = (isModuleMode: boolean) => {
6972
assert.ok(gopath, 'Cannot run tests if GOPATH is not set as environment variable');
7073
return;
7174
}
75+
goVersion = await getGoVersion();
76+
7277
console.log(`Using GOPATH: ${gopath}`);
7378

7479
repoPath = isModuleMode ? fs.mkdtempSync(path.join(os.tmpdir(), 'legacy')) : path.join(gopath, 'src', 'test');
@@ -225,13 +230,16 @@ standard output. Spaces are always added between operands and a newline is
225230
appended. It returns the number of bytes written and any write error
226231
encountered.
227232
`;
233+
const printlnSig = goVersion.lt('1.18')
234+
? 'Println(a ...interface{}) (n int, err error)'
235+
: 'Println(a ...any) (n int, err error)';
228236

229237
const testCases: [vscode.Position, string, string, string[]][] = [
230238
[
231239
new vscode.Position(19, 13),
232-
'Println(a ...interface{}) (n int, err error)',
240+
printlnSig,
233241
printlnDoc,
234-
['a ...interface{}']
242+
[goVersion.lt('1.18') ? 'a ...interface{}' : 'a ...any']
235243
],
236244
[
237245
new vscode.Position(23, 7),
@@ -272,12 +280,16 @@ encountered.
272280
Spaces are always added between operands and a newline is appended.
273281
It returns the number of bytes written and any write error encountered.
274282
`;
283+
const printlnSig = goVersion.lt('1.18')
284+
? 'Println(a ...interface{}) (n int, err error)'
285+
: 'Println(a ...any) (n int, err error)';
286+
275287
const testCases: [vscode.Position, string, string, string[]][] = [
276288
[
277289
new vscode.Position(19, 13),
278-
'Println(a ...interface{}) (n int, err error)',
290+
printlnSig,
279291
printlnDoc,
280-
['a ...interface{}']
292+
[goVersion.lt('1.18') ? 'a ...interface{}' : 'a ...any']
281293
],
282294
[
283295
new vscode.Position(23, 7),
@@ -314,6 +326,10 @@ standard output. Spaces are always added between operands and a newline is
314326
appended. It returns the number of bytes written and any write error
315327
encountered.
316328
`;
329+
const printlnSig = goVersion.lt('1.18')
330+
? 'Println func(a ...interface{}) (n int, err error)'
331+
: 'Println func(a ...any) (n int, err error)';
332+
317333
const testCases: [vscode.Position, string | null, string | null][] = [
318334
// [new vscode.Position(3,3), '/usr/local/go/src/fmt'],
319335
[new vscode.Position(0, 3), null, null], // keyword
@@ -322,7 +338,7 @@ encountered.
322338
[new vscode.Position(28, 16), null, null], // inside a number
323339
[new vscode.Position(22, 5), 'main func()', '\n'],
324340
[new vscode.Position(40, 23), 'import (math "math")', null],
325-
[new vscode.Position(19, 6), 'Println func(a ...interface{}) (n int, err error)', printlnDoc],
341+
[new vscode.Position(19, 6), printlnSig, printlnDoc],
326342
[
327343
new vscode.Position(23, 4),
328344
'print func(txt string)',
@@ -350,6 +366,10 @@ encountered.
350366
Spaces are always added between operands and a newline is appended.
351367
It returns the number of bytes written and any write error encountered.
352368
`;
369+
const printlnSig = goVersion.lt('1.18')
370+
? 'func Println(a ...interface{}) (n int, err error)'
371+
: 'func Println(a ...any) (n int, err error)';
372+
353373
const testCases: [vscode.Position, string | null, string | null][] = [
354374
[new vscode.Position(0, 3), null, null], // keyword
355375
[new vscode.Position(23, 11), null, null], // inside a string
@@ -366,7 +386,7 @@ It returns the number of bytes written and any write error encountered.
366386
'package math',
367387
'Package math provides basic constants and mathematical functions.\n\nThis package does not guarantee bit-identical results across architectures.\n'
368388
],
369-
[new vscode.Position(19, 6), 'func Println(a ...interface{}) (n int, err error)', printlnDoc],
389+
[new vscode.Position(19, 6), printlnSig, printlnDoc],
370390
[
371391
new vscode.Position(27, 14),
372392
'type ABC struct {\n a int\n b int\n c int\n}',
@@ -384,7 +404,13 @@ It returns the number of bytes written and any write error encountered.
384404
await testHoverProvider(config, testCases);
385405
});
386406

387-
test('Linting - concurrent process cancelation', async () => {
407+
test('Linting - concurrent process cancelation', async function () {
408+
if (!goVersion.lt('1.18')) {
409+
// TODO(hyangah): reenable test when staticcheck for go1.18 is released
410+
// https://github.com/dominikh/go-tools/issues/1145
411+
this.skip();
412+
}
413+
388414
const util = require('../../src/util');
389415
const processutil = require('../../src/utils/processUtils');
390416
sinon.spy(util, 'runTool');
@@ -413,7 +439,12 @@ It returns the number of bytes written and any write error encountered.
413439
);
414440
});
415441

416-
test('Linting - lint errors with multiple open files', async () => {
442+
test('Linting - lint errors with multiple open files', async function () {
443+
if (!goVersion.lt('1.18')) {
444+
// TODO(hyangah): reenable test when staticcheck for go1.18 is released
445+
// https://github.com/dominikh/go-tools/issues/1145
446+
this.skip();
447+
}
417448
// handleDiagnosticErrors may adjust the lint errors' ranges to make the error more visible.
418449
// This adjustment applies only to the text documents known to vscode. This test checks
419450
// the adjustment is made consistently across multiple open text documents.
@@ -448,7 +479,13 @@ It returns the number of bytes written and any write error encountered.
448479
assert.deepStrictEqual(file1Diagnostics[0], file2Diagnostics[0]);
449480
});
450481

451-
test('Error checking', async () => {
482+
test('Error checking', async function () {
483+
if (!goVersion.lt('1.18')) {
484+
// TODO(hyangah): reenable test when staticcheck for go1.18 is released
485+
// https://github.com/dominikh/go-tools/issues/1145
486+
this.skip();
487+
}
488+
452489
const config = Object.create(getGoConfig(), {
453490
vetOnSave: { value: 'package' },
454491
vetFlags: { value: ['-all'] },
@@ -901,10 +938,14 @@ standard output. Spaces are always added between operands and a newline is
901938
appended. It returns the number of bytes written and any write error
902939
encountered.
903940
`;
941+
const printlnSig = goVersion.lt('1.18')
942+
? 'func(a ...interface{}) (n int, err error)'
943+
: 'func(a ...any) (n int, err error)';
944+
904945
const provider = new GoCompletionItemProvider();
905946
const testCases: [vscode.Position, string, string | null, string | null][] = [
906947
[new vscode.Position(7, 4), 'fmt', 'fmt', null],
907-
[new vscode.Position(7, 6), 'Println', 'func(a ...interface{}) (n int, err error)', printlnDoc]
948+
[new vscode.Position(7, 6), 'Println', printlnSig, printlnDoc]
908949
];
909950
const uri = vscode.Uri.file(path.join(fixturePath, 'baseTest', 'test.go'));
910951
const textDocument = await vscode.workspace.openTextDocument(uri);
@@ -980,7 +1021,10 @@ encountered.
9801021
if (!item1) {
9811022
assert.fail('Suggestion with label "Print" not found in test case withFunctionSnippet.');
9821023
}
983-
assert.equal((<vscode.SnippetString>item1.insertText).value, 'Print(${1:a ...interface{\\}})');
1024+
assert.equal(
1025+
(<vscode.SnippetString>item1.insertText).value,
1026+
goVersion.lt('1.18') ? 'Print(${1:a ...interface{\\}})' : 'Print(${1:a ...any})'
1027+
);
9841028
});
9851029
const withFunctionSnippetNotype = provider
9861030
.provideCompletionItemsInternal(

test/integration/goDebug.test.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ suite('GoDebugSession Tests', async () => {
5757
process.env.GOPATH = '/usr/gopath';
5858
process.env.GOROOT = '/usr/goroot';
5959
remoteSourcesAndPackages = new RemoteSourcesAndPackages();
60+
// eslint-disable-next-line prettier/prettier
6061
fileSystem = ({ existsSync: () => false } as unknown) as typeof fs;
6162
delve.program = workspaceFolder;
6263
delve.isApiV1 = false;
@@ -287,6 +288,7 @@ suite('RemoteSourcesAndPackages Tests', () => {
287288
let remoteSourcesAndPackages: RemoteSourcesAndPackages;
288289
let delve: Delve;
289290
setup(() => {
291+
// eslint-disable-next-line prettier/prettier
290292
delve = ({ callPromise: () => ({}), isApiV1: false } as unknown) as Delve;
291293
remoteSourcesAndPackages = new RemoteSourcesAndPackages();
292294
});
@@ -399,7 +401,13 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {
399401
): Promise<cp.ChildProcess> {
400402
const serverFolder = path.join(DATA_ROOT, 'helloWorldServer');
401403
const toolPath = getBinPath('dlv');
402-
const args = ['debug', '--api-version=2', '--headless', `--listen=127.0.0.1:${dlvPort}`];
404+
const args = [
405+
'debug',
406+
'--check-go-version=false',
407+
'--api-version=2',
408+
'--headless',
409+
`--listen=127.0.0.1:${dlvPort}`
410+
];
403411
if (acceptMultiClient) {
404412
args.push('--accept-multiclient');
405413
}
@@ -2170,6 +2178,12 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => {
21702178
config['showLog'] = true;
21712179
config['trace'] = 'verbose';
21722180
}
2181+
2182+
// disable version check (like in dlv-dap).
2183+
if (!isDlvDap) {
2184+
const dlvFlags = config['dlvFlags'] || [];
2185+
config['dlvFlags'] = ['--check-go-version=false'].concat(dlvFlags);
2186+
}
21732187
// Give each test a distinct debug binary. If a previous test
21742188
// and a new test use the same binary location, it is possible
21752189
// that the second test could build the binary, and then the

0 commit comments

Comments
 (0)