|
| 1 | +// Copyright (c) Microsoft Corporation. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +import * as assert from "assert"; |
| 5 | +import { ConfigurationTarget, DebugConfiguration, DebugSession, debug, workspace } from "vscode"; |
| 6 | +import { ensureEditorServicesIsConnected } from "../utils"; |
| 7 | + |
| 8 | + |
| 9 | +// Create a fixture that mocks the DebugSessionFeature |
| 10 | +// and provides a way to call the onDidTerminateDebugSession event |
| 11 | + |
| 12 | +describe("Basic Debug Test", () => { |
| 13 | + before(async () => { |
| 14 | + // Change the vscode setting debug.toolBarLocation to hidden |
| 15 | + // This is to prevent the debug toolbar from appearing in the test |
| 16 | + // and causing the test to fail due to the dialog manager not wanting to show dialogs |
| 17 | + // await workspace.getConfiguration("debug").update("toolBarLocation", "hidden"); |
| 18 | + await ensureEditorServicesIsConnected(); |
| 19 | + }); |
| 20 | + |
| 21 | + //FIXME: Test currently failing due to https://github.com/microsoft/vscode-test/issues/207 |
| 22 | + it.skip("should start and stop debugging session", async () => { |
| 23 | + const debugConfig: DebugConfiguration = { |
| 24 | + type: "PowerShell Interactive Session", |
| 25 | + name: "Debug Test", |
| 26 | + request: "launch" |
| 27 | + }; |
| 28 | + |
| 29 | + // Inspect the debug session via the started events to ensure it is correct |
| 30 | + let debugSession: DebugSession; |
| 31 | + debug.onDidStartDebugSession((newDebugSession) => { |
| 32 | + debugSession = newDebugSession; |
| 33 | + assert.strictEqual(newDebugSession.name, debugConfig.name, "Started debug session should have the correct name"); |
| 34 | + debug.onDidTerminateDebugSession((terminatedDebugSession) => { |
| 35 | + assert.strictEqual(terminatedDebugSession.name, debugConfig.name, "Terminated debug session should have the correct name"); |
| 36 | + }); |
| 37 | + }); |
| 38 | + |
| 39 | + const debugSessionStarted = await debug.startDebugging(undefined, debugConfig); |
| 40 | + assert.ok(debugSessionStarted, "Debug session should start"); |
| 41 | + |
| 42 | + // debugSession var should be populated from the event before startDebugging completes |
| 43 | + const debugSessionStopped = await debug.stopDebugging(debugSession!); |
| 44 | + |
| 45 | + assert.ok(debugSessionStopped, "Debug session should stop"); |
| 46 | + }); |
| 47 | +}); |
0 commit comments