diff --git a/lib/windows/AutoOS.ClaudeAutostart.psm1 b/lib/windows/AutoOS.ClaudeAutostart.psm1 index 98c4a9f..2e20b02 100644 --- a/lib/windows/AutoOS.ClaudeAutostart.psm1 +++ b/lib/windows/AutoOS.ClaudeAutostart.psm1 @@ -43,7 +43,7 @@ function Get-AutoOSClaudeDefaults { foreach ($p in $block.PSObject.Properties) { $table[$p.Name] = $p.Value } if ($table.Count -gt 0) { return $table } } - } catch { } + } catch { $_ | Out-Null } } @{ enabled = $true; snapshot_interval_mins = 5; liveness_window_mins = 240 @@ -272,7 +272,7 @@ function Get-AutoOSClaudeState { sessions = @($doc.sessions) } } - } catch { } + } catch { $_ | Out-Null } } [pscustomobject]@{ version = $script:StateVersion; captured_at = 0; captured_at_iso = $null; sessions = @() } } diff --git a/lib/windows/AutoOS.Detect.psm1 b/lib/windows/AutoOS.Detect.psm1 index b1934ec..871dda5 100644 --- a/lib/windows/AutoOS.Detect.psm1 +++ b/lib/windows/AutoOS.Detect.psm1 @@ -122,7 +122,7 @@ function Get-AutoOSWingetPackageProcess { $process = [Diagnostics.Process]::Start($psi) # Close stdin so a prompt that slipped past --disable-interactivity reads # EOF and gives up, instead of sitting there until the timeout. - try { $process.StandardInput.Close() } catch { } + try { $process.StandardInput.Close() } catch { $_ | Out-Null } $process } catch { $null } } @@ -144,7 +144,7 @@ function Get-AutoOSWingetPackageResult { $Process.Kill() } } catch { $packages = @() } - finally { try { $Process.Dispose() } catch { } } + finally { try { $Process.Dispose() } catch { $_ | Out-Null } } $packages } diff --git a/lib/windows/AutoOS.Serve.psm1 b/lib/windows/AutoOS.Serve.psm1 index f732bf6..1aa1345 100644 --- a/lib/windows/AutoOS.Serve.psm1 +++ b/lib/windows/AutoOS.Serve.psm1 @@ -266,7 +266,7 @@ function Get-AutoOSExampleBlock { try { $block = (Get-Content -LiteralPath $path -Raw -Encoding UTF8 | ConvertFrom-Json).$Name if ($block) { return $block } - } catch { } + } catch { $_ | Out-Null } @{} } @@ -286,7 +286,7 @@ function Get-AutoOSDetectedAnswers { try { $value = (& git config --global $pair.Setting 2>$null | Select-Object -First 1) if ($value) { $answers[$pair.Key] = [string]$value } - } catch { } + } catch { $_ | Out-Null } } $answers } diff --git a/tests/run-tests.ps1 b/tests/run-tests.ps1 index fab45f6..48b3b44 100644 --- a/tests/run-tests.ps1 +++ b/tests/run-tests.ps1 @@ -304,7 +304,7 @@ Test-Case 'a different product sharing a prefix is never matched' { Test-Case 'the shim directories package managers use are probed even when PATH is stale' { $dirs = @(Get-AutoOSShimDirectory) - foreach ($want in @('scoop\shims', 'chocolatey\bin', 'Microsoft\WinGet\Links')) { + foreach ($want in @('scoop\shims', 'chocolatey\bin', 'Microsoft\WinGet\Links', 'WinGet\Links')) { if (-not @($dirs | Where-Object { $_ -like "*$want*" })) { throw "no probe directory for $want in: $($dirs -join '; ')" } diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 7e759a8..73335ce 100644 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -1490,6 +1490,38 @@ if it "shellcheck is clean"; then fi fi +# ─── Process ──────────────────────────────────────────────────────────────── +describe "process wrapper" + +if it "process.py run() rejects invalid timeout limits"; then + failures="$(python3 - <<'PY' +import sys +import os +import io +import contextlib +sys.path.insert(0, './lib/linux') +import process + +failures = [] + +for bad in ["0", "86401", "not_a_number"]: + os.environ["AUTOOS_INSTALL_TIMEOUT_SECONDS"] = bad + stderr = io.StringIO() + with contextlib.redirect_stderr(stderr): + res = process.run(["echo", "test"]) + if res != 2: + failures.append(f"Expected 2 for {bad}, got {res}") + err_out = stderr.getvalue() + if "between 1 and 86400" not in err_out: + failures.append(f"Expected error message for {bad}, got: {err_out}") + +if failures: + print("\n".join(failures)) +PY +)" + if [[ -z "$failures" ]]; then pass; else fail "$failures"; fi +fi + # ─── Summary ──────────────────────────────────────────────────────────────── printf '\n%s%s%s\n' "$DIM" "$(printf '─%.0s' $(seq 1 56))" "$RESET" printf ' %spassed %d%s %sfailed %d%s %sskipped %d%s\n' \