Skip to content

Commit 459385d

Browse files
committed
Fix PowerShell test runner logic and add support for awkward 128-bit test fallback
1 parent bbc4a57 commit 459385d

File tree

1 file changed

+57
-7
lines changed

1 file changed

+57
-7
lines changed

test-high/run-tests.ps1

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,24 @@ Run-Test "check-pcg32_k16384_fast" "check-pcg32_k16384_fast.out"
119119
Get-ChildItem "actual" | Where-Object { $_.Length -lt 80 } | Remove-Item
120120

121121
# Compare with expected
122-
$diff = Compare-Object (Get-ChildItem "expected" -Exclude .gitignore) (Get-ChildItem "actual")
122+
$expectedItems = Get-ChildItem "expected" -Exclude .gitignore
123+
$actualItems = Get-ChildItem "actual"
124+
125+
$expectedNames = $expectedItems | Select-Object -ExpandProperty Name
126+
$actualNames = $actualItems | Select-Object -ExpandProperty Name
127+
128+
$diff = Compare-Object $expectedNames $actualNames
129+
123130
if ($null -eq $diff) {
124131
# Perform actual content comparison
125132
$failed = $false
126-
Foreach ($file in Get-ChildItem "expected" -Exclude .gitignore) {
127-
$expectedFile = $file.FullName
128-
$actualFile = Join-Path "actual" $file.Name
133+
Foreach ($item in $expectedItems) {
134+
$expectedFile = $item.FullName
135+
$actualFile = Join-Path "actual" $item.Name
129136
if (Test-Path $actualFile) {
130137
$diffContent = Compare-Object (Get-Content $expectedFile) (Get-Content $actualFile)
131138
if ($diffContent) {
132-
Write-Host "Difference in $($file.Name)" -ForegroundColor Red
139+
Write-Host "Difference in $($item.Name)" -ForegroundColor Red
133140
$failed = $true
134141
}
135142
}
@@ -142,6 +149,49 @@ if ($null -eq $diff) {
142149
exit 1
143150
}
144151
} else {
145-
Write-Host "ERROR: File list mismatch between expected and actual." -ForegroundColor Red
146-
exit 1
152+
# Fallback check: maybe it's just the awkward 128-bit tests?
153+
$awkwardPatterns = @("*-pcg64_c*.out", "*-pcg64_k*.out", "*-pcg128_c*.out", "*-pcg128_k*.out")
154+
155+
$cleanExpected = $expectedNames
156+
foreach ($pattern in $awkwardPatterns) {
157+
$cleanExpected = $cleanExpected | Where-Object { $_ -notlike $pattern }
158+
}
159+
160+
$cleanActual = $actualNames
161+
foreach ($pattern in $awkwardPatterns) {
162+
$cleanActual = $cleanActual | Where-Object { $_ -notlike $pattern }
163+
}
164+
165+
$diffClean = Compare-Object $cleanExpected $cleanActual
166+
167+
if ($null -eq $diffClean) {
168+
# Check content of the non-awkward files
169+
$failed = $false
170+
foreach ($name in $cleanExpected) {
171+
$expectedFile = Join-Path "expected" $name
172+
$actualFile = Join-Path "actual" $name
173+
if (Test-Path $actualFile) {
174+
$diffContent = Compare-Object (Get-Content $expectedFile) (Get-Content $actualFile)
175+
if ($diffContent) {
176+
Write-Host "Difference in $name" -ForegroundColor Red
177+
$failed = $true
178+
}
179+
}
180+
}
181+
182+
if (!$failed) {
183+
Write-Host "All tests except awkward tests with 128-bit math succeeded." -ForegroundColor Yellow
184+
} else {
185+
Write-Host "ERROR: Some tests failed." -ForegroundColor Red
186+
exit 1
187+
}
188+
} else {
189+
Write-Host "ERROR: File list mismatch between expected and actual." -ForegroundColor Red
190+
# Print the diff to help debugging
191+
$diff | ForEach-Object {
192+
$side = if ($_.SideIndicator -eq "<=") { "Missing in Actual" } else { "Extra in Actual" }
193+
Write-Host " $($_.InputObject) ($side)"
194+
}
195+
exit 1
196+
}
147197
}

0 commit comments

Comments
 (0)