mandelbrot/scripts/test-all.ps1

41 lines
2.2 KiB
PowerShell
Raw Normal View History

2026-08-22 20:55:27 +09:00
param([switch]$RequireToolchain)
$ErrorActionPreference = 'Stop'
$workspace = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '..')).Path
function Run-CheckedPowerShell([string]$Path) {
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $Path
if ($LASTEXITCODE -ne 0) { throw "PowerShell test failed: $Path" }
}
Run-CheckedPowerShell (Join-Path $workspace 'tests\kernel-source-contract.ps1')
Run-CheckedPowerShell (Join-Path $workspace 'tests\source-contract.ps1')
2026-08-23 17:12:29 +09:00
Run-CheckedPowerShell (Join-Path $workspace 'tests\document-contract.ps1')
2026-08-22 20:55:27 +09:00
$node = Get-Command node -ErrorAction SilentlyContinue
if ($node) {
foreach ($test in @('js-syntax.mjs','module-clone.mjs','precision-reference.mjs','analytic-interior.mjs','pixel-mapping.mjs','pixel-contract.mjs','runtime-budget.mjs')) {
& $node.Source (Join-Path $workspace "tests\$test")
if ($LASTEXITCODE -ne 0) { throw "Node regression test failed: $test" }
}
} elseif ($RequireToolchain) { throw 'Node.js is required by -RequireToolchain.' }
else { Write-Warning 'Node.js is unavailable; executable JavaScript/WASM tests were skipped.' }
$clang = Get-Command clang -ErrorAction SilentlyContinue
$sourceGolden = $false
if ($clang -and $node -and ((& $clang.Source --version | Select-Object -First 1) -match '17\.0\.6')) {
$generated = & powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $workspace 'scripts\build-wasm.ps1') -Compiler $clang.Source
if ($LASTEXITCODE -ne 0) { throw 'Source-WASM build failed.' }
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $workspace 'tests\kernel-golden.ps1') -GeneratedDirectory (Split-Path $generated)
if ($LASTEXITCODE -ne 0) { throw 'Generated-WASM golden failed.' }
$sourceGolden = $true
} elseif ($RequireToolchain) { throw 'clang 17.0.6 is required by -RequireToolchain.' }
else { Write-Warning 'clang 17.0.6 is unavailable; source-WASM build/golden was skipped.' }
2026-08-23 17:12:29 +09:00
$status = if ($node -and $sourceGolden) { 'pass' } else { 'partial' }
[ordered]@{
status=$status
sourceContracts=$true
documentContract=$true
nodeTests=[bool]$node
sourceWasmGolden=$sourceGolden
note=if ($status -eq 'partial') { 'Use -RequireToolchain for a full pass; skipped gates are not pass.' } else { $null }
} | ConvertTo-Json