34 lines
3.4 KiB
PowerShell
34 lines
3.4 KiB
PowerShell
#Requires -Version 7.0
|
|
param([ValidateSet('parser-verification.json','parser-preparation-verification.json','parser-preparation-verification-timing.json')][string]$OutputName='parser-verification.json')
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference='Stop'
|
|
if(Test-Path -LiteralPath (Join-Path $PSScriptRoot $OutputName)){throw 'Preserve prior parser evidence; choose a fresh gate or preparation output.'}
|
|
$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;runnerSha256=(Get-FileHash -LiteralPath (Join-Path $PSScriptRoot 'run.ps1') -Algorithm SHA256).Hash.ToLowerInvariant();cases=$results}|ConvertTo-Json -Depth 6|Set-Content -LiteralPath (Join-Path $PSScriptRoot $OutputName) -Encoding utf8
|
|
Write-Output ('Verified '+$results.Count+' parser cases')
|