64 lines
5.6 KiB
PowerShell
64 lines
5.6 KiB
PowerShell
#Requires -Version 7.0
|
|
# Pure recipe syntax and synthetic parser checks only. No Cargo, source capture or test executable invocation.
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference='Stop'
|
|
if(Test-Path -LiteralPath (Join-Path $PSScriptRoot 'preparation-verification.json')){throw 'Preserve preparation evidence'}
|
|
. (Join-Path $PSScriptRoot 'batch-helpers.ps1')
|
|
$p=Get-Content -Raw (Join-Path $PSScriptRoot 'batches.json')|ConvertFrom-Json
|
|
$e=Get-Content -Raw (Join-Path $PSScriptRoot 'expected-tests.json')|ConvertFrom-Json
|
|
Assert-BatchPlan $p $e.tests $p.cargo_path
|
|
$syntax=@()
|
|
foreach($name in @('run.ps1','capture.ps1','batch-helpers.ps1')){
|
|
$tokens=$null;$errors=$null
|
|
$null=[System.Management.Automation.Language.Parser]::ParseFile((Join-Path $PSScriptRoot $name),[ref]$tokens,[ref]$errors)
|
|
if($errors.Count){throw ($errors|Out-String)}
|
|
$syntax+=$name
|
|
}
|
|
$checks=@('exact301-plan')
|
|
foreach($b in $p.batches){
|
|
$lines=@($b.tests|ForEach-Object {'test '+$_+' ... ok'})
|
|
$lines+=('test result: ok. '+$b.expected_passed+' passed; 0 failed; 0 ignored; 0 measured; '+$b.expected_filtered+' filtered out; finished in 1.23s')
|
|
$r=Read-BatchResults ($lines -join [Environment]::NewLine)
|
|
Assert-ExactBatch $b $r 1095
|
|
$checks+=('accept-'+$b.id)
|
|
}
|
|
function Must-Reject([string]$Name,[scriptblock]$Action){
|
|
$rejected=$false;try{& $Action}catch{$rejected=$true}
|
|
if(-not $rejected){throw ('Accepted invalid synthetic case: '+$Name)}
|
|
$script:checks+=('reject-'+$Name)
|
|
}
|
|
$b=$p.batches[0]
|
|
$validLines=@($b.tests|ForEach-Object {'test '+$_+' ... ok'})
|
|
$summary='test result: ok. '+$b.expected_passed+' passed; 0 failed; 0 ignored; 0 measured; '+$b.expected_filtered+' filtered out; finished in 1.23s'
|
|
Must-Reject 'duplicate-outcome' {Assert-ExactBatch $b (Read-BatchResults ((@($validLines)+$validLines[0]+$summary)-join [Environment]::NewLine)) 1095}
|
|
Must-Reject 'missing-outcome' {Assert-ExactBatch $b (Read-BatchResults ((@($validLines|Select-Object -Skip 1)+$summary)-join [Environment]::NewLine)) 1095}
|
|
Must-Reject 'wrong-filtered' {Assert-ExactBatch $b (Read-BatchResults ((@($validLines)+$summary.Replace('988 filtered','794 filtered'))-join [Environment]::NewLine)) 1095}
|
|
Must-Reject 'ignored-outcome' {$bad=@($validLines);$bad[0]=$bad[0].Replace(' ... ok',' ... ignored');Assert-ExactBatch $b (Read-BatchResults (($bad+$summary)-join [Environment]::NewLine)) 1095}
|
|
Must-Reject 'duplicate-summary' {Assert-ExactBatch $b (Read-BatchResults ((@($validLines)+$summary+$summary)-join [Environment]::NewLine)) 1095}
|
|
Must-Reject 'duplicate-plan-union' {$bad=$p|ConvertTo-Json -Depth 20|ConvertFrom-Json;$bad.batches[1].tests[0]=$bad.batches[0].tests[0];Assert-BatchPlan $bad $e.tests $bad.cargo_path}
|
|
|
|
# Exercise the actual runner list/aggregate parser without invoking the runner.
|
|
$runner=Get-Content -Raw (Join-Path $PSScriptRoot 'run.ps1')
|
|
$begin=$runner.IndexOf(' $taskValid=$true;$taskFailure=$null')
|
|
$end=$runner.IndexOf(' $inputsUnchanged=$false',$begin)
|
|
if($begin -lt 0 -or $end -lt 0){throw 'Actual runner parser block not found'}
|
|
$block=[scriptblock]::Create($runner.Substring($begin,$end-$begin))
|
|
$selection=$e;$expected=@($e.tests|Sort-Object);$expectedCount=301
|
|
$batchPlan=$p;$batchesValid=$true;$batchReceipts=@($p.batches)
|
|
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}
|
|
$listLines=@($e.desktop_tests|ForEach-Object {$_+': test'})
|
|
$oldList=@($e.desktop_tests|Where-Object {$_ -notlike 'app::scenario_details_tests::*'})
|
|
$batchText=@(foreach($b in $p.batches){foreach($name in $b.tests){'test '+$name+' ... ok'};'test result: ok. '+$b.expected_passed+' passed; 0 failed; 0 ignored; 0 measured; '+$b.expected_filtered+' filtered out; finished in 1.23s'}) -join [Environment]::NewLine
|
|
$cases=@(
|
|
[pscustomobject]@{name='list-exact1095';stage='list';valid=$true;text=(($listLines+@('1095 tests, 0 benchmarks')) -join [Environment]::NewLine)},
|
|
[pscustomobject]@{name='list-old1089';stage='list';valid=$false;text=((@($oldList|ForEach-Object {$_+': test'})+@('1089 tests, 0 benchmarks')) -join [Environment]::NewLine)},
|
|
[pscustomobject]@{name='list-duplicate';stage='list';valid=$false;text=(($listLines+@($listLines[0],'1096 tests, 0 benchmarks')) -join [Environment]::NewLine)},
|
|
[pscustomobject]@{name='list-no-summary';stage='list';valid=$false;text=($listLines -join [Environment]::NewLine)},
|
|
[pscustomobject]@{name='focused-three-actual-summaries';stage='focused';valid=$true;text=$batchText},
|
|
[pscustomobject]@{name='focused-duplicate';stage='focused';valid=$false;text=($batchText+[Environment]::NewLine+'test '+$expected[0]+' ... ok')},
|
|
[pscustomobject]@{name='focused-failed';stage='focused';valid=$false;text=$batchText.Replace(('test '+$expected[0]+' ... ok'),('test '+$expected[0]+' ... FAILED'))}
|
|
)
|
|
foreach($case in $cases){$Stage=$case.stage;$taskText=$case.text;. $block;if($taskValid -ne $case.valid){throw ('Wrong actual parser decision: '+$case.name)};$checks+=($case.name)}
|
|
[ordered]@{schema='scenario_validation_preparation_v1';source_commit=$p.source_commit;syntax=$syntax;pureChecks=$checks;runnerSha256=(Get-FileHash -LiteralPath (Join-Path $PSScriptRoot 'run.ps1') -Algorithm SHA256).Hash.ToLowerInvariant();batchHelperSha256=(Get-FileHash -LiteralPath (Join-Path $PSScriptRoot 'batch-helpers.ps1') -Algorithm SHA256).Hash.ToLowerInvariant();cargoInvoked=$false;testExecutableInvoked=$false;capturesTaken=$false;createdUtc=[DateTime]::UtcNow.ToString('o')}|ConvertTo-Json -Depth 5|Set-Content -LiteralPath (Join-Path $PSScriptRoot 'preparation-verification.json') -Encoding utf8
|
|
'PASS: syntax and '+$checks.Count+' pure checks; no Cargo or test execution'
|