File size: 2,218 Bytes
3ca1d38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env pwsh
<#
.SYNOPSIS
    Run MediGuard AI tests with pytest.

.DESCRIPTION
    Runs the test suite with proper configuration:
    - Sets up environment variables
    - Activates virtual environment
    - Runs pytest with appropriate flags

.PARAMETER Filter
    Test filter pattern (e.g., "test_integration")

.PARAMETER Verbose
    Enable verbose output

.PARAMETER Coverage
    Generate coverage report

.EXAMPLE
    .\scripts\run_tests.ps1
    
.EXAMPLE
    .\scripts\run_tests.ps1 -Filter "test_integration" -Verbose
#>

param(
    [string]$Filter = "",
    [switch]$Verbose,
    [switch]$Coverage
)

$ErrorActionPreference = "Stop"

Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "  MediGuard AI - Running Tests" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""

# Change to project root
$ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
if (Test-Path (Join-Path $PSScriptRoot "..")) {
    $ProjectRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
}
Set-Location $ProjectRoot

# Activate virtual environment
$VenvActivate = Join-Path $ProjectRoot ".venv\Scripts\Activate.ps1"
if (Test-Path $VenvActivate) {
    & $VenvActivate
}

# Set deterministic mode for evaluation tests
$env:EVALUATION_DETERMINISTIC = "true"

# Build pytest command
$PytestArgs = @()

if ($Verbose) {
    $PytestArgs += "-v"
}

if ($Coverage) {
    $PytestArgs += "--cov=src"
    $PytestArgs += "--cov-report=term-missing"
}

# Add filter if specified
if ($Filter) {
    $PytestArgs += "-k"
    $PytestArgs += $Filter
}

# Ignore slow/broken tests by default
$PytestArgs += "--ignore=tests/test_evolution_loop.py"
$PytestArgs += "--ignore=tests/test_evolution_quick.py"

# Add test directory
$PytestArgs += "tests/"

Write-Host "[INFO] Running: pytest $($PytestArgs -join ' ')" -ForegroundColor Gray
Write-Host ""

python -m pytest @PytestArgs

$ExitCode = $LASTEXITCODE
Write-Host ""
if ($ExitCode -eq 0) {
    Write-Host "[SUCCESS] All tests passed!" -ForegroundColor Green
} else {
    Write-Host "[FAILED] Some tests failed (exit code: $ExitCode)" -ForegroundColor Red
}

exit $ExitCode