-
Notifications
You must be signed in to change notification settings - Fork 420
/
Copy pathtest-aot.ps1
50 lines (38 loc) · 1.53 KB
/
test-aot.ps1
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
param([string]$targetNetFramework)
$projectName='Microsoft.IdentityModel.AotCompatibility.TestApp'
$rootDirectory = Split-Path $PSScriptRoot -Parent
$publishOutput = dotnet publish $rootDirectory/test/$projectName/$projectName.csproj --self-contained --framework $targetNetFramework -nodeReuse:false /p:UseSharedCompilation=false
$actualWarningCount = 0
foreach ($line in $($publishOutput -split "`r`n"))
{
if (($line -like "*analysis warning IL*") -or ($line -like "*analysis error IL*"))
{
Write-Host $line
$actualWarningCount += 1
}
}
Write-Host "Actual warning count is: ", $actualWarningCount
$expectedWarningCount = 0
if ($LastExitCode -ne 0)
{
Write-Host "There was an error while publishing AotCompatibility Test App. LastExitCode is:", $LastExitCode
Write-Host $publishOutput
}
$runtime = if ($IsWindows) { "win-x64" } elseif ($IsMacOS) { "macos-x64"} else {"linux-x64"}
$app = if ($IsWindows ) {"./$projectName.exe" } else {"./projectName" }
Push-Location $rootDirectory/test/$projectName/bin/Release/$targetNetFramework/$runtime
Write-Host "Executing test App..."
$app
Write-Host "Finished executing test App"
if ($LastExitCode -ne 0)
{
Write-Host "There was an error while executing AotCompatibility Test App. LastExitCode is:", $LastExitCode
}
Pop-Location
$testPassed = 0
if ($actualWarningCount -ne $expectedWarningCount)
{
$testPassed = 1
Write-Host "Actual warning count:", $actualWarningCount, "is not as expected. Expected warning count is:", $expectedWarningCount
}
Exit $testPassed