tests/widths.ps1: do not pipe native stderr into the output stream

The first run died at cell 1: with ErrorActionPreference=Stop a native command
whose stderr is captured through the pipeline becomes a terminating ErrorRecord,
so r8asm's harmless 'cached, 5 blocks' line killed the script.  Native calls now
report through LASTEXITCODE and their stderr goes to \; the configure no
longer passes CMAKE_BUILD_TYPE, which the Visual Studio generator ignores anyway
(it printed a warning per width).
This commit is contained in:
dsh committed 2026-11-15 16:25:56 +08:00
1 parent b7de3cad23
commit e137b09958
1 file changed
+15 -14
+15 -14
View File
@@ -1,20 +1,21 @@
# Build the toolchain at a set of cell widths and run what is meaningful there.
#
# powershell -File tests\widths.ps1 # the full list below
# powershell -File tests\widths.ps1 # 1,2,7,8,11,16,17,31,32
# powershell -File tests\widths.ps1 -Widths 8,11,32 # just these
#
# What is checked per width:
# * the `widthfree` ctest label: bit level slices, the synthesizer, the looping
# demo and the macro comment format (all true at any width);
# * examples/calc.r8asm assembles, and at widths where the ASCII constants fit
# (>= 6) it also runs one session through r8forge_derive.
# The 11 bit baseline (byte_ops, examples, the flagship tape) only means anything
# at the default geometry, so it is not part of this script.
# Per width: configure with -DR8FORGE_CELL_SIZE, build, run the `widthfree` ctest
# label (bit level slices, the synthesizer, the looping demo and the macro comment
# format -- all true at any width), then try one calculator session. The 11 bit
# baseline (byte_ops, examples, the flagship tape) only means anything at the
# default geometry, so it is not part of this script.
#
# Native commands report through $LASTEXITCODE, and their stderr must not be piped
# into the output stream: PowerShell turns that into an ErrorRecord.
param(
[int[]]$Widths = @(1, 2, 7, 8, 11, 16, 17, 31, 32),
[string]$CMake = "C:/Program Files/Microsoft Visual Studio/18/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe"
)
$ErrorActionPreference = "Stop"
$ErrorActionPreference = "Continue"
$root = Split-Path -Parent $PSScriptRoot
$ctest = Join-Path (Split-Path $CMake) "ctest.exe"
$failed = @()
@@ -22,17 +23,17 @@ $failed = @()
foreach ($w in $Widths) {
$dir = Join-Path $root "build$w"
Write-Host "=== cell $w"
& $CMake -S $root -B $dir -DCMAKE_BUILD_TYPE=Release -DR8FORGE_CELL_SIZE=$w | Out-Null
& $CMake --build $dir --config Release | Out-Null
& $CMake -S $root -B $dir "-DR8FORGE_CELL_SIZE=$w" 2>$null | Out-Null
& $CMake --build $dir --config Release 2>$null | Out-Null
& $ctest --test-dir $dir -C Release -L widthfree --output-on-failure | Out-Null
& $ctest --test-dir $dir -C Release -L widthfree 2>$null | Out-Null
if ($LASTEXITCODE -ne 0) { Write-Host " widthfree tests FAILED"; $failed += $w }
else { Write-Host " widthfree tests ok" }
$derive = Join-Path $dir "Release\r8forge_derive.exe"
$out = & $derive "examples/calc.r8asm" 0 -i "12 34 + ." 2>&1 | Out-String
$out = & $derive "examples/calc.r8asm" 0 -i "12 34 + ." 2>$null | Out-String
if ($LASTEXITCODE -eq 0) { Write-Host (" calc: " + ($out.Trim() -replace '\s+', ' ')) }
else { Write-Host " calc: does not run at this width (constant or digit does not fit)" }
else { Write-Host " calc: does not run at this width" }
Remove-Item -Recurse -Force $dir
}