|
| 1 | +$ErrorActionPreference='Continue' |
| 2 | +$tests=@( |
| 3 | + @{Script='scripts/powershell/check-prerequisites.ps1';Args=@('-Help')}, |
| 4 | + @{Script='scripts/powershell/create-new-feature.ps1';Args=@('-Help')}, |
| 5 | + @{Script='scripts/powershell/archive-context.ps1';Args=@('-Json')}, |
| 6 | + @{Script='scripts/powershell/evolution-context.ps1';Args=@('-Json')}, |
| 7 | + @{Script='scripts/powershell/harvest.ps1';Args=@('-Scope','scan','-Json')}, |
| 8 | + @{Script='scripts/powershell/migrate-to-documentation.ps1';Args=@('-DryRun')}, |
| 9 | + @{Script='scripts/powershell/quickfix-context.ps1';Args=@('-Json')}, |
| 10 | + @{Script='scripts/powershell/release-context.ps1';Args=@('-Json','-DryRun')}, |
| 11 | + @{Script='scripts/powershell/setup-plan.ps1';Args=@('-Help')}, |
| 12 | + @{Script='scripts/powershell/site-audit.ps1';Args=@('-Scope','constitution','-OutputFormat','summary')}, |
| 13 | + @{Script='scripts/powershell/update-agent-context.ps1';Args=@()} |
| 14 | +) |
| 15 | +$results=foreach($t in $tests){ |
| 16 | + $scriptPath=Join-Path (Get-Location) $t.Script |
| 17 | + $argList=@('-NoProfile','-ExecutionPolicy','Bypass','-File',$scriptPath)+$t.Args |
| 18 | + $cmdText='pwsh '+(($argList|ForEach-Object{ if($_ -match '\s'){ '"'+$_+'"' } else { $_ } }) -join ' ') |
| 19 | + $outFile=[System.IO.Path]::GetTempFileName(); $errFile=[System.IO.Path]::GetTempFileName() |
| 20 | + $exit=1; $timedOut=$false; $startErr=$null |
| 21 | + try { |
| 22 | + $p=Start-Process -FilePath 'pwsh' -ArgumentList $argList -PassThru -RedirectStandardOutput $outFile -RedirectStandardError $errFile -ErrorAction Stop |
| 23 | + try { Wait-Process -Id $p.Id -Timeout 45 -ErrorAction Stop } catch { $timedOut=$true } |
| 24 | + if($timedOut -and $p -and -not $p.HasExited){ Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue } |
| 25 | + if($timedOut){ $exit=124 } else { $exit=$p.ExitCode } |
| 26 | + } catch { $startErr=$_.Exception.Message; $exit=1 } |
| 27 | + $stdout=@(); $stderr=@() |
| 28 | + if(Test-Path -LiteralPath $outFile){ $stdout=Get-Content -LiteralPath $outFile -ErrorAction SilentlyContinue } |
| 29 | + if(Test-Path -LiteralPath $errFile){ $stderr=Get-Content -LiteralPath $errFile -ErrorAction SilentlyContinue } |
| 30 | + Remove-Item -LiteralPath $outFile,$errFile -ErrorAction SilentlyContinue |
| 31 | + $lines=@() |
| 32 | + if($startErr){ $lines += $startErr } |
| 33 | + if($stderr){ $lines += $stderr } |
| 34 | + if($stdout){ $lines += $stdout } |
| 35 | + $lines=$lines|Where-Object{ $_ -and $_.ToString().Trim().Length -gt 0 } |
| 36 | + $firstErr=$lines|Where-Object{ $_ -match '(?i)(^\s*error\b|exception|failed|not recognized|cannot|invalid|parsererror|at line:)' }|Select-Object -First 1 |
| 37 | + if(-not $firstErr -and $exit -ne 0){ $firstErr=$lines|Select-Object -First 1 } |
| 38 | + $status = if($exit -eq 0){'PASS'} elseif($exit -eq 124){'TIMEOUT'} else {'FAIL'} |
| 39 | + [pscustomobject]@{ Script=$t.Script; Command=$cmdText; ExitCode=$exit; Status=$status; KeyError=(if($firstErr){$firstErr.ToString().Trim()}else{''}) } |
| 40 | +} |
| 41 | +$results | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath '.tmp-smoke-results.json' |
| 42 | +$results | Format-Table -AutoSize |
0 commit comments