Repository navigation
Fix Parent property on processes with complex name #17545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2d0d3d4
f8adcee
9d3c688
a4d5472
ed8c6db
025f30d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -22,7 +22,7 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') { | |||||
| $pwshVersion.FileBuildPart | Should -BeExactly $PSVersionTable.PSVersion.Patch | ||||||
| $gitCommitId = $PSVersionTable.GitCommitId | ||||||
| if ($gitCommitId.StartsWith("v")) { $gitCommitId = $gitCommitId.Substring(1) } | ||||||
| $productVersion = $pwshVersion.ProductVersion.Replace(" Commits: ","-").Replace(" SHA: ","-g") | ||||||
| $productVersion = $pwshVersion.ProductVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g") | ||||||
| $productVersion | Should -Match $gitCommitId | ||||||
| } else { | ||||||
| $pwshVersion.FileVersion | Should -BeNullOrEmpty | ||||||
|
|
@@ -46,7 +46,7 @@ Describe "Get-Process" -Tags "CI" { | |||||
| $idleProcessPid = 0 | ||||||
| } | ||||||
| It "Should return a type of Object[] for Get-Process cmdlet" -Pending:$IsMacOS { | ||||||
| ,$ps | Should -BeOfType System.Object[] | ||||||
| , $ps | Should -BeOfType System.Object[] | ||||||
| } | ||||||
|
|
||||||
| It "Should have not empty Name flags set for Get-Process object" -Pending:$IsMacOS { | ||||||
|
|
@@ -78,7 +78,7 @@ Describe "Get-Process" -Tags "CI" { | |||||
| (Get-Process -Id $PID).Id | Should -BeExactly $PID | ||||||
| } | ||||||
|
|
||||||
| It "Should fail to run Get-Process with -IncludeUserName without admin" -Skip:(!$IsWindows) { | ||||||
| It "Should fail to run Get-Process with -IncludeUserName without admin" -Skip:(!$IsWindows) { | ||||||
| { Get-Process -IncludeUserName } | Should -Throw -ErrorId "IncludeUserNameRequiresElevation,Microsoft.PowerShell.Commands.GetProcessCommand" | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -95,7 +95,7 @@ Describe "Get-Process" -Tags "CI" { | |||||
| { Get-Process -FileVersionInfo -ErrorAction Stop } | Should -Throw -ErrorId "CouldNotEnumerateFileVer,Microsoft.PowerShell.Commands.GetProcessCommand" | ||||||
| } | ||||||
|
|
||||||
| It "Should return CommandLine property" -Skip:($IsMacOS) { | ||||||
| It "Should return CommandLine property" -Skip:($IsMacOS) { | ||||||
| $command = "(Get-Process -Id `$pid).CommandLine" | ||||||
| $result = & "$PSHOME/pwsh" -NoProfile -NonInteractive -Command $command | ||||||
| $result | Should -BeLike "*$command*" | ||||||
|
|
@@ -105,19 +105,18 @@ Describe "Get-Process" -Tags "CI" { | |||||
| Describe "Get-Process Formatting" -Tags "Feature" { | ||||||
| BeforeAll { | ||||||
| $skip = $false | ||||||
| if ($IsWindows) | ||||||
| { | ||||||
| if ($IsWindows) { | ||||||
| # on Windows skip this test until issue #11016 is resolved | ||||||
| $skip = $true | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| It "Should not have Handle in table format header" -Skip:$skip { | ||||||
| $types = "System.Diagnostics.Process","System.Diagnostics.Process#IncludeUserName" | ||||||
| $types = "System.Diagnostics.Process", "System.Diagnostics.Process#IncludeUserName" | ||||||
|
|
||||||
| foreach ($type in $types) { | ||||||
| $formatData = Get-FormatData -TypeName $type -PowerShellVersion $PSVersionTable.PSVersion | ||||||
| $tableControls = $formatData.FormatViewDefinition | Where-Object {$_.Control -is "System.Management.Automation.TableControl"} | ||||||
| $tableControls = $formatData.FormatViewDefinition | Where-Object { $_.Control -is "System.Management.Automation.TableControl" } | ||||||
| foreach ($tableControl in $tableControls) { | ||||||
| $tableControl.Control.Headers.Label -match "Handle*" | Should -BeNullOrEmpty | ||||||
| # 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" { | |||||
| $powershellexe = (Get-Process -Id $PID).mainmodule.filename | ||||||
| & $powershellexe -noprofile -command '(Get-Process -Id $PID).Parent.Id' | Should -Be $PID | ||||||
| } | ||||||
|
|
||||||
| It "Can find parent with spaces and parenthesis in the name on non-Windows" -Skip:($IsWindows) { | ||||||
| # Bug. See https://github.com/PowerShell/PowerShell/issues/12908 | ||||||
| $commandName = 't ( e ( s ) t )' | ||||||
|
|
||||||
| $script = @' | ||||||
| #!/bin/sh | ||||||
|
|
||||||
| while true; do sleep 1; done | ||||||
| '@ | ||||||
|
|
||||||
| # Can't use testdrive: as unelevated user doesn't have perms in test in CI | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please reword:
Suggested change
I guess it is because .Net 7 RC1 has a breaking change in Directory.Create() where chmod mask was changed. If so, it might still break something in PowerShell or Pester.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assumed this was just a byproduct of how PowerShell CI is set up. I've not looked into it but I believe the unelevated user may potentially be inheriting the same tmpdir as the elevated account and thus cannot set the execute bit on files in that dir. This is just a guess so your assumption could also be true. |
||||||
| Set-Content -Path /tmp/$commandName -Value $script | ||||||
| chmod +x (Resolve-Path -Path /tmp/$commandName -Relative) | ||||||
| try { | ||||||
| $p = Start-Process -FilePath /tmp/$commandName -PassThru | ||||||
| $p.Parent.Id | Should -Be $pid | ||||||
| } finally { | ||||||
| $p | Stop-Process | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.