Skip to content

Commit dd667c2

Browse files
committed
extension/test/gopls: increase the stretchr test timeout
Allow more time for shutting down gopls. The stretchr test requires 3rd party modules to build and need more time for gopls to load & shutdown. Remove unnecessary async in afterEach callback. This async caused the callback to be unnecessarily wrapped in a Promise and triggered confusing error message in case of test failure - unresolved promise even when the cause of failure is somewhere else. Change-Id: Iabf3f7639ae68548fb730183bf7fc8c925ecca79 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/618356 kokoro-CI: kokoro <[email protected]> Commit-Queue: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 5212b15 commit dd667c2

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

Diff for: extension/test/gopls/codelens.test.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ suite('Code lenses for testing and benchmarking', function () {
2929
const testdataDir = path.join(projectDir, 'test', 'testdata', 'codelens');
3030
const env = new Env();
3131

32-
this.afterEach(async function () {
32+
this.afterEach(function () {
3333
// Note: this shouldn't use () => {...}. Arrow functions do not have 'this'.
3434
// I don't know why but this.currentTest.state does not have the expected value when
3535
// used with teardown.
@@ -229,16 +229,14 @@ suite('Code lenses for testing and benchmarking', function () {
229229
});
230230

231231
suite('Code lenses with stretchr/testify/suite', function () {
232-
if (process.platform === 'win32') {
233-
this.timeout(20000); // Gopls on windows needs more time to load required modules.
234-
}
232+
this.timeout(20000); // Gopls needs to load modules from the internet for this test.
235233

236234
const ctx = MockExtensionContext.new();
237235

238236
const testdataDir = path.join(__dirname, '..', '..', '..', 'test', 'testdata', 'stretchrTestSuite');
239237
const env = new Env();
240238

241-
this.afterEach(async function () {
239+
this.afterEach(function () {
242240
// Note: this shouldn't use () => {...}. Arrow functions do not have 'this'.
243241
// I don't know why but this.currentTest.state does not have the expected value when
244242
// used with teardown.

Diff for: extension/test/gopls/goplsTestEnv.utils.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,11 @@ export class Env {
143143
public async teardown() {
144144
try {
145145
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
146-
await this.languageClient?.stop(1000); // 1s timeout
146+
await this.languageClient?.stop(10000); // 10s timeout
147147
} catch (e) {
148-
console.log(`failed to stop gopls within 1sec: ${e}`);
148+
console.log(`failed to stop gopls within 10sec: ${e}`);
149+
this.flushTrace(true);
149150
} finally {
150-
if (this.languageClient?.isRunning()) {
151-
console.log(`failed to stop language client on time: ${this.languageClient?.state}`);
152-
this.flushTrace(true);
153-
}
154151
for (const d of this.disposables) {
155152
d.dispose();
156153
}

0 commit comments

Comments
 (0)