From 82d6b51a36029fe80e25700cb740a0099c4d0a24 Mon Sep 17 00:00:00 2001 From: hkobew Date: Mon, 11 Nov 2024 15:17:37 -0500 Subject: [PATCH 1/4] try decreasing timeout to see if cause --- packages/core/src/test/testUtil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/test/testUtil.ts b/packages/core/src/test/testUtil.ts index d45a0b1ad20..00ad482493b 100644 --- a/packages/core/src/test/testUtil.ts +++ b/packages/core/src/test/testUtil.ts @@ -506,7 +506,7 @@ export async function closeAllEditors(): Promise { return editors.length === 0 }, { - timeout: 5000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. + timeout: 1000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. interval: 250, truthy: true, } From 19155162acda2fa6e541a071248f9c99a62ff40a Mon Sep 17 00:00:00 2001 From: hkobew Date: Mon, 11 Nov 2024 15:41:46 -0500 Subject: [PATCH 2/4] refactor closing editors to check if any open --- packages/core/src/test/testUtil.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/src/test/testUtil.ts b/packages/core/src/test/testUtil.ts index 00ad482493b..13d57c94b2e 100644 --- a/packages/core/src/test/testUtil.ts +++ b/packages/core/src/test/testUtil.ts @@ -490,30 +490,30 @@ export async function closeAllEditors(): Promise { /amazonwebservices\.[a-z\-]+-vscode\./, /nullExtensionDescription./, // Sometimes exists instead of the prior line, see https://github.com/aws/aws-toolkit-vscode/issues/4658 ] - const editors: vscode.TextEditor[] = [] + const visibleEditors: vscode.TextEditor[] = [] const noVisibleEditor: boolean | undefined = await waitUntil( async () => { // Race: documents could appear after the call to closeAllEditors(), so retry. await vscode.commands.executeCommand(closeAllCmd) - editors.length = 0 - editors.push( + visibleEditors.length = 0 + visibleEditors.push( ...vscode.window.visibleTextEditors.filter( (editor) => !ignorePatterns.some((p) => p.test(editor.document.fileName)) ) ) - return editors.length === 0 + return visibleEditors.length === 0 }, { - timeout: 1000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. + timeout: 5000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. interval: 250, truthy: true, } ) - if (!noVisibleEditor) { - const editorNames = editors.map((editor) => `\t${editor.document.fileName}`) + if (!noVisibleEditor && visibleEditors.length > 0) { + const editorNames = visibleEditors.map((editor) => `\t${editor.document.fileName}`) throw new Error(`Editors were still open after closeAllEditors():\n${editorNames.join('\n')}`) } } From 3e11dd3f26fbbb6cce0bee2a5d696340c48d6bf5 Mon Sep 17 00:00:00 2001 From: hkobew Date: Mon, 11 Nov 2024 15:45:34 -0500 Subject: [PATCH 3/4] decrease timeout --- packages/core/src/test/testUtil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/test/testUtil.ts b/packages/core/src/test/testUtil.ts index 13d57c94b2e..d40cf672956 100644 --- a/packages/core/src/test/testUtil.ts +++ b/packages/core/src/test/testUtil.ts @@ -506,7 +506,7 @@ export async function closeAllEditors(): Promise { return visibleEditors.length === 0 }, { - timeout: 5000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. + timeout: 1000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. interval: 250, truthy: true, } From a9ca3b11cc786c49408c8c338d39b5c8f714d503 Mon Sep 17 00:00:00 2001 From: hkobew Date: Mon, 11 Nov 2024 15:48:54 -0500 Subject: [PATCH 4/4] rename var to be more consistent with queue-like purpose --- packages/core/src/test/testUtil.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/src/test/testUtil.ts b/packages/core/src/test/testUtil.ts index d40cf672956..eac5ffc2a2b 100644 --- a/packages/core/src/test/testUtil.ts +++ b/packages/core/src/test/testUtil.ts @@ -490,20 +490,20 @@ export async function closeAllEditors(): Promise { /amazonwebservices\.[a-z\-]+-vscode\./, /nullExtensionDescription./, // Sometimes exists instead of the prior line, see https://github.com/aws/aws-toolkit-vscode/issues/4658 ] - const visibleEditors: vscode.TextEditor[] = [] + const editorsToClose: vscode.TextEditor[] = [] const noVisibleEditor: boolean | undefined = await waitUntil( async () => { // Race: documents could appear after the call to closeAllEditors(), so retry. await vscode.commands.executeCommand(closeAllCmd) - visibleEditors.length = 0 - visibleEditors.push( + editorsToClose.length = 0 + editorsToClose.push( ...vscode.window.visibleTextEditors.filter( (editor) => !ignorePatterns.some((p) => p.test(editor.document.fileName)) ) ) - return visibleEditors.length === 0 + return editorsToClose.length === 0 }, { timeout: 1000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. @@ -512,8 +512,8 @@ export async function closeAllEditors(): Promise { } ) - if (!noVisibleEditor && visibleEditors.length > 0) { - const editorNames = visibleEditors.map((editor) => `\t${editor.document.fileName}`) + if (!noVisibleEditor && editorsToClose.length > 0) { + const editorNames = editorsToClose.map((editor) => `\t${editor.document.fileName}`) throw new Error(`Editors were still open after closeAllEditors():\n${editorNames.join('\n')}`) } }