Skip to content

Fix flaky test #4547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2023
Merged
Changes from 1 commit
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
38 changes: 17 additions & 21 deletions test/features/DebugSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,31 +440,27 @@ describe("DebugSessionFeature E2E", function slowTests() {

it("Starts and stops a debugging session", async () => {
// Inspect the debug session via the started events to ensure it is correct
let startDebugSession: DebugSession;
let stopDebugSession: DebugSession;
const interactiveSessionConfig = defaultDebugConfigurations[DebugConfig.InteractiveSession];
// Asserts don't seem to fire in this event or the event doesn't resolve
// in the test code flow, so we need to "extract" the values for later
// use by the asserts

const startDebugEvent = debug.onDidStartDebugSession((newDebugSession) => {
startDebugEvent.dispose();
startDebugSession = newDebugSession;
const stopDebugEvent = debug.onDidTerminateDebugSession((terminatedDebugSession) => {
stopDebugEvent.dispose();
stopDebugSession = terminatedDebugSession;
const startDebugSession = new Promise<DebugSession>((resolve) => {
const event = debug.onDidStartDebugSession((session) => {
resolve(session);
event.dispose();
});
});
const stopDebugSession = new Promise<DebugSession>((resolve) => {
const event = debug.onDidTerminateDebugSession((session) => {
resolve(session);
event.dispose();
});
});

const debugSessionStarted = await debug.startDebugging(undefined, interactiveSessionConfig);
assert.ok(debugSessionStarted, "Debug session should start");
assert.equal(startDebugSession!.name, interactiveSessionConfig.name, "Debug session name should match when started");
// debugSession var should be populated from the event before startDebugging completes
await debug.stopDebugging(startDebugSession!);
const config = defaultDebugConfigurations[DebugConfig.InteractiveSession];
assert.ok(await debug.startDebugging(undefined, config), "Debug session should start");
assert.equal((await startDebugSession).name, config.name, "Debug session name should match when started");

assert.equal(stopDebugSession!.name, interactiveSessionConfig.name, "Debug session name should match when stopped");
assert.equal(stopDebugSession!.configuration.internalConsoleOptions, "neverOpen", "Debug session should always have neverOpen internalConsoleOptions");
assert.ok(stopDebugSession!, "Debug session should stop");
await debug.stopDebugging(await startDebugSession);
assert.ok(await stopDebugSession, "Debug session should stop");
assert.equal((await stopDebugSession).name, config.name, "Debug session name should match when stopped");
assert.equal((await stopDebugSession).configuration.internalConsoleOptions, "neverOpen", "Debug session should always have neverOpen internalConsoleOptions");
});

describe("Binary Modules", () => {
Expand Down