Skip to content

Commit

Permalink
adding new pester test
Browse files Browse the repository at this point in the history
  • Loading branch information
santisq committed Jun 24, 2024
1 parent e85785f commit 4d10b1a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/PSParallelPipeline.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,22 @@ Describe PSParallelPipeline {

$dict[$PID].ProcessName | Should -Be (Get-Process -Id $PID).ProcessName
}

It 'Stops processing on CTRL+C' {
try {
$timer = [Stopwatch]::StartNew()
$ps = [powershell]::Create([RunspaceMode]::NewRunspace).
AddScript('0..10 | Invoke-Parallel { Start-Sleep 1; $_ }')
$async = $ps.BeginInvoke()
Start-Sleep 1
$async = $ps.BeginStop($ps.EndStop, $null)
while (-not $async.AsyncWaitHandle.WaitOne(200)) { }
$timer.Stop()
$timer.Elapsed | Should -BeLessOrEqual ([timespan]::FromSeconds(1.5))
}
finally {
$ps.Dispose()
}
}
}
}

0 comments on commit 4d10b1a

Please sign in to comment.