test: adjust tests involving 'check*' when language server is on
When language server is enabled, `check*` functions behave differently -
skip vet/build checks. So, we adjust the existing tests as we start to
enable the language server by default for nightly release.
- Change 'Error checking' test to not expect the build/vet errors when language
server is enabled.
- Change 'Build Tags checking' test to be skipped when language server is
enabled. This test depends on build errors.
Fixes golang/vscode-go#752
Change-Id: I831ad00b8104a033384195c405f9b201b88910e9
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/260199
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: Rebecca Stambler <rstambler@golang.org>
diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts
index 385e554..e7e2191 100644
--- a/test/integration/extension.test.ts
+++ b/test/integration/extension.test.ts
@@ -21,6 +21,7 @@
} from '../../src/goGenerateTests';
import { getTextEditForAddImport, listPackages } from '../../src/goImport';
import { updateGoVarsFromConfig } from '../../src/goInstallTools';
+import { buildLanguageServerConfig } from '../../src/goLanguageServer';
import { goLint } from '../../src/goLint';
import { documentSymbols, GoDocumentSymbolProvider, GoOutlineImportsOptions } from '../../src/goOutline';
import { getAllPackages } from '../../src/goPackages';
@@ -419,14 +420,19 @@
lintFlags: { value: [] },
buildOnSave: { value: 'package' }
});
- const expected = [
+ const expectedLintErrors = [
{
line: 7,
severity: 'warning',
msg: 'exported function Print2 should have comment or be unexported'
},
- { line: 11, severity: 'error', msg: 'undefined: prin' }
];
+ // If a user has enabled diagnostics via a language server,
+ // then we disable running build or vet to avoid duplicate errors and warnings.
+ const lspConfig = buildLanguageServerConfig();
+ const expectedBuildVetErrors = lspConfig.enabled ? [] : [{ line: 11, severity: 'error', msg: 'undefined: prin' }];
+
+ const expected = [...expectedLintErrors, ...expectedBuildVetErrors];
const diagnostics = await check(vscode.Uri.file(path.join(fixturePath, 'errorsTest', 'errors.go')), config);
const sortedDiagnostics = ([] as ICheckResult[]).concat
.apply(
@@ -445,7 +451,7 @@
);
});
});
- assert.equal(matchCount.length >= expected.length, true, `Failed to match expected errors`);
+ assert.equal(matchCount.length >= expected.length, true, `Failed to match expected errors \n${JSON.stringify(sortedDiagnostics)} \n VS\n ${JSON.stringify(expected)}`);
});
test('Test Generate unit tests skeleton for file', async () => {
@@ -1365,6 +1371,12 @@
});
test('Build Tags checking', async () => {
+ const goplsConfig = buildLanguageServerConfig();
+ if (goplsConfig.enabled) {
+ // Skip this test if gopls is enabled. Build/Vet checks this test depend on are
+ // disabled when the language server is enabled, and gopls is not handling tags yet.
+ return;
+ }
// Note: The following checks can't be parallelized because the underlying go build command
// runner (goBuild) will cancel any outstanding go build commands.