2026-01-27 16:21:58 +00:00
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Runs tests for the Likwid project.
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
Runs backend (Rust) and frontend tests.
|
|
|
|
|
Use -Backend, -Frontend, or -All flags.
|
|
|
|
|
#>
|
|
|
|
|
[CmdletBinding()]
|
|
|
|
|
param(
|
|
|
|
|
[switch]$Backend,
|
|
|
|
|
[switch]$Frontend,
|
|
|
|
|
[switch]$All
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
|
|
|
|
|
|
|
|
# Default to all if no flags
|
|
|
|
|
if (-not $Backend -and -not $Frontend) { $All = $true }
|
|
|
|
|
|
|
|
|
|
$results = @()
|
|
|
|
|
|
|
|
|
|
# Backend tests
|
|
|
|
|
if ($Backend -or $All) {
|
|
|
|
|
Write-Host "=== Backend Tests ===" -ForegroundColor Cyan
|
|
|
|
|
Push-Location (Join-Path $root 'backend')
|
|
|
|
|
try {
|
|
|
|
|
$env:DATABASE_URL = "postgres://likwid:likwid@127.0.0.1:5432/likwid"
|
|
|
|
|
cargo test --no-fail-fast 2>&1 | Tee-Object -Variable backendOutput
|
|
|
|
|
$results += @{ Component = 'Backend'; Success = ($LASTEXITCODE -eq 0) }
|
|
|
|
|
} finally {
|
|
|
|
|
Pop-Location
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Frontend tests
|
|
|
|
|
if ($Frontend -or $All) {
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Write-Host "=== Frontend Tests ===" -ForegroundColor Cyan
|
|
|
|
|
Push-Location (Join-Path $root 'frontend')
|
|
|
|
|
try {
|
2026-02-03 23:32:14 +00:00
|
|
|
npm run build 2>&1 | Tee-Object -Variable frontendOutput
|
2026-01-27 16:21:58 +00:00
|
|
|
$results += @{ Component = 'Frontend'; Success = ($LASTEXITCODE -eq 0) }
|
|
|
|
|
} finally {
|
|
|
|
|
Pop-Location
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Summary
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Write-Host "=== Test Summary ===" -ForegroundColor Cyan
|
|
|
|
|
foreach ($r in $results) {
|
|
|
|
|
$status = if ($r.Success) { "PASS" } else { "FAIL" }
|
|
|
|
|
$color = if ($r.Success) { "Green" } else { "Red" }
|
|
|
|
|
Write-Host "$($r.Component): $status" -ForegroundColor $color
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$failed = $results | Where-Object { -not $_.Success }
|
|
|
|
|
if ($failed) {
|
|
|
|
|
exit 1
|
|
|
|
|
}
|