Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions ParallelKit.Harness.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4883,14 +4883,21 @@ foreach ($rsPath in 'CreatedInJob', 'Process.Start', 'batch') {
foreach ($rsAfter in 0, 1) {
if ($rsPath -eq 'batch' -and $rsAfter -eq 0) { continue }
$rsW++
# On the Process.Start path a program runs before it's added to its Job
# Object, so a child it starts straight away can escape it (the gap the
# README's Limits gives for AddedToJob). There the tagged ping starts a
# second later, and the failing Run waits until it's up.
$rsArgs = '/d /c ping -n 30 -w ' + $rsW + ' 127.0.0.1 >nul'
$rsDelayMs = 0
if ($rsPath -eq 'Process.Start') { $rsArgs = '/d /c ping -n 2 127.0.0.1 >nul & ping -n 30 -w ' + $rsW + ' 127.0.0.1 >nul'; $rsDelayMs = 2500 }
$rsError = $null
[PkChildProcessJob]::TestUseProcessStart = ($rsPath -eq 'Process.Start')
[PkStreamReadTask]::TestFailRunAfter = $rsAfter
[PkStreamReadTask]::TestFailRunDelayMs = $rsDelayMs
try {
if ($rsPath -eq 'batch') { $rsError = [string](Invoke-PkProcessBatch -Commands @(@{ FilePath = $cmdExe; Arguments = $rsArgs })).Results[0].StartError }
else { $null = Start-PkProcess -FilePath $cmdExe -Arguments $rsArgs }
} catch { $rsError = [string]$_ } finally { [PkStreamReadTask]::TestFailRunAfter = -1; [PkChildProcessJob]::TestUseProcessStart = $false }
} catch { $rsError = [string]$_ } finally { [PkStreamReadTask]::TestFailRunAfter = -1; [PkStreamReadTask]::TestFailRunDelayMs = 0; [PkChildProcessJob]::TestUseProcessStart = $false }
$rsWait = [System.Diagnostics.Stopwatch]::StartNew()
do {
$rsLeft = @(Get-CimInstance Win32_Process -Filter "Name='PING.EXE' OR Name='cmd.exe'" | Where-Object { [string]$_.CommandLine -like ('*-w ' + $rsW + ' 127.0.0.1*') })
Expand All @@ -4905,14 +4912,17 @@ foreach ($rsPath in 'CreatedInJob', 'Process.Start', 'batch') {
# The same once the program has exited before the rollback: what it left
# running is still ended, through its tree job (a kill of the program itself
# passes over one that has exited). TestFailRunDelayMs holds the failing Run
# until cmd.exe, which only starts the ping, is gone.
# until cmd.exe, which only starts the ping, is gone. On the Process.Start path
# the ping starts a second later, as above.
foreach ($rxPath in 'CreatedInJob', 'Process.Start') {
$rsW++
$rxArgs = '/d /c start "" /b ping -n 30 -w ' + $rsW + ' 127.0.0.1 >nul'
$rxDelayMs = 2000
if ($rxPath -eq 'Process.Start') { $rxArgs = '/d /c ping -n 2 127.0.0.1 >nul & start "" /b ping -n 30 -w ' + $rsW + ' 127.0.0.1 >nul'; $rxDelayMs = 3500 }
$rxError = $null
[PkChildProcessJob]::TestUseProcessStart = ($rxPath -eq 'Process.Start')
[PkStreamReadTask]::TestFailRunAfter = 1
[PkStreamReadTask]::TestFailRunDelayMs = 2000
[PkStreamReadTask]::TestFailRunDelayMs = $rxDelayMs
try { $null = Start-PkProcess -FilePath $cmdExe -Arguments $rxArgs } catch { $rxError = [string]$_ } finally { [PkStreamReadTask]::TestFailRunAfter = -1; [PkStreamReadTask]::TestFailRunDelayMs = 0; [PkChildProcessJob]::TestUseProcessStart = $false }
$rxWait = [System.Diagnostics.Stopwatch]::StartNew()
do {
Expand Down