-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.ps1
More file actions
72 lines (58 loc) · 2.01 KB
/
test.ps1
File metadata and controls
72 lines (58 loc) · 2.01 KB
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
# Marchat Test Runner (PowerShell)
# This script runs all tests in the Marchat project
param(
[switch]$Coverage,
[switch]$Verbose
)
Write-Host "Running Marchat Test Suite" -ForegroundColor Cyan
Write-Host "================================" -ForegroundColor Cyan
# Check if Go is installed
try {
$goVersion = go version
Write-Host "Using Go: $goVersion" -ForegroundColor Green
} catch {
Write-Host "Go is not installed or not in PATH" -ForegroundColor Red
exit 1
}
# Run tests
Write-Host ""
Write-Host "Running tests..." -ForegroundColor Yellow
Write-Host "=================" -ForegroundColor Yellow
$testArgs = @()
if ($Verbose) {
$testArgs += "-v"
}
try {
if ($Coverage) {
$testArgs += "-coverprofile=coverage.out"
}
$testArgs += "./..."
& go test @testArgs
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "All tests passed!" -ForegroundColor Green
if ($Coverage) {
Write-Host ""
Write-Host "Generating coverage report..." -ForegroundColor Yellow
Write-Host "=============================" -ForegroundColor Yellow
go tool cover -html coverage.out -o coverage.html
Write-Host "Coverage report generated: coverage.html" -ForegroundColor Green
# Show coverage summary
Write-Host ""
Write-Host "Coverage Summary:" -ForegroundColor Yellow
Write-Host "=================" -ForegroundColor Yellow
$coverageSummary = go tool cover -func coverage.out | Select-Object -Last 1
Write-Host $coverageSummary -ForegroundColor White
}
Write-Host ""
Write-Host "Test suite completed successfully!" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "Some tests failed!" -ForegroundColor Red
exit 1
}
} catch {
Write-Host ""
Write-Host "Error running tests: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}