Skip to content

Commit

Permalink
Add a test for the powershell hang fix (PowerShell#5451)
Browse files Browse the repository at this point in the history
- Add test for the powershell hang fix
- Ignore the 'Sync-PSTags' warning
  • Loading branch information
daxian-dbw committed Nov 15, 2017
1 parent cef7762 commit c4f0d1c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ Fix steps:
if ($ReleaseTagToUse) {
$ReleaseVersion = $ReleaseTagToUse
} else {
$ReleaseVersion = (Get-PSCommitId) -replace '^v'
$ReleaseVersion = (Get-PSCommitId -WarningAction SilentlyContinue) -replace '^v'
}

Start-NativeExecution { & "~/.rcedit/rcedit-x64.exe" "$($Options.Output)" --set-icon "$PSScriptRoot\assets\Powershell_black.ico" `
Expand Down
24 changes: 24 additions & 0 deletions test/powershell/engine/Api/BasicEngine.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,27 @@ Describe 'Basic engine APIs' -Tags "CI" {
}
}
}

Describe "Clean up open Runspaces when exit powershell process" -Tags "Feature" {
It "PowerShell process should not freeze at exit" {
$command = @'
-c $rs = [runspacefactory]::CreateRunspacePool(1,5)
$rs.Open()
$ps = [powershell]::Create()
$ps.RunspacePool = $rs
$null = $ps.AddScript(1).Invoke()
write-host should_not_hang_at_exit
exit
'@
$process = Start-Process pwsh -ArgumentList $command -PassThru
Wait-UntilTrue -sb { $process.HasExited } -TimeoutInMilliseconds 5000 -IntervalInMilliseconds 1000 > $null

$expect = "powershell process exits in 5 seconds"
if (-not $process.HasExited) {
Stop-Process -InputObject $process -Force -ErrorAction SilentlyContinue
"powershell process doesn't exit in 5 seconds" | Should Be $expect
} else {
$expect | Should Be $expect
}
}
}

0 comments on commit c4f0d1c

Please sign in to comment.