Status: Done (2026-02-24)
Priority: Medium
Component: tools/pslib/wsl/ (8 source files, 8 test files)
Description:
Removed 32 redundant Test-WslInstalled guard blocks from 8 source files and ~250 Mock Test-WslInstalled { $true } boilerplate lines from 8 test files. WSL 2 availability is now validated once at the Invoke-WslManager entry point via a new Assert-Wsl2Installed function. This also upgraded the check from WSL 1 detection to WSL 2 detection (wsl --version only exists in the WSL 2 store app).
Acceptance Criteria:
- New
Assert-Wsl2Installedfunction that throws if WSL 2 is not installed -
Invoke-WslManagercalls the assertion once before dispatching - All 32
if (-not (Test-WslInstalled))guard blocks removed from individual functions - 23 "When WSL is not installed" test contexts deleted from test files
- ~250
Mock Test-WslInstalled { $true }lines removed from remaining test contexts - Mocks preserved in
Test-WslInstalledandAssert-Wsl2Installedtest describes -
Test-WslInstalled(the boolean check) remains available for non-throwing use cases - All tests pass (27 redundant guard tests removed)
- No change in user-facing behavior