@@ -22,7 +22,7 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') {
22
22
$pwshVersion.FileBuildPart | Should - BeExactly $PSVersionTable.PSVersion.Patch
23
23
$gitCommitId = $PSVersionTable.GitCommitId
24
24
if ($gitCommitId.StartsWith (" v" )) { $gitCommitId = $gitCommitId.Substring (1 ) }
25
- $productVersion = $pwshVersion.ProductVersion.Replace (" Commits: " , " -" ).Replace(" SHA: " , " -g" )
25
+ $productVersion = $pwshVersion.ProductVersion.Replace (" Commits: " , " -" ).Replace(" SHA: " , " -g" )
26
26
$productVersion | Should -Match $gitCommitId
27
27
} else {
28
28
$pwshVersion.FileVersion | Should - BeNullOrEmpty
@@ -46,7 +46,7 @@ Describe "Get-Process" -Tags "CI" {
46
46
$idleProcessPid = 0
47
47
}
48
48
It " Should return a type of Object[] for Get-Process cmdlet" - Pending:$IsMacOS {
49
- , $ps | Should - BeOfType System.Object[]
49
+ , $ps | Should - BeOfType System.Object[]
50
50
}
51
51
52
52
It " Should have not empty Name flags set for Get-Process object" - Pending:$IsMacOS {
@@ -78,7 +78,7 @@ Describe "Get-Process" -Tags "CI" {
78
78
(Get-Process - Id $PID ).Id | Should - BeExactly $PID
79
79
}
80
80
81
- It " Should fail to run Get-Process with -IncludeUserName without admin" - Skip:(! $IsWindows ) {
81
+ It " Should fail to run Get-Process with -IncludeUserName without admin" - Skip:(! $IsWindows ) {
82
82
{ Get-Process - IncludeUserName } | Should - Throw - ErrorId " IncludeUserNameRequiresElevation,Microsoft.PowerShell.Commands.GetProcessCommand"
83
83
}
84
84
@@ -95,7 +95,7 @@ Describe "Get-Process" -Tags "CI" {
95
95
{ Get-Process - FileVersionInfo - ErrorAction Stop } | Should - Throw - ErrorId " CouldNotEnumerateFileVer,Microsoft.PowerShell.Commands.GetProcessCommand"
96
96
}
97
97
98
- It " Should return CommandLine property" - Skip:($IsMacOS ) {
98
+ It " Should return CommandLine property" - Skip:($IsMacOS ) {
99
99
$command = " (Get-Process -Id `$ pid).CommandLine"
100
100
$result = & " $PSHOME /pwsh" - NoProfile - NonInteractive - Command $command
101
101
$result | Should - BeLike " *$command *"
@@ -105,19 +105,18 @@ Describe "Get-Process" -Tags "CI" {
105
105
Describe " Get-Process Formatting" - Tags " Feature" {
106
106
BeforeAll {
107
107
$skip = $false
108
- if ($IsWindows )
109
- {
108
+ if ($IsWindows ) {
110
109
# on Windows skip this test until issue #11016 is resolved
111
110
$skip = $true
112
111
}
113
112
}
114
113
115
114
It " Should not have Handle in table format header" - Skip:$skip {
116
- $types = " System.Diagnostics.Process" , " System.Diagnostics.Process#IncludeUserName"
115
+ $types = " System.Diagnostics.Process" , " System.Diagnostics.Process#IncludeUserName"
117
116
118
117
foreach ($type in $types ) {
119
118
$formatData = Get-FormatData - TypeName $type - PowerShellVersion $PSVersionTable.PSVersion
120
- $tableControls = $formatData.FormatViewDefinition | Where-Object {$_.Control -is " System.Management.Automation.TableControl" }
119
+ $tableControls = $formatData.FormatViewDefinition | Where-Object { $_.Control -is " System.Management.Automation.TableControl" }
121
120
foreach ($tableControl in $tableControls ) {
122
121
$tableControl.Control.Headers.Label -match " Handle*" | Should - BeNullOrEmpty
123
122
# verify that rows without headers isn't the handlecount (as PowerShell will create a header that matches the property name)
@@ -138,5 +137,26 @@ Describe "Process Parent property" -Tags "CI" {
138
137
$powershellexe = (Get-Process - Id $PID ).mainmodule.filename
139
138
& $powershellexe - noprofile - command ' (Get-Process -Id $PID).Parent.Id' | Should - Be $PID
140
139
}
140
+
141
+ It " Can find parent with spaces and parenthesis in the name on non-Windows" - Skip:($IsWindows ) {
142
+ # Bug. See https://github.com/PowerShell/PowerShell/issues/12908
143
+ $commandName = ' t ( e ( s ) t )'
144
+
145
+ $script = @'
146
+ #!/bin/sh
147
+
148
+ while true; do sleep 1; done
149
+ '@
150
+
151
+ # Can't use testdrive: as unelevated user doesn't have perms in test in CI
152
+ Set-Content - Path / tmp/ $commandName - Value $script
153
+ chmod + x (Resolve-Path - Path / tmp/ $commandName - Relative)
154
+ try {
155
+ $p = Start-Process - FilePath / tmp/ $commandName - PassThru
156
+ $p.Parent.Id | Should - Be $pid
157
+ } finally {
158
+ $p | Stop-Process
159
+ }
160
+ }
141
161
}
142
162
0 commit comments