Files
ARCADIA-Studio/harness/experiments/navigation-rename-cache-rejection-20260913/run.ps1
T

53 lines
4.0 KiB
PowerShell

param([Parameter(Mandatory=$true)][ValidateSet('check','list','focused','tests','clippy','build','timing')][string]$Stage)
$ErrorActionPreference = 'Stop'
$taskWorkspace = 'C:\Users\User\Documents\Git\ARCADIA-Studio\.local\navigation-rename-union-ytr83r-20260912'
Push-Location -LiteralPath $taskWorkspace
try {
. 'C:\Users\User\Documents\Git\ARCADIA-Studio\.local\toolchain\env.ps1'
$env:CARGO_TARGET_DIR = 'C:\Users\User\Documents\Git\ARCADIA-Studio\target'
$taskArgs = switch ($Stage) {
'check' { @('check','-p','oa-desktop','--bin','arcadia-studio','--tests','--locked','--offline') }
'list' { @('test','-p','oa-desktop','--bin','arcadia-studio','--locked','--offline','--','--list') }
'focused' { @('test','-p','oa-desktop','--bin','arcadia-studio','--locked','--offline','--','app::source_rename::tests::navigation_union_tests::','app::source_rename::tests::preview_scroll_tests::','--test-threads=1') }
'tests' { @('test','-p','oa-desktop','--all-targets','--locked','--offline') }
'clippy' { @('clippy','-p','oa-desktop','--all-targets','--locked','--offline','--','-D','warnings') }
'build' { @('build','-p','oa-desktop','--bin','arcadia-studio','--locked','--offline') }
'timing' { @('test','-p','oa-desktop','--bin','arcadia-studio','--locked','--offline','--','accepted_release1_prepare_commit_sync_and_confirm_timing','--ignored','--nocapture','--test-threads=1') }
}
$taskLog = Join-Path $PSScriptRoot ($Stage+'.log')
$taskReceipt = Join-Path $PSScriptRoot ($Stage+'-receipt.json')
if ((Test-Path -LiteralPath $taskLog) -or (Test-Path -LiteralPath $taskReceipt)) { throw 'Refusing to replace existing gate evidence' }
$taskStart = [DateTime]::UtcNow.ToString('o')
$taskBase = git rev-parse HEAD
if ($LASTEXITCODE -ne 0) { throw 'Cannot identify source commit' }
$taskInputs = Get-Content -Raw -LiteralPath (Join-Path $PSScriptRoot 'inputs-complete-before.json') | ConvertFrom-Json
if ($taskInputs.base -ne $taskBase -or $taskInputs.workspace -ne $taskWorkspace) { throw 'Captured source does not match the pinned gate checkout' }
if ($Stage -eq 'tests') {
$taskListing = Get-Content -Raw -LiteralPath (Join-Path $PSScriptRoot 'list-receipt.json') | ConvertFrom-Json
if (-not $taskListing.selectionValid -or $taskListing.cargoExitCode -ne 0 -or $taskListing.base -ne $taskBase) { throw 'Full gate requires valid listing of this source commit' }
}
& cargo @taskArgs 2>&1 | Tee-Object -FilePath $taskLog
$taskExit = $LASTEXITCODE
$taskOutput = Get-Content -Raw -LiteralPath $taskLog
$taskSelectionValid = $true
$taskListed = $null
$taskUnionCount = $null
$taskScrollCount = $null
if ($Stage -eq 'list') {
$taskListed = [regex]::Matches($taskOutput, '(?m)^[^\r\n]+: test\r?$').Count
$taskUnionCount = [regex]::Matches($taskOutput, '(?m)^app::source_rename::tests::navigation_union_tests::[^\r\n]+: test\r?$').Count
$taskScrollCount = [regex]::Matches($taskOutput, '(?m)^app::source_rename::tests::preview_scroll_tests::[^\r\n]+: test\r?$').Count
$taskSelectionValid = $taskListed -ge 905 -and $taskUnionCount -eq 6 -and $taskScrollCount -eq 4
}
if ($Stage -eq 'focused') { $taskSelectionValid = $taskOutput -match 'test result: ok\. 10 passed; 0 failed; 0 ignored;' }
if ($Stage -eq 'timing') { $taskSelectionValid = $taskOutput -match 'test result: ok\. 1 passed; 0 failed; 0 ignored;' }
if ($Stage -eq 'tests') {
$taskExpectedPassed = $taskListing.listedTests - 3
$taskSelectionValid = $taskOutput -match ('test result: ok\. '+$taskExpectedPassed+' passed; 0 failed; 3 ignored;')
}
[ordered]@{command=('cargo '+($taskArgs -join ' '));workspace=$taskWorkspace;startUtc=$taskStart;endUtc=[DateTime]::UtcNow.ToString('o');base=$taskBase;cargoExitCode=$taskExit;listedTests=$taskListed;listedUnionTests=$taskUnionCount;listedScrollTests=$taskScrollCount;selectionValid=$taskSelectionValid} | ConvertTo-Json | Set-Content -LiteralPath $taskReceipt -Encoding utf8
if ($taskExit -ne 0) { exit $taskExit }
if (-not $taskSelectionValid) { throw 'Selected test count or passing result differs from the explicit expectation' }
exit 0
} finally { Pop-Location }