ci-test/tests/run-tests.ps1
ci 1423c7c11c
Some checks failed
CI Test / hello (push) Successful in 1s
CI Test / windows-test (push) Failing after 41s
CI Test / revert-vm (push) Successful in 8s
ci(windows): scp tests/ into VM and run PowerShell test suite
2026-05-02 06:31:40 -04:00

30 lines
1,004 B
PowerShell

$ErrorActionPreference = 'Stop'
$script:failed = 0
function Assert-True($cond, $msg) {
if ($cond) { Write-Host "PASS: $msg" }
else { Write-Host "FAIL: $msg"; $script:failed++ }
}
Write-Host "=== environment ==="
Write-Host "host=$env:COMPUTERNAME user=$env:USERNAME"
Write-Host "ps=$($PSVersionTable.PSVersion)"
Write-Host "=== tests ==="
Assert-True ($PSVersionTable.PSVersion.Major -ge 5) "PowerShell major >= 5"
Assert-True ((Get-CimInstance Win32_OperatingSystem).Caption -match 'Windows') "OS reports as Windows"
Assert-True ((2 + 2) -eq 4) "arithmetic sanity"
Assert-True ($env:USERNAME -eq 'edr') "running as edr"
$tmp = Join-Path $env:TEMP "ci-write-test.txt"
"hello $(Get-Date -Format o)" | Out-File -Encoding ascii $tmp
Assert-True (Test-Path $tmp) "wrote file under TEMP"
Assert-True ((Get-Content $tmp) -match 'hello') "read file content back"
Remove-Item $tmp -Force
if ($failed -gt 0) {
Write-Host "$failed test(s) failed"
exit 1
}
Write-Host "all tests passed"
exit 0