-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathrun-aot-tests.ps1
More file actions
109 lines (91 loc) · 3.47 KB
/
run-aot-tests.ps1
File metadata and controls
109 lines (91 loc) · 3.47 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
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
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env pwsh
[CmdletBinding()]
param(
[string]$Framework = "net9.0",
[string]$Configuration = "Release",
[string]$Filter = "/*/*/*/*[EngineTest=Pass]"
)
$ErrorActionPreference = "Stop"
Write-Host "Running AOT tests..." -ForegroundColor Yellow
# Get runtime identifier for platform-specific builds
function Get-RuntimeIdentifier {
# For PowerShell 5.x compatibility on Windows
if ($PSVersionTable.PSVersion.Major -lt 6) {
# Windows PowerShell 5.x
return "win-x64"
}
# PowerShell Core 6+
if ($IsWindows) {
return "win-x64"
} elseif ($IsLinux) {
return "linux-x64"
} elseif ($IsMacOS) {
return "osx-x64"
} else {
# Default to Windows if platform detection fails
return "win-x64"
}
}
$rid = Get-RuntimeIdentifier
$isWindowsPlatform = ($PSVersionTable.PSVersion.Major -lt 6) -or ((Get-Variable -Name 'IsWindows' -ErrorAction SilentlyContinue) -and $IsWindows)
$executableName = if ($isWindowsPlatform) { "TUnit.TestProject.exe" } else { "TUnit.TestProject" }
# Change to test project directory
$testProjectDir = Join-Path $PSScriptRoot "TUnit.TestProject"
if (-not (Test-Path $testProjectDir)) {
Write-Error "Test project directory not found: $testProjectDir"
exit 1
}
Push-Location $testProjectDir
try {
Write-Host "Building AOT version..." -ForegroundColor Yellow
# First restore with runtime identifier
Write-Host "Restoring with runtime identifier $rid..." -ForegroundColor Cyan
dotnet restore TUnit.TestProject.csproj `
-r $rid 2>&1 | Out-String | Write-Host
if ($LASTEXITCODE -ne 0) {
Write-Host "Restore failed with exit code $LASTEXITCODE" -ForegroundColor Yellow
exit $LASTEXITCODE
}
# Build the test project
Write-Host "Building TUnit.TestProject..." -ForegroundColor Cyan
dotnet build TUnit.TestProject.csproj `
-f $Framework `
-c $Configuration `
--no-restore 2>&1 | Out-String | Write-Host
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed with exit code $LASTEXITCODE" -ForegroundColor Yellow
exit $LASTEXITCODE
}
# Now publish with AOT - use the Aot property that's already in the project
Write-Host "Publishing with AOT..." -ForegroundColor Cyan
dotnet publish TUnit.TestProject.csproj `
-f $Framework `
-c $Configuration `
-r $rid `
-p:Aot=true `
-p:SelfContained=true `
-p:IlcGenerateStackTraceData=false `
-p:IlcOptimizationPreference=Size `
-o "TESTPROJECT_AOT" 2>&1 | Out-String | Write-Host
if ($LASTEXITCODE -ne 0) {
Write-Host "AOT build completed with exit code $LASTEXITCODE" -ForegroundColor Yellow
exit $LASTEXITCODE
}
Write-Host "Running AOT tests..." -ForegroundColor Yellow
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$aotExecutable = Join-Path "TESTPROJECT_AOT" $executableName
& $aotExecutable --treenode-filter $Filter 2>&1 | Out-String | Write-Host
$success = $LASTEXITCODE -eq 0
$stopwatch.Stop()
if ($success) {
Write-Host "AOT tests PASSED in $($stopwatch.Elapsed)" -ForegroundColor Green
} else {
Write-Host "AOT tests completed with exit code $LASTEXITCODE in $($stopwatch.Elapsed)" -ForegroundColor Yellow
}
exit $LASTEXITCODE
} catch {
Write-Host "AOT tests FAILED with error: $_" -ForegroundColor Red
exit 1
} finally {
Pop-Location
}