# PowerShell script to run tests in WSL2 # Usage: .\scripts\run-wsl-tests.ps1 $ErrorActionPreference = "Stop" Write-Host "=== Running Admin Service Tests in WSL2 ===" -ForegroundColor Blue # Get the current directory in Windows format $currentDir = Get-Location $scriptPath = Join-Path $currentDir "scripts\test-in-wsl.sh" # Convert Windows path to WSL path $wslPath = $currentDir.Path -replace '^([A-Z]):', '/mnt/$1' -replace '\\', '/' $wslPath = $wslPath.ToLower() Write-Host "Current directory: $currentDir" -ForegroundColor Yellow Write-Host "WSL path: $wslPath" -ForegroundColor Yellow # Check if WSL is available try { $wslVersion = wsl --version Write-Host "WSL is available" -ForegroundColor Green } catch { Write-Host "ERROR: WSL is not installed or not available" -ForegroundColor Red exit 1 } # Make script executable and run it in WSL Write-Host "Running test script in WSL..." -ForegroundColor Yellow wsl -d Ubuntu -e bash -c "cd '$wslPath' && chmod +x scripts/test-in-wsl.sh && ./scripts/test-in-wsl.sh" if ($LASTEXITCODE -eq 0) { Write-Host "`n=== Tests completed successfully ===" -ForegroundColor Green } else { Write-Host "`n=== Tests failed ===" -ForegroundColor Red exit $LASTEXITCODE }