$ErrorActionPreference = 'Stop' $projectRoot = Split-Path -Parent $PSScriptRoot $scratch = Join-Path $projectRoot '.tmp' function Assert-ExitCode { param([string]$Step) if ($LASTEXITCODE -ne 0) { throw "$Step failed with exit code $LASTEXITCODE" } } # 测试统一使用仓库内的临时目录:不依赖系统 %TEMP% 的权限策略, # 也让清理、归档和排障都留在项目目录里。 [void](New-Item -ItemType Directory -Path $scratch -Force) $env:TMP = $scratch $env:TEMP = $scratch Push-Location $projectRoot try { pnpm --dir frontend lint Assert-ExitCode 'Frontend lint' pnpm --dir frontend typecheck Assert-ExitCode 'Frontend typecheck' pnpm --dir frontend test Assert-ExitCode 'Frontend tests' pnpm --dir frontend build Assert-ExitCode 'Frontend build' cargo fmt --manifest-path backend\Cargo.toml -- --check Assert-ExitCode 'Rust formatting' cargo clippy --manifest-path backend\Cargo.toml --all-targets -- -D warnings Assert-ExitCode 'Rust clippy' cargo test --manifest-path backend\Cargo.toml Assert-ExitCode 'Rust tests' powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot 'e2e.ps1') Assert-ExitCode 'Playwright end-to-end tests' } finally { Pop-Location Remove-Item -LiteralPath $scratch -Recurse -Force -ErrorAction SilentlyContinue }