Skip to content

Commit 4cda145

Browse files
authored
fix: race condition between globals registration and extension test activation (aws#5078)
Problem: - In globalSetup we use activateExtension which relies on globals being registered under the hood (inside of the Timeout). If globals aren't registered before we get to that code then the toolkit immediately stops running. This is evident when you use the VSCode current file test launch configs. I _think_ the reason why this doesn't happen when running all the e2e/integ tests is because the glob pattern takes longer to find all the files to load into mocha, giving more time for the extension to activate before the tests are actually ran Solution: - Just use vscode.extensions.getExtension directly though we technically lose the 60000 timeout. In the worst case the editor just stays open, which is what happens now anyways since errors don't cause VSCode tests to close Alternative solutions: - Re-implement the timeout without using global clock but that could mean a lot of refactoring for tests that rely on it - Re-implement a seperate timeout that doesn't use global clock but is essentially duplicate code except for the fact it just uses Date directly vs global.clock.Date - Don't use the waitUntil function inside of activeExtension and just re-implement a small function that activates the extension or fails after 60000 seconds inside of global setup
1 parent 45ae5d9 commit 4cda145

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

packages/core/src/testInteg/globalSetup.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import vscode from 'vscode'
1010
import { getLogger } from '../shared/logger'
1111
import { WinstonToolkitLogger } from '../shared/logger/winstonToolkitLogger'
12-
import { activateExtension } from '../shared/utilities/vsCodeUtils'
1312
import { mapTestErrors, normalizeError, patchObject, setRunnableTimeout } from '../test/setupUtil'
1413
import { getTestWindow, resetTestWindow } from '../test/shared/vscode/window'
1514

@@ -33,7 +32,7 @@ export async function mochaGlobalSetup(extensionId: string) {
3332
patchWindow()
3433

3534
// Needed for getLogger().
36-
await activateExtension(extensionId, false)
35+
await vscode.extensions.getExtension(extensionId)?.activate()
3736

3837
// Log as much as possible, useful for debugging integration tests.
3938
getLogger().setLogLevel('debug')

0 commit comments

Comments
 (0)