summaryrefslogtreecommitdiff
path: root/scripts/windows_input/Bootstrap.ps1
diff options
context:
space:
mode:
authorakbash <akbash@herdr.dev>2026-09-18 02:13:13 +0300
committerGitHub <noreply@github.com>2026-09-18 01:13:13 +0200
commitb88e8116e9e1f7e2f6e8b211536311cd17feca9a (patch)
tree699535f31233ae1aee63a110bdbf2e989ba0878b /scripts/windows_input/Bootstrap.ps1
parent14351f121f6fc8c84b7c6c6eda78ad210e93cfcb (diff)
test: add local windows input gauntlet (#4298)
* test: add local windows input gauntlet refs #4251 * test: add local windows input gauntlet Harden elevation and channel identity checks, distinguish known host limitations, and surface incomplete cleanup. refs #4251 * test(windows): harden input gauntlet execution refs #4251 * test(windows): make input gauntlet self-contained refs #4251 * test(windows): bound input gauntlet failure paths refs #4251 * test(windows): extend input qualification gauntlet refs #4251 * test(windows): complete input qualification matrix refs #4251 --------- Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Jonathan Liebig <jonathan.liebig@gmail.com>
Diffstat (limited to 'scripts/windows_input/Bootstrap.ps1')
-rw-r--r--scripts/windows_input/Bootstrap.ps151
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/windows_input/Bootstrap.ps1 b/scripts/windows_input/Bootstrap.ps1
new file mode 100644
index 00000000..4f6884fb
--- /dev/null
+++ b/scripts/windows_input/Bootstrap.ps1
@@ -0,0 +1,51 @@
+#Requires -Version 7.0
+param([Parameter(Mandatory)][string] $PlanPath)
+. "$PSScriptRoot/Common.ps1"
+$plan = Read-GauntletJson $PlanPath
+# Terminal activation can inherit another process's environment. Normalize here too.
+foreach ($item in @(Get-ChildItem Env:)) {
+ if ($item.Name -like 'HERDR_*' -or $item.Name -in @('SSH_CONNECTION', 'SSH_TTY')) { Remove-Item "Env:$($item.Name)" }
+}
+$env:HERDR_CONFIG_PATH = $plan.config
+$env:XDG_CONFIG_HOME = $plan.config_home
+$env:HERDR_SESSION = $plan.session
+if ($plan.profile -ne 'default') { $env:HERDR_WINDOWS_INPUT_PROBE = $plan.profile }
+Add-Type -Path "$PSScriptRoot/Native.cs"
+$before = [HerdrInputGauntlet.ConsoleProbe]::Geometry()
+$child = $null
+try {
+ if ($plan.path -eq 'herdr') {
+ $child = New-GauntletProcess $plan.exe @('--session', $plan.session) $plan
+ } else {
+ $child = New-GauntletProcess $plan.pwsh @('-NoProfile', '-File', "$PSScriptRoot/Probe.ps1", '-PlanPath', $PlanPath) $plan
+ }
+ $sequence = 0
+ while (-not $child.HasExited -and (Test-GauntletLease $plan.root) -and -not (Test-Path (Join-Path $plan.work 'stop'))) {
+ $sequence++
+ Write-GauntletJson (Join-Path $plan.work 'outer.json') @{
+ nonce = $plan.nonce; pid = $PID; child_pid = $child.Id; sequence = $sequence
+ geometry = [HerdrInputGauntlet.ConsoleProbe]::Geometry(); before = $before
+ }
+ Start-Sleep -Milliseconds 100
+ }
+} finally {
+ $cleanup = @()
+ if ($null -ne $child) {
+ # Allow normal detach / observer disposal before forcing this owned child down.
+ if (-not $child.WaitForExit(5000)) {
+ $cleanup += 'Child required forced termination; normal console restoration was not qualified'
+ $child.Kill($true)
+ if (-not $child.WaitForExit(5000)) { $cleanup += 'Child remained active after forced termination' }
+ }
+ $child.Dispose()
+ }
+ if ($plan.path -eq 'herdr') {
+ foreach ($verb in @('stop', 'delete')) {
+ try { $null = Invoke-GauntletProcess $plan.exe @('session', $verb, $plan.session) $plan }
+ catch { $cleanup += $_.ToString() }
+ }
+ }
+ Write-GauntletJson (Join-Path $plan.work 'bootstrap-exit.json') @{
+ nonce = $plan.nonce; before = $before; after = [HerdrInputGauntlet.ConsoleProbe]::Geometry(); cleanup_errors = $cleanup
+ }
+}