From 355b83e84d857fe9c6da29021142f4cbbc5e7d81 Mon Sep 17 00:00:00 2001 From: Soutaro Matsumoto Date: Mon, 9 Mar 2026 14:27:19 +0900 Subject: [PATCH 1/2] Wait for 30secs --- vscode/src/test/suite/testController.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/src/test/suite/testController.test.ts b/vscode/src/test/suite/testController.test.ts index be904e49a1..cc80dcf2ea 100644 --- a/vscode/src/test/suite/testController.test.ts +++ b/vscode/src/test/suite/testController.test.ts @@ -749,7 +749,7 @@ suite("TestController", () => { assert.ok(runStub.started.calledWith(testItem)); assert.ok(runStub.passed.calledWith(testItem)); assert.ok(runStub.end.calledWithExactly()); - }).timeout(10000); + }).timeout(30000); test("refresh handler clears all items and starts from scratch", async () => { await controller.testController.resolveHandler!(undefined); From 38eeb3cacf3c5bdfbb62ea838cb9aa463f85f837 Mon Sep 17 00:00:00 2001 From: Soutaro Matsumoto Date: Mon, 9 Mar 2026 14:41:34 +0900 Subject: [PATCH 2/2] Retry the `callCount` assertions --- vscode/src/test/suite/helpers.ts | 18 ++++++++++++++++++ vscode/src/test/suite/workspace.test.ts | 16 ++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/vscode/src/test/suite/helpers.ts b/vscode/src/test/suite/helpers.ts index 6c48a8bfb3..1d3cfd1fff 100644 --- a/vscode/src/test/suite/helpers.ts +++ b/vscode/src/test/suite/helpers.ts @@ -70,3 +70,21 @@ export function createContext() { }, } as unknown as FakeContext; } + +// Retries the given assertion function until it passes or the timeout (in ms) is exceeded. +// Polls every 500ms. If the assertion never passes, the last assertion error is thrown. +export async function retryForDuration(timeoutMs: number, fn: () => void) { + const deadline = Date.now() + timeoutMs; + + while (Date.now() < deadline) { + try { + fn(); + return; + } catch (_error) { + await new Promise((resolve) => setTimeout(resolve, 500)); + } + } + + // Final attempt — let it throw + fn(); +} diff --git a/vscode/src/test/suite/workspace.test.ts b/vscode/src/test/suite/workspace.test.ts index ab8fb9aa88..fe5a20d35a 100644 --- a/vscode/src/test/suite/workspace.test.ts +++ b/vscode/src/test/suite/workspace.test.ts @@ -10,7 +10,7 @@ import { beforeEach, afterEach } from "mocha"; import { Workspace } from "../../workspace"; import { FAKE_TELEMETRY } from "./fakeTelemetry"; -import { createContext, FakeContext } from "./helpers"; +import { createContext, FakeContext, retryForDuration } from "./helpers"; suite("Workspace", () => { let workspacePath: string; @@ -56,13 +56,13 @@ suite("Workspace", () => { fs.rmSync(path.join(gitDir, "rebase-apply")); } - // Give enough time for all watchers to fire and all debounces to run off - await new Promise((resolve) => setTimeout(resolve, 10000)); - - // The start call only happens once because of the inhibitRestart flag - assert.strictEqual(startStub.callCount, 1); - // The restart call only happens once because of the debounce - assert.strictEqual(restartSpy.callCount, 1); + // Retry assertions for up to 30 seconds to allow watchers and debounces to fire + await retryForDuration(30000, () => { + // The start call only happens once because of the inhibitRestart flag + assert.strictEqual(startStub.callCount, 1); + // The restart call only happens once because of the debounce + assert.strictEqual(restartSpy.callCount, 1); + }); }).timeout(60000); test("does not restart when watched files are touched without modifying contents", async () => {