Skip to content

Commit 519f5aa

Browse files
add path alias test for Start-Process, Tee-Object, and Trace-Command
1 parent d886963 commit 519f5aa

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

src/Modules/Shared/Pester

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 1f546b6aaa0893e215e940a14f57c96f56f7eff1

test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ Describe "Start-Process" -Tags @("Feature") {
4646
# $process.ProcessName | Should Be "ping"
4747
}
4848

49+
It "Should invoke correct path when used with Path alias argument" {
50+
$process = Start-Process -Path $pingCommand -ArgumentList $pingParam -PassThru -RedirectStandardOutput "$TESTDRIVE/output"
51+
52+
$process.Length | Should Be 1
53+
$process.Id | Should BeGreaterThan 1
54+
}
55+
4956
It "Should wait for command completion if used with Wait argument" {
5057
$process = Start-Process ping -ArgumentList $pingParam -Wait -PassThru -RedirectStandardOutput "$TESTDRIVE/output"
5158
}
@@ -110,7 +117,7 @@ Describe "Start-Process" -Tags @("Feature") {
110117
It "Should be able to use the -WhatIf switch without performing the actual action" {
111118
$pingOutput = Join-Path $TestDrive "pingOutput.txt"
112119
{ Start-Process -Wait $pingCommand -ArgumentList $pingParam -RedirectStandardOutput $pingOutput -WhatIf -ErrorAction Stop } | Should Not Throw
113-
$pingOutput | Should Not Exist
120+
$pingOutput | Should Not Exist
114121
}
115122

116123
It "Should return null when using -WhatIf switch with -PassThru" {

test/powershell/Modules/Microsoft.PowerShell.Utility/Tee-Object.Tests.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ Describe "Tee-Object DRT Unit Tests" -Tags "CI" {
3535
$content | Should Be $expected
3636
}
3737

38+
It "Positive File Test with Path parameter alias" {
39+
$expected = "1", "2", "3"
40+
$results = $expected | Tee-Object -Path $tempFile
41+
$results.Length | Should be 3
42+
$results | Should Be $expected
43+
$content = Get-Content $tempFile
44+
$content | Should Be $expected
45+
}
46+
3847
It "Positive Variable Test" {
3948
$expected = "1", "2", "3"
4049
$varName = "teeObjectTestVar"

test/powershell/Modules/Microsoft.PowerShell.Utility/Trace-Command.Tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ Describe "Trace-Command" -tags "CI" {
119119
Get-Content $filePath -Raw | Should Match 'ParameterBinding Information'
120120
}
121121

122+
It "Trace-Command using Path parameter alias" {
123+
$null = New-Item $filePath -Force
124+
Trace-Command -Name ParameterBinding -Command 'Get-PSDrive' -Path $filePath -Force
125+
Get-Content $filePath -Raw | Should Match 'ParameterBinding Information'
126+
}
127+
122128
It "Trace-Command contains wildcard characters" {
123129
$a = Trace-Command -Name ParameterB* -Command 'get-alias'
124130
$a.count | Should BeGreaterThan 0

0 commit comments

Comments
 (0)