tools: add offline rpa window watchdog
This commit is contained in:
45
scripts/test-open-offline-real-client-window-watchdog.ps1
Normal file
45
scripts/test-open-offline-real-client-window-watchdog.ps1
Normal file
@@ -0,0 +1,45 @@
|
||||
param(
|
||||
[string]$ScriptPath = "scripts/open-offline-real-client-window.ps1"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
||||
$target = if ([System.IO.Path]::IsPathRooted($ScriptPath)) {
|
||||
$ScriptPath
|
||||
}
|
||||
else {
|
||||
Join-Path $repo $ScriptPath
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $target)) {
|
||||
throw "script not found: $target"
|
||||
}
|
||||
|
||||
$text = Get-Content -LiteralPath $target -Raw
|
||||
|
||||
$requiredPatterns = @(
|
||||
@{ Name = "WatchSeconds parameter"; Pattern = '\[int\]\$WatchSeconds' },
|
||||
@{ Name = "PollIntervalMs parameter"; Pattern = '\[int\]\$PollIntervalMs' },
|
||||
@{ Name = "watch loop output"; Pattern = 'watch_iteration_count' },
|
||||
@{ Name = "relaunch counter output"; Pattern = 'relaunch_count' },
|
||||
@{ Name = "move repair counter output"; Pattern = 'repair_count' },
|
||||
@{ Name = "closed window recovery"; Pattern = 'Relaunch-OfflineClient' },
|
||||
@{ Name = "moved window recovery"; Pattern = 'Repair-ClientWindowPlacement' }
|
||||
)
|
||||
|
||||
$missing = @()
|
||||
foreach ($item in $requiredPatterns) {
|
||||
if ($text -notmatch $item.Pattern) {
|
||||
$missing += $item.Name
|
||||
}
|
||||
}
|
||||
|
||||
if ($missing.Count -gt 0) {
|
||||
throw "watchdog contract missing: $($missing -join ', ')"
|
||||
}
|
||||
|
||||
[pscustomobject]@{
|
||||
ok = $true
|
||||
script = $target
|
||||
checked = $requiredPatterns.Count
|
||||
} | ConvertTo-Json -Compress
|
||||
Reference in New Issue
Block a user