Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/editors/vscode/src/test/suite/debug-test-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
requireWorkspaceRoot,
pollUntilResult,
} from './test-helpers';
import { COMMAND_MS } from './test-timeouts';
import { COMMAND_MS, DEBUG_SESSION_MS } from './test-timeouts';

/** Wait for the actual terminal object to close, not an unrelated queue. */
export async function assertTerminalClosed(terminal: vscode.Terminal): Promise<void> {
Expand All @@ -55,6 +55,22 @@ export async function assertTerminalClosed(terminal: vscode.Terminal): Promise<v
assert.equal(closed, true, 'Stop must settle the owned runner and close its debug terminal');
}

/**
* No `name` terminal survives from an EARLIER test: a debug run's terminal closes
* once that run settles, which can trail its suite by the debuggee's own wait.
* A test that counts terminals starts from none, and a terminal that never closes
* fails here, naming the leak instead of the next test's count.
*/
export async function assertNoTerminalLeft(name: string, why: string): Promise<void> {
const left = await pollUntilResult(
async () => vscode.window.terminals.filter((terminal) => terminal.name === name).length,
(count) => count === 0,
DEBUG_SESSION_MS,
100,
);
assert.equal(left, 0, why);
}

/** Require exactly one named terminal and return the actual object owned by the run. */
export function assertOneTerminal(
name: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
requireActive,
type TestDebugFixture,
assertTerminalClosed,
assertNoTerminalLeft,
assertOneTerminal,
assertDebugCache,
} from './debug-test-kit';
Expand Down Expand Up @@ -112,7 +113,11 @@ for (const language of ['fsharp', 'csharp'] as const) {
});

test('Stop ends its host and terminal, never retries, and the next Debug starts clean', async function () {
this.timeout(DEBUG_TEST_MS * 2);
this.timeout(DEBUG_TEST_MS * 3);
await assertNoTerminalLeft(
TEST_DEBUG_TERMINAL_NAME,
'every earlier debug run closed its terminal once it settled',
);
const api = await activateTestExplorer();
await discoverSolution(api, fixture.solutionPath, [id, 'Other.Unselected']);
const item = findItem(api.testController.items, id);
Expand Down