diff --git a/package.json b/package.json index 55a542770f..6d705e137e 100644 --- a/package.json +++ b/package.json @@ -501,6 +501,52 @@ "request": "attach", "processId": "current" } + }, + { + "label": "PowerShell: Run Pester Tests", + "description": "Debug Pester Tests detected in your current directory (runs Invoke-Pester)", + "body": { + "name": "PowerShell Run Pester Tests", + "type": "PowerShell", + "request": "launch", + "script": "Invoke-Pester", + "createTemporaryIntegratedConsole": true, + "attachDotnetDebugger": true + } + }, + { + "label": "PowerShell: Interactive Session (Module)", + "description": "Debug commands executed from the PowerShell Extension Terminal after auto-loading your module", + "body": { + "name": "PowerShell: Module Interactive Session", + "type": "PowerShell", + "request": "launch", + "script": "Enter command to import your binary module, for example: \"Import-Module -Force ${workspaceFolder}/path/to/module.psd1|dll\"" + } + }, + { + "label": "PowerShell: Interactive Session (Binary Module)", + "description": "Debug a .NET binary or hybrid module loaded into a PowerShell session. Breakpoints you set in your .NET (C#/F#/VB/etc.) code will be hit upon command execution. You may want to add a compile or watch action as a pre-launch task to this configuration.", + "body": { + "name": "PowerShell: Binary Module Interactive", + "type": "PowerShell", + "request": "launch", + "script": "Enter command to import your binary module, for example: \"Import-Module -Force ${workspaceFolder}/path/to/module.psd1|dll\"", + "createTemporaryIntegratedConsole": true, + "attachDotnetDebugger": true + } + }, + { + "label": "Run Pester Tests (Binary Module)", + "description": "Debug a .NET binary or hybrid module by running Pester tests. Breakpoints you set in your .NET (C#/F#/VB/etc.) code will be hit upon command execution. You may want to add a compile or watch action as a pre-launch task to this configuration.", + "body": { + "name": "PowerShell: Binary Module Pester Tests", + "type": "PowerShell", + "request": "launch", + "script": "Invoke-Pester", + "createTemporaryIntegratedConsole": true, + "attachDotnetDebugger": true + } } ], "configurationAttributes": { diff --git a/src/features/DebugSession.ts b/src/features/DebugSession.ts index 792d92ebed..38d9eef462 100644 --- a/src/features/DebugSession.ts +++ b/src/features/DebugSession.ts @@ -21,7 +21,8 @@ import { CancellationTokenSource, InputBoxOptions, QuickPickItem, - QuickPickOptions + QuickPickOptions, + DebugConfigurationProviderTriggerKind } from "vscode"; import { NotificationType, RequestType } from "vscode-languageclient"; import { LanguageClient } from "vscode-languageclient/node"; @@ -60,6 +61,7 @@ const PREVENT_DEBUG_START = undefined; const PREVENT_DEBUG_START_AND_OPEN_DEBUGCONFIG = null; /** Represents the various built-in debug configurations that will be advertised to the user if they choose "Add Config" from the launch debug config window */ +// NOTE: These are duplicated with what is in package.json until https://github.com/microsoft/vscode/issues/150663#issuecomment-1506134754 is resolved. export const defaultDebugConfigurations: Record = { [DebugConfig.LaunchCurrentFile]: { name: "PowerShell: Launch Current File", @@ -129,7 +131,12 @@ export class DebugSessionFeature extends LanguageClientConsumer constructor(context: ExtensionContext, private sessionManager: SessionManager, private logger: ILogger) { super(); // This "activates" the debug adapter for use with You can only do this once. - context.subscriptions.push(debug.registerDebugConfigurationProvider("PowerShell", this)); + [ + DebugConfigurationProviderTriggerKind.Initial, + DebugConfigurationProviderTriggerKind.Dynamic + ].forEach(triggerKind => { + context.subscriptions.push(debug.registerDebugConfigurationProvider("PowerShell", this, triggerKind)); + }); context.subscriptions.push(debug.registerDebugAdapterDescriptorFactory("PowerShell", this)); } @@ -199,7 +206,7 @@ export class DebugSessionFeature extends LanguageClientConsumer { id: DebugConfig.RunPester, label: "Run Pester Tests (Binary Module)", - description: "Debug a .NET binary or hybrid module by running pester tests. Breakpoints you set in your .NET (C#/F#/VB/etc.) code will be hit upon command execution. You may want to add a compile or watch action as a pre-launch task to this configuration.", + description: "Debug a .NET binary or hybrid module by running Pester tests. Breakpoints you set in your .NET (C#/F#/VB/etc.) code will be hit upon command execution. You may want to add a compile or watch action as a pre-launch task to this configuration.", }, ]; diff --git a/test/features/DebugSession.test.ts b/test/features/DebugSession.test.ts index 191eafa336..3539598c7e 100644 --- a/test/features/DebugSession.test.ts +++ b/test/features/DebugSession.test.ts @@ -64,10 +64,9 @@ describe("DebugSessionFeature", () => { }); createDebugSessionFeatureStub({context: context}); - assert.ok(registerFactoryStub.calledOnce, "Debug adapter factory method called"); - assert.ok(registerProviderStub.calledOnce, "Debug config provider method called"); - assert.equal(context.subscriptions.length, 2, "DebugSessionFeature disposables populated"); + assert.ok(registerProviderStub.calledTwice, "Debug config provider registered for both Initial and Dynamic"); + assert.equal(context.subscriptions.length, 3, "DebugSessionFeature disposables populated"); // TODO: Validate the registration content, such as the language name }); });