diff --git a/.github/workflows/test-long-all.yml b/.github/workflows/test-long-all.yml index 4b43f3001e..182fcededb 100644 --- a/.github/workflows/test-long-all.yml +++ b/.github/workflows/test-long-all.yml @@ -17,7 +17,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] version: ['stable', 'insiders'] - go: ['1.15', '1.16', '1.17'] + go: ['1.15', '1.16', '1.17', '1.18.0-beta1'] steps: - name: Clone repository diff --git a/.github/workflows/test-long.yml b/.github/workflows/test-long.yml index 91f1a761a9..79784f57d9 100644 --- a/.github/workflows/test-long.yml +++ b/.github/workflows/test-long.yml @@ -16,7 +16,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] # TODO: reenable macos-latest version: ['stable'] - go: ['1.15', '1.16', '1.17'] + go: ['1.15', '1.16', '1.17', '1.18.0-beta1'] steps: - name: Clone repository diff --git a/test/gopls/extension.test.ts b/test/gopls/extension.test.ts index 9a09f5a221..47a67a9895 100644 --- a/test/gopls/extension.test.ts +++ b/test/gopls/extension.test.ts @@ -11,6 +11,7 @@ import { LanguageClient } from 'vscode-languageclient/node'; import { getGoConfig } from '../../src/config'; import { buildLanguageClient, BuildLanguageClientOption, buildLanguageServerConfig } from '../../src/goLanguageServer'; import sinon = require('sinon'); +import { getGoVersion, GoVersion } from '../../src/util'; // FakeOutputChannel is a fake output channel used to buffer // the output of the tested language client in an in-memory @@ -132,7 +133,11 @@ suite('Go Extension Tests With Gopls', function () { const testdataDir = path.join(projectDir, 'test', 'testdata'); const env = new Env(); - suiteSetup(async () => await env.setup(path.resolve(testdataDir, 'gogetdocTestData', 'test.go'))); + let goVersion: GoVersion; + suiteSetup(async () => { + await env.setup(path.resolve(testdataDir, 'gogetdocTestData', 'test.go')); + goVersion = await getGoVersion(); + }); suiteTeardown(() => env.teardown()); this.afterEach(function () { @@ -155,7 +160,9 @@ suite('Go Extension Tests With Gopls', function () { [ 'func Println()', new vscode.Position(19, 6), - 'func fmt.Println(a ...interface{}) (n int, err error)', + goVersion.lt('1.18') + ? 'func fmt.Println(a ...interface{}) (n int, err error)' + : 'func fmt.Println(a ...any) (n int, err error)', 'Println formats ' ], ['func print()', new vscode.Position(23, 4), 'func print(txt string)', 'This is an unexported function '] diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts index c3b703e2ad..d7bb17eeeb 100644 --- a/test/integration/extension.test.ts +++ b/test/integration/extension.test.ts @@ -37,7 +37,9 @@ import { testCurrentFile } from '../../src/goTest'; import { getBinPath, getCurrentGoPath, + getGoVersion, getImportPath, + GoVersion, handleDiagnosticErrors, ICheckResult, isVendorSupported @@ -57,6 +59,7 @@ const testAll = (isModuleMode: boolean) => { let generateFunctionTestSourcePath: string; let generatePackageTestSourcePath: string; let previousEnv: any; + let goVersion: GoVersion; suiteSetup(async () => { previousEnv = Object.assign({}, process.env); @@ -69,6 +72,8 @@ const testAll = (isModuleMode: boolean) => { assert.ok(gopath, 'Cannot run tests if GOPATH is not set as environment variable'); return; } + goVersion = await getGoVersion(); + console.log(`Using GOPATH: ${gopath}`); 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 appended. It returns the number of bytes written and any write error encountered. `; + const printlnSig = goVersion.lt('1.18') + ? 'Println(a ...interface{}) (n int, err error)' + : 'Println(a ...any) (n int, err error)'; const testCases: [vscode.Position, string, string, string[]][] = [ [ new vscode.Position(19, 13), - 'Println(a ...interface{}) (n int, err error)', + printlnSig, printlnDoc, - ['a ...interface{}'] + [goVersion.lt('1.18') ? 'a ...interface{}' : 'a ...any'] ], [ new vscode.Position(23, 7), @@ -272,12 +280,16 @@ encountered. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. `; + const printlnSig = goVersion.lt('1.18') + ? 'Println(a ...interface{}) (n int, err error)' + : 'Println(a ...any) (n int, err error)'; + const testCases: [vscode.Position, string, string, string[]][] = [ [ new vscode.Position(19, 13), - 'Println(a ...interface{}) (n int, err error)', + printlnSig, printlnDoc, - ['a ...interface{}'] + [goVersion.lt('1.18') ? 'a ...interface{}' : 'a ...any'] ], [ new vscode.Position(23, 7), @@ -314,6 +326,10 @@ standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. `; + const printlnSig = goVersion.lt('1.18') + ? 'Println func(a ...interface{}) (n int, err error)' + : 'Println func(a ...any) (n int, err error)'; + const testCases: [vscode.Position, string | null, string | null][] = [ // [new vscode.Position(3,3), '/usr/local/go/src/fmt'], [new vscode.Position(0, 3), null, null], // keyword @@ -322,7 +338,7 @@ encountered. [new vscode.Position(28, 16), null, null], // inside a number [new vscode.Position(22, 5), 'main func()', '\n'], [new vscode.Position(40, 23), 'import (math "math")', null], - [new vscode.Position(19, 6), 'Println func(a ...interface{}) (n int, err error)', printlnDoc], + [new vscode.Position(19, 6), printlnSig, printlnDoc], [ new vscode.Position(23, 4), 'print func(txt string)', @@ -350,6 +366,10 @@ encountered. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. `; + const printlnSig = goVersion.lt('1.18') + ? 'func Println(a ...interface{}) (n int, err error)' + : 'func Println(a ...any) (n int, err error)'; + const testCases: [vscode.Position, string | null, string | null][] = [ [new vscode.Position(0, 3), null, null], // keyword [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. 'package math', 'Package math provides basic constants and mathematical functions.\n\nThis package does not guarantee bit-identical results across architectures.\n' ], - [new vscode.Position(19, 6), 'func Println(a ...interface{}) (n int, err error)', printlnDoc], + [new vscode.Position(19, 6), printlnSig, printlnDoc], [ new vscode.Position(27, 14), '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. await testHoverProvider(config, testCases); }); - test('Linting - concurrent process cancelation', async () => { + test('Linting - concurrent process cancelation', async function () { + if (!goVersion.lt('1.18')) { + // TODO(hyangah): reenable test when staticcheck for go1.18 is released + // https://github.com/dominikh/go-tools/issues/1145 + this.skip(); + } + const util = require('../../src/util'); const processutil = require('../../src/utils/processUtils'); sinon.spy(util, 'runTool'); @@ -413,7 +439,12 @@ It returns the number of bytes written and any write error encountered. ); }); - test('Linting - lint errors with multiple open files', async () => { + test('Linting - lint errors with multiple open files', async function () { + if (!goVersion.lt('1.18')) { + // TODO(hyangah): reenable test when staticcheck for go1.18 is released + // https://github.com/dominikh/go-tools/issues/1145 + this.skip(); + } // handleDiagnosticErrors may adjust the lint errors' ranges to make the error more visible. // This adjustment applies only to the text documents known to vscode. This test checks // 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. assert.deepStrictEqual(file1Diagnostics[0], file2Diagnostics[0]); }); - test('Error checking', async () => { + test('Error checking', async function () { + if (!goVersion.lt('1.18')) { + // TODO(hyangah): reenable test when staticcheck for go1.18 is released + // https://github.com/dominikh/go-tools/issues/1145 + this.skip(); + } + const config = Object.create(getGoConfig(), { vetOnSave: { value: 'package' }, vetFlags: { value: ['-all'] }, @@ -901,10 +938,14 @@ standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. `; + const printlnSig = goVersion.lt('1.18') + ? 'func(a ...interface{}) (n int, err error)' + : 'func(a ...any) (n int, err error)'; + const provider = new GoCompletionItemProvider(); const testCases: [vscode.Position, string, string | null, string | null][] = [ [new vscode.Position(7, 4), 'fmt', 'fmt', null], - [new vscode.Position(7, 6), 'Println', 'func(a ...interface{}) (n int, err error)', printlnDoc] + [new vscode.Position(7, 6), 'Println', printlnSig, printlnDoc] ]; const uri = vscode.Uri.file(path.join(fixturePath, 'baseTest', 'test.go')); const textDocument = await vscode.workspace.openTextDocument(uri); @@ -980,7 +1021,10 @@ encountered. if (!item1) { assert.fail('Suggestion with label "Print" not found in test case withFunctionSnippet.'); } - assert.equal((item1.insertText).value, 'Print(${1:a ...interface{\\}})'); + assert.equal( + (item1.insertText).value, + goVersion.lt('1.18') ? 'Print(${1:a ...interface{\\}})' : 'Print(${1:a ...any})' + ); }); const withFunctionSnippetNotype = provider .provideCompletionItemsInternal( diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts index b9b67fe0c5..f48bc38d63 100644 --- a/test/integration/goDebug.test.ts +++ b/test/integration/goDebug.test.ts @@ -57,6 +57,7 @@ suite('GoDebugSession Tests', async () => { process.env.GOPATH = '/usr/gopath'; process.env.GOROOT = '/usr/goroot'; remoteSourcesAndPackages = new RemoteSourcesAndPackages(); + // eslint-disable-next-line prettier/prettier fileSystem = ({ existsSync: () => false } as unknown) as typeof fs; delve.program = workspaceFolder; delve.isApiV1 = false; @@ -287,6 +288,7 @@ suite('RemoteSourcesAndPackages Tests', () => { let remoteSourcesAndPackages: RemoteSourcesAndPackages; let delve: Delve; setup(() => { + // eslint-disable-next-line prettier/prettier delve = ({ callPromise: () => ({}), isApiV1: false } as unknown) as Delve; remoteSourcesAndPackages = new RemoteSourcesAndPackages(); }); @@ -399,7 +401,13 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => { ): Promise { const serverFolder = path.join(DATA_ROOT, 'helloWorldServer'); const toolPath = getBinPath('dlv'); - const args = ['debug', '--api-version=2', '--headless', `--listen=127.0.0.1:${dlvPort}`]; + const args = [ + 'debug', + '--check-go-version=false', + '--api-version=2', + '--headless', + `--listen=127.0.0.1:${dlvPort}` + ]; if (acceptMultiClient) { args.push('--accept-multiclient'); } @@ -2170,6 +2178,12 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => { config['showLog'] = true; config['trace'] = 'verbose'; } + + // disable version check (like in dlv-dap). + if (!isDlvDap) { + const dlvFlags = config['dlvFlags'] || []; + config['dlvFlags'] = ['--check-go-version=false'].concat(dlvFlags); + } // Give each test a distinct debug binary. If a previous test // and a new test use the same binary location, it is possible // that the second test could build the binary, and then the