#Requires -Version 7.0 Set-StrictMode -Version Latest $ErrorActionPreference='Stop' $script=Get-Content -Raw -LiteralPath (Join-Path $PSScriptRoot 'run.ps1') $begin=$script.IndexOf(' $taskValid=$true;$taskFailure=$null') $end=$script.IndexOf(' $inputsUnchanged=$false',$begin) if($begin -lt 0 -or $end -lt 0){throw 'Runner parser block not found'} $block=[scriptblock]::Create($script.Substring($begin,$end-$begin)) $selection=Get-Content -Raw -LiteralPath (Join-Path $PSScriptRoot 'expected-tests.json')|ConvertFrom-Json $expected=@($selection.tests|Sort-Object -Unique);$expectedCount=$expected.Count function Same-Names($Left,$Right){$a=@($Left|Sort-Object);$b=@($Right|Sort-Object);return $a.Count -eq $b.Count -and @(Compare-Object $a $b).Count -eq 0} $prior=[pscustomobject]@{listedTests=@($selection.desktop_tests)} $filtered=@($prior.listedTests).Count-$expectedCount $passLines=@($expected|ForEach-Object {'test '+$_+' ... ok'}) $summary='test result: ok. '+$expectedCount+' passed; 0 failed; 0 ignored; 0 measured; '+$filtered+' filtered out;' $listLines=@($selection.desktop_tests|ForEach-Object {$_+': test'}) $listSummary=@($selection.desktop_tests).Count.ToString()+' tests, 0 benchmarks' $cases=@( [pscustomobject]@{name='focused-exact';stage='focused';valid=$true;text=(($passLines+@($summary)) -join "`n")}, [pscustomobject]@{name='focused-zero';stage='focused';valid=$false;text='test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out;'}, [pscustomobject]@{name='focused-duplicate';stage='focused';valid=$false;text=(($passLines+@($passLines[0],$summary)) -join "`n")}, [pscustomobject]@{name='focused-missing';stage='focused';valid=$false;text=(($passLines[1..($passLines.Count-1)]+@($summary)) -join "`n")}, [pscustomobject]@{name='focused-wrong-total';stage='focused';valid=$false;text=(($passLines+@('test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; '+$filtered+' filtered out;')) -join "`n")}, [pscustomobject]@{name='focused-wrong-filtered';stage='focused';valid=$false;text=(($passLines+@($summary.Replace(($filtered.ToString()+' filtered'), '0 filtered'))) -join "`n")}, [pscustomobject]@{name='list-complete';stage='list';valid=$true;text=(($listLines+@($listSummary)) -join "`n")}, [pscustomobject]@{name='list-missing-summary';stage='list';valid=$false;text=($listLines -join "`n")}, [pscustomobject]@{name='list-duplicate';stage='list';valid=$false;text=(($listLines+@($listLines[0],$listSummary)) -join "`n")} ) $results=@(foreach($case in $cases){$Stage=$case.stage;$taskText=$case.text;. $block;if($taskValid -ne $case.valid){throw ('Unexpected parser decision: '+$case.name)};[ordered]@{case=$case.name;expected=$case.valid;actual=$taskValid}}) [ordered]@{status='Synthetic actual-runner parser checks only; no Cargo or product tests';focusedCount=$expectedCount;cases=$results}|ConvertTo-Json -Depth 6|Set-Content -LiteralPath (Join-Path $PSScriptRoot 'parser-verification.json') -Encoding utf8 Write-Output ('Verified '+$results.Count+' parser cases')