|
2 | 2 | * Copyright (C) Microsoft Corporation. All rights reserved.
|
3 | 3 | *--------------------------------------------------------*/
|
4 | 4 |
|
5 |
| -import ChildProcess = require("child_process"); |
| 5 | +import * as path from "path"; |
6 | 6 | import vscode = require("vscode");
|
7 |
| -import Window = vscode.window; |
8 | 7 | import { IFeature, LanguageClient } from "../feature";
|
9 | 8 | import { SessionManager } from "../session";
|
10 | 9 | import Settings = require("../settings");
|
@@ -36,26 +35,35 @@ export class PesterTestsFeature implements IFeature {
|
36 | 35 | const currentDocument = vscode.window.activeTextEditor.document;
|
37 | 36 | const settings = Settings.load();
|
38 | 37 |
|
| 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 | + |
39 | 42 | const launchConfig = {
|
40 | 43 | request: "launch",
|
41 | 44 | type: "PowerShell",
|
42 | 45 | name: "PowerShell Launch Pester Tests",
|
43 | 46 | script: "Invoke-Pester",
|
44 | 47 | args: [
|
45 |
| - `-Script "${uri.fsPath}"`, |
46 |
| - describeBlockName |
47 |
| - ? `-TestName '${describeBlockName}'` |
48 |
| - : "", |
| 48 | + "-Script", |
| 49 | + `'${scriptPath}'`, |
| 50 | + "-PesterOption", |
| 51 | + "@{IncludeVSCodeMarker=$true}", |
49 | 52 | ],
|
50 | 53 | internalConsoleOptions: "neverOpen",
|
51 | 54 | noDebug: !runInDebugger,
|
52 | 55 | createTemporaryIntegratedConsole: settings.debugging.createTemporaryIntegratedConsole,
|
53 | 56 | cwd:
|
54 | 57 | currentDocument.isUntitled
|
55 | 58 | ? vscode.workspace.rootPath
|
56 |
| - : currentDocument.fileName, |
| 59 | + : path.dirname(currentDocument.fileName), |
57 | 60 | };
|
58 | 61 |
|
| 62 | + if (describeBlockName) { |
| 63 | + launchConfig.args.push("-TestName"); |
| 64 | + launchConfig.args.push(`'${describeBlockName}'`); |
| 65 | + } |
| 66 | + |
59 | 67 | // Create or show the interactive console
|
60 | 68 | // TODO #367: Check if "newSession" mode is configured
|
61 | 69 | vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true);
|
|
0 commit comments