From 8bc0703b44357592184a18364de5fcae51368156 Mon Sep 17 00:00:00 2001 From: "Hana (Hyang-Ah) Kim" Date: Wed, 8 Jun 2022 17:13:13 -0400 Subject: [PATCH] test/integration: reenable staticcheck and fix "Error checking" test Staticcheck has been supporting go1.18 for a while, so reenable the skipped test. https://go-review.googlesource.com/c/vscode-go/+/405551 rearranged how diagnostics collection was passed. We need to pass them as goCtx. Updates golang/vscode-go#1950 Fixes golang/vscode-go#2282 Change-Id: I9147e452bcfe61c8a5a260c0cca246dcc2375f0e Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/411104 Run-TryBot: Hyang-Ah Hana Kim Reviewed-by: Jamal Carvalho TryBot-Result: kokoro --- .vscode/launch.json | 1 + test/integration/extension.test.ts | 33 +++++++++++------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index ab3634d582..418e3d26b5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -63,6 +63,7 @@ "env": { "VSCODE_GO_IN_TEST": "1", // Disable code that shouldn't be used in test "MOCHA_TIMEOUT": "999999", + "MOCHA_GREP": "Error checking" }, "stopOnEntry": false, "sourceMaps": true, diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts index 7fb2b9270c..6446c55dd2 100644 --- a/test/integration/extension.test.ts +++ b/test/integration/extension.test.ts @@ -405,13 +405,7 @@ It returns the number of bytes written and any write error encountered. await testHoverProvider(config, testCases); }); - 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(); - } - + test('Linting - concurrent process cancelation', async () => { const util = require('../../src/util'); const processutil = require('../../src/utils/processUtils'); sinon.spy(util, 'runTool'); @@ -440,12 +434,7 @@ It returns the number of bytes written and any write error encountered. ); }); - 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(); - } + test('Linting - lint errors with multiple open files', async () => { // 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. @@ -482,13 +471,7 @@ It returns the number of bytes written and any write error encountered. assert.deepStrictEqual(file1Diagnostics[0], file2Diagnostics[0]); }); - 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(); - } - + test('Error checking', async () => { const config = Object.create(getGoConfig(), { vetOnSave: { value: 'package' }, vetFlags: { value: ['-all'] }, @@ -515,7 +498,15 @@ It returns the number of bytes written and any write error encountered. // `check` itself doesn't run deDupeDiagnostics, so we expect all vet/lint errors. const expected = [...expectedLintErrors, ...expectedBuildVetErrors]; - const diagnostics = await check({}, vscode.Uri.file(path.join(fixturePath, 'errorsTest', 'errors.go')), config); + const diagnostics = await check( + { + buildDiagnosticCollection: vscode.languages.createDiagnosticCollection('buildtest'), + lintDiagnosticCollection: vscode.languages.createDiagnosticCollection('linttest'), + vetDiagnosticCollection: vscode.languages.createDiagnosticCollection('vettest') + }, + vscode.Uri.file(path.join(fixturePath, 'errorsTest', 'errors.go')), + config + ); const sortedDiagnostics = ([] as ICheckResult[]).concat .apply( [],