Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7883879

Browse files
Fix Pester CodeLens not working for running/debugging tests (#1615)
* Fix Pester CodeLens not working for running/debugging tests Fixes #1500 * Single quote/escape script path passed in -Script param in dbg pester Use same Pester output format that tasks use for user familiarity * Remove unnecessary string interpolation.
1 parent 6f576e4 commit 7883879

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

‎src/features/PesterTests.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import ChildProcess= require("child_process");
5+
import *aspathfrom"path";
66
import vscode = require("vscode");
7-
import Window = vscode.window;
87
import { IFeature, LanguageClient } from "../feature";
98
import { SessionManager } from "../session";
109
import Settings = require("../settings");
@@ -36,26 +35,35 @@ export class PesterTestsFeature implements IFeature {
3635
const currentDocument = vscode.window.activeTextEditor.document;
3736
const settings = Settings.load();
3837

38+
// Since we pass the script path to PSES in single quotes to avoid issues with PowerShell
39+
// special chars like & $ @ () [], we do have to double up the interior single quotes.
40+
const scriptPath = uri.fsPath.replace(/'/g, "''");
41+
3942
const launchConfig = {
4043
request: "launch",
4144
type: "PowerShell",
4245
name: "PowerShell Launch Pester Tests",
4346
script: "Invoke-Pester",
4447
args: [
45-
`-Script "${uri.fsPath}"`,
46-
describeBlockName
47-
? `-TestName '${describeBlockName}'`
48-
: "",
48+
"-Script",
49+
`'${scriptPath}'`,
50+
"-PesterOption",
51+
"@{IncludeVSCodeMarker=$true}",
4952
],
5053
internalConsoleOptions: "neverOpen",
5154
noDebug: !runInDebugger,
5255
createTemporaryIntegratedConsole: settings.debugging.createTemporaryIntegratedConsole,
5356
cwd:
5457
currentDocument.isUntitled
5558
? vscode.workspace.rootPath
56-
: currentDocument.fileName,
59+
: path.dirname(currentDocument.fileName),
5760
};
5861

62+
if (describeBlockName) {
63+
launchConfig.args.push("-TestName");
64+
launchConfig.args.push(`'${describeBlockName}'`);
65+
}
66+
5967
// Create or show the interactive console
6068
// TODO #367: Check if "newSession" mode is configured
6169
vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /