Skip to content

Conversation

@Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Nov 11, 2024

Problem

  • See unreliable test: beforeEach..closeAllEditors failure in Amazon Q tests #5325
  • the following waitUntil is timing out:
    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(
    ...vscode.window.visibleTextEditors.filter(
    (editor) => !ignorePatterns.some((p) => p.test(editor.document.fileName))
    )
    )
    return editors.length === 0
    },
    {
    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}`)
    throw new Error(`Editors were still open after closeAllEditors():\n${editorNames.join('\n')}`)
    }
  • All occurrences of error (AFAIK) fail to list any editors open. This implies waitUntil is timing out even though all editors (that aren't ignored by pattern) are closed.

Solution

A potential explanation is that the executeCommand is taking a long time to close the editors ignored by the patterns, and causing a timeout in waitUntil. In this case, we don't want to error.

  • refactor to also check if activeEditors is cleared. If there aren't any, we shouldn't be throwing an error.
  • Also, decrease timeout to avoid wasting time here during tests (if we can't close ignored editors, don't waste time trying). This code is run between every test so 5 second timeout per test is huge.

License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions
Copy link

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.

@Hweinstock Hweinstock changed the title test(vscode): fix failure to close editors on beforeEach hook. test(vscode): fix failure to close editors on beforeEach hook. (WIP) Nov 11, 2024
@Hweinstock Hweinstock changed the title test(vscode): fix failure to close editors on beforeEach hook. (WIP) test(vscode): fix failure to close editors on beforeEach hook. Nov 11, 2024
@Hweinstock Hweinstock marked this pull request as ready for review November 11, 2024 21:06
@Hweinstock Hweinstock requested a review from a team as a code owner November 11, 2024 21:06
@Hweinstock Hweinstock merged commit a77ec12 into aws:master Nov 11, 2024
31 of 35 checks passed
@Hweinstock Hweinstock deleted the flakyEditorClosing branch November 11, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants