Skip to content

Commit 7e58b70

Browse files
committed
giving a bit of wait time to Assert-RunspaceCount
1 parent 4d08cad commit 7e58b70

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

tests/PSParallelPipeline.tests.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ Describe PSParallelPipeline {
137137

138138
Context 'TimeoutSeconds Parameter' {
139139
It 'Stops processing after the specified seconds' {
140+
$wait = 5
141+
if (-not $IsCoreCLR) {
142+
# because pwsh 5.1 fucking sucks!
143+
$wait = 10
144+
}
145+
140146
Assert-RunspaceCount {
141147
$timer = [Stopwatch]::StartNew()
142148
{
@@ -150,7 +156,7 @@ Describe PSParallelPipeline {
150156
} | Should -Throw -ExceptionType ([TimeoutException])
151157
$timer.Stop()
152158
$timer.Elapsed | Should -BeLessOrEqual ([timespan]::FromSeconds(2.2))
153-
}
159+
} -WaitSeconds $wait
154160
}
155161
}
156162

tests/common.psm1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ function Assert-RunspaceCount {
2020
[CmdletBinding()]
2121
param(
2222
[Parameter(Mandatory)]
23-
[scriptblock] $ScriptBlock
23+
[scriptblock] $ScriptBlock,
24+
25+
[Parameter()]
26+
[int] $WaitSeconds = 5
2427
)
2528

2629
try {
2730
$count = @(Get-Runspace).Count
2831
& $ScriptBlock
2932
}
3033
finally {
31-
Start-Sleep 5
34+
Start-Sleep $WaitSeconds
3235
Get-Runspace |
3336
Should -HaveCount $count -Because 'Runspaces should be correctly disposed'
3437
}

0 commit comments

Comments
 (0)