Skip to content

Harness: tests for stream timeouts, leaks, hard kills, start-path parity and throwing callbacks - #60

Merged
HalRiveria-Bot merged 2 commits into
mainfrom
test/runtime-guards
Nov 17, 2026
Merged

HalRiveria-Bot merged 2 commits into
mainfrom
test/runtime-guards

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Several things the README promises had no test, so a regression in them would have shipped green. This adds harness tests for them; all pass on the current code, and nothing in the kit changes.

What changed

  • AO: StreamTimedOut. Only its existence and $false value were checked. Now a cmd /c whose start /b child holds the output pipe past -StreamTimeoutMs 1000 must come back with StreamTimedOut = $true after about a second, through Complete-PkProcess and Invoke-PkProcessWithTimeout.
  • AP: no growth over repeated runs. After a warm-up, 100 more starts on each start path, 60 batches and 80 runspace runs must leave the process's handle count, thread count and Get-Runspace count where they were. The handle count jumps by a few hundred and back between runs on both runtimes (a bare RunspacePool does the same), so each side is the lowest of 20 readings. For the runspace engine only threads and runspaces are checked: its handle noise is as large as any leak worth catching.
  • AQ: "No orphans" under a hard kill. A child PowerShell loads the kit, starts three cmd /c ping jobs and is killed with Stop-Process -Force; none of the pings may survive. Run on both start paths (created inside the Job Object, and the Process.Start fallback).
  • AR: start-path parity. One table of programs run on both start paths must give identical results: an environment variable set by the script, a quoted argument list, UTF-8 output, stderr, the working folder, and exit codes -1073741819 and 2147483647. Also checks the values themselves.
  • AS: callbacks that throw while programs run. For -PollCallback, -GroupCompleteCallback, -JobBuilder, -GroupProvider and -GroupReleaseCheck on the dispatcher, each throwing while a program runs: the exception comes out, no program is left running, and a shared SemaphoreSlim gets every slot back. For -ResultHandler, -PollCallback and -NextJobProvider on the runspace engine, each throwing while two workers run: the exception comes out and the workers' runspaces close.

Testing

Full harness passes in fresh processes on Windows PowerShell 5.1 and PowerShell 7 (505 assertions each). The new sections add about 30 s per runtime. The leak section was also run three times on each runtime on its own, and passed every time.

🤖 Generated with Claude Code

HalRiveria and others added 2 commits November 17, 2026 16:00
…-path parity and throwing callbacks

Tests of behavior the README promises but nothing checked, all passing on
today's code:

- a leftover child holding the output past -StreamTimeoutMs sets
  StreamTimedOut (Complete-PkProcess, Invoke-PkProcessWithTimeout)
- repeated starts (both start paths), batches and runspace runs don't
  grow handles, threads or runspaces once warmed up
- PowerShell killed outright leaves none of its programs running, on
  both start paths
- creating a program inside the Job Object and the Process.Start fallback
  give the same exit codes, output, environment and working folder
- a dispatcher or runspace callback that throws while programs run lets
  the exception out, leaves nothing running and returns shared slots

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Start the fallback's long ping a second after cmd.exe (the documented
fallback race), bound the throwing-callback cases with a time limit, and
report a missing program output as a failure instead of stopping the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 038b85d into main Nov 17, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the test/runtime-guards branch November 17, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants