Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static PowerShellProcessInstance()
}
Comment thread
SteveL-MSFT marked this conversation as resolved.
Comment thread
SteveL-MSFT marked this conversation as resolved.

/// <summary>
/// Initializes a new instance of the <see cref="PowerShellProcessInstance"/> class. Initializes the underlying dotnet process class.
/// Initializes a new instance of the <see cref="PowerShellProcessInstance"/> class. Initializes the underlying dotnet process class.
/// </summary>
/// <param name="powerShellVersion">Specifies the version of powershell.</param>
/// <param name="credential">Specifies a user account credentials.</param>
Expand All @@ -56,9 +56,9 @@ public PowerShellProcessInstance(Version powerShellVersion, PSCredential credent
{
processArguments = string.Format(
CultureInfo.InvariantCulture,
"{0} -wd {1}",
"{0} -wd \"{1}\"",
processArguments,
workingDirectory);
workingDirectory.Replace("\"", "\"\""));
}

if (initializationScript != null)
Expand Down Expand Up @@ -105,7 +105,7 @@ public PowerShellProcessInstance(Version powerShellVersion, PSCredential credent
}

/// <summary>
/// Initializes a new instance of the <see cref="PowerShellProcessInstance"/> class. Initializes the underlying dotnet process class.
/// Initializes a new instance of the <see cref="PowerShellProcessInstance"/> class. Initializes the underlying dotnet process class.
/// </summary>
/// <param name="powerShellVersion"></param>
/// <param name="credential"></param>
Expand Down
16 changes: 13 additions & 3 deletions test/powershell/engine/Job/Jobs.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,20 @@ Describe 'Basic Job Tests' -Tags 'CI' {
$ProgressMsg[0].StatusDescription | Should -BeExactly 2
}

It 'Can use the user specified working directory parameter' {
$job = Start-Job -ScriptBlock { $pwd } -WorkingDirectory $TestDrive | Wait-Job
It 'Can use the user specified working directory parameter with whitespace' {
$path = Join-Path -Path $TestDrive -ChildPath "My Dir"
$null = New-Item -ItemType Directory -Path "$path"
$job = Start-Job -ScriptBlock { $pwd } -WorkingDirectory $path | Wait-Job
$jobOutput = Receive-Job $job
$jobOutput | Should -BeExactly $TestDrive.ToString()
$jobOutput | Should -BeExactly $path.ToString()
}

It 'Can use the user specified working directory parameter with quote' -Skip:($IsWindows) {
$path = Join-Path -Path $TestDrive -ChildPath "My ""Dir"
$null = New-Item -ItemType Directory -Path "$path"
$job = Start-Job -ScriptBlock { $pwd } -WorkingDirectory $path | Wait-Job
$jobOutput = Receive-Job $job
$jobOutput | Should -BeExactly $path.ToString()
}

It 'Throws an error when the working directory parameter is <case>' -TestCases $invalidPathTestCases {
Expand Down