From 1f9959d7eb7bb49f4608c8b590518316c5f4861d Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 13 Jan 2019 22:45:03 +0000 Subject: [PATCH 1/5] add run pester tests command and file tab menu --- package.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package.json b/package.json index 341b4623a3..d2a696b1f2 100644 --- a/package.json +++ b/package.json @@ -204,6 +204,11 @@ "title": "Create New Project from Plaster Template", "category": "PowerShell" }, + { + "command": "PowerShell.RunPesterTests", + "title": "Run Pester tests", + "category": "PowerShell" + }, { "command": "PowerShell.OpenExamplesFolder", "title": "Open Examples Folder", @@ -233,6 +238,12 @@ "group": "2_powershell" } ], + "editor/title/context": [ + { + "when": "resourceExtname == .ps1", + "command": "PowerShell.RunPesterTests" + } + ], "view/title": [ { "command": "PowerShell.RefreshCommandsExplorer", From fe41d7b7d5ae5254df45bae9c1d0582bb4cfaa69 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 14 Jan 2019 12:51:28 +0000 Subject: [PATCH 2/5] only add menu for tests.ps1 or Tests.ps1 files --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d2a696b1f2..e27449e18f 100644 --- a/package.json +++ b/package.json @@ -240,7 +240,7 @@ ], "editor/title/context": [ { - "when": "resourceExtname == .ps1", + "when": "resourceFilename =~ /\\.[Tt]ests\\.ps1$/", "command": "PowerShell.RunPesterTests" } ], From 08b8bb5f174423dd139c3141c8bbbfc7cec81251 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 14 Jan 2019 18:44:53 +0000 Subject: [PATCH 3/5] make check for tests.ps1 completely case insensitive --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e27449e18f..cd1759b143 100644 --- a/package.json +++ b/package.json @@ -240,7 +240,7 @@ ], "editor/title/context": [ { - "when": "resourceFilename =~ /\\.[Tt]ests\\.ps1$/", + "when": "resourceFilename =~ /\\.tests\\.ps1$/i", "command": "PowerShell.RunPesterTests" } ], From fb0760e55b66f89bdd30a9e9acd45142c1c2d634 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Wed, 16 Jan 2019 17:50:01 +0000 Subject: [PATCH 4/5] add new commands to separate concerns due to PSES usage with a different file uri. Add support for debugging as well --- package.json | 13 +++++++++++-- src/features/PesterTests.ts | 13 ++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index cd1759b143..94099f6893 100644 --- a/package.json +++ b/package.json @@ -205,10 +205,15 @@ "category": "PowerShell" }, { - "command": "PowerShell.RunPesterTests", + "command": "PowerShell.RunPesterTestsFromFile", "title": "Run Pester tests", "category": "PowerShell" }, + { + "command": "PowerShell.DebugPesterTestsFromFile", + "title": "Debug Pester tests", + "category": "PowerShell" + }, { "command": "PowerShell.OpenExamplesFolder", "title": "Open Examples Folder", @@ -241,7 +246,11 @@ "editor/title/context": [ { "when": "resourceFilename =~ /\\.tests\\.ps1$/i", - "command": "PowerShell.RunPesterTests" + "command": "PowerShell.RunPesterTestsFromFile" + }, + { + "when": "resourceFilename =~ /\\.tests\\.ps1$/i", + "command": "PowerShell.DebugPesterTestsFromFile" } ], "view/title": [ diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index 1cdbfc1298..3c1a271cb0 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -1,4 +1,4 @@ -/*--------------------------------------------------------- + /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ @@ -15,6 +15,17 @@ export class PesterTestsFeature implements IFeature { private languageClient: LanguageClient; constructor(private sessionManager: SessionManager) { + this.command = vscode.commands.registerCommand( + "PowerShell.RunPesterTestsFromFile", + (uriString, runInDebugger, describeBlockName?) => { + this.launchTests(vscode.window.activeTextEditor.document.uri, false, describeBlockName); + }); + this.command = vscode.commands.registerCommand( + "PowerShell.DebugPesterTestsFromFile", + (uriString, runInDebugger, describeBlockName?) => { + this.launchTests(vscode.window.activeTextEditor.document.uri, true, describeBlockName); + }); + // This command is provided for usage by PowerShellEditorServices (PSES) only this.command = vscode.commands.registerCommand( "PowerShell.RunPesterTests", (uriString, runInDebugger, describeBlockName?) => { From 969fa92290aca9531ede5b76f34a46acac4dab96 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Wed, 16 Jan 2019 19:03:44 +0000 Subject: [PATCH 5/5] simplify lambda syntax to minimise parameters and revert accidental whitespace change --- src/features/PesterTests.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index 3c1a271cb0..45111e295b 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -1,4 +1,4 @@ - /*--------------------------------------------------------- +/*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ @@ -17,13 +17,13 @@ export class PesterTestsFeature implements IFeature { constructor(private sessionManager: SessionManager) { this.command = vscode.commands.registerCommand( "PowerShell.RunPesterTestsFromFile", - (uriString, runInDebugger, describeBlockName?) => { - this.launchTests(vscode.window.activeTextEditor.document.uri, false, describeBlockName); + () => { + this.launchTests(vscode.window.activeTextEditor.document.uri, false); }); this.command = vscode.commands.registerCommand( "PowerShell.DebugPesterTestsFromFile", - (uriString, runInDebugger, describeBlockName?) => { - this.launchTests(vscode.window.activeTextEditor.document.uri, true, describeBlockName); + () => { + this.launchTests(vscode.window.activeTextEditor.document.uri, true); }); // This command is provided for usage by PowerShellEditorServices (PSES) only this.command = vscode.commands.registerCommand(