#!/usr/bin/env pwsh # CAN Sync v2 Integration Test Runner # # Usage: # .\run-integration-test.ps1 # Build + run test # .\run-integration-test.ps1 -NoBuild # Skip building, just run param( [switch]$NoBuild ) $ErrorActionPreference = "Stop" $canServiceRoot = Resolve-Path (Join-Path $PSScriptRoot "../..") $canSyncRoot = $PSScriptRoot Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " CAN Sync v2 - Integration Test Runner" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # Step 1: Build CAN service if (-not $NoBuild) { Write-Host "[1/3] Building CAN service..." -ForegroundColor Yellow Push-Location $canServiceRoot try { cargo build 2>&1 | ForEach-Object { Write-Host " $_" -ForegroundColor DarkGray } if ($LASTEXITCODE -ne 0) { Write-Host "FAILED: CAN service build failed!" -ForegroundColor Red exit 1 } Write-Host " CAN service built OK" -ForegroundColor Green } finally { Pop-Location } # Step 2: Build can-sync + sync-test Write-Host "" Write-Host "[2/3] Building can-sync and sync-test..." -ForegroundColor Yellow Push-Location $canSyncRoot try { cargo build --bin can-sync --bin sync-test 2>&1 | ForEach-Object { Write-Host " $_" -ForegroundColor DarkGray } if ($LASTEXITCODE -ne 0) { Write-Host "FAILED: can-sync build failed!" -ForegroundColor Red exit 1 } Write-Host " can-sync built OK" -ForegroundColor Green } finally { Pop-Location } } else { Write-Host "[SKIP] Builds skipped (-NoBuild)" -ForegroundColor DarkYellow } # Step 3: Run integration test Write-Host "" Write-Host "[3/3] Running integration test..." -ForegroundColor Yellow Write-Host "" Push-Location $canSyncRoot try { cargo run --bin sync-test $testResult = $LASTEXITCODE } finally { Pop-Location } Write-Host "" if ($testResult -eq 0) { Write-Host "ALL TESTS PASSED" -ForegroundColor Green } else { Write-Host "SOME TESTS FAILED (exit code: $testResult)" -ForegroundColor Red } exit $testResult