mirror of
https://codeberg.org/likwid/likwid.git
synced 2026-02-09 21:13:09 +00:00
62 lines
1.6 KiB
PowerShell
62 lines
1.6 KiB
PowerShell
|
|
<#
|
||
|
|
.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 {
|
||
|
|
npm run check 2>&1 | Tee-Object -Variable frontendOutput
|
||
|
|
$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
|
||
|
|
}
|