forked from getsentry/sentry-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaot.Tests.ps1
More file actions
82 lines (73 loc) · 3.07 KB
/
aot.Tests.ps1
File metadata and controls
82 lines (73 loc) · 3.07 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
# This file contains test cases for https://pester.dev/
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
Describe 'Publish' {
BeforeAll {
$package = Get-ChildItem -Path "$PSScriptRoot/../src/Sentry/bin/Release/Sentry.*.nupkg" -File | Select-Object -First 1
if (-not $package)
{
throw "No NuGet package found in src/Sentry/bin/Release."
}
$tempDir = Resolve-Path ([System.IO.Path]::GetTempPath())
$tempDir = Join-Path $tempDir ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
Set-Location $tempDir
Write-Host "Testing $package in $tempDir"
Write-Host "::group::Setup local NuGet source"
$localPackages = Join-Path $tempDir "packages"
New-Item -ItemType Directory -Path $localPackages -Force | Out-Null
Copy-Item $package $localPackages
$localConfig = Join-Path $tempDir "nuget.config"
Copy-Item $PSScriptRoot/nuget.config $localConfig
(Get-Content $localConfig) -replace '\./packages', $localPackages | Set-Content $localConfig
$env:NUGET_PACKAGES = Join-Path $tempDir "nuget"
New-Item -ItemType Directory -Path $env:NUGET_PACKAGES -Force | Out-Null
dotnet nuget list source | Write-Host
Write-Host "::endgroup::"
Write-Host "::group::Create test project"
dotnet new console --aot --name hello-sentry --output . | Write-Host
dotnet add package Sentry --prerelease --source $localPackages | Write-Host
@"
SentrySdk.Init(options =>
{
options.Dsn = "https://foo@sentry.invalid/42";
options.Debug = true;
});
Console.WriteLine("Hello, Sentry!");
"@ | Set-Content Program.cs
Write-Host "::endgroup::"
}
AfterAll {
if ($tempDir -and (Test-Path $tempDir))
{
Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue
}
}
It 'Aot' {
$rid = $env:RuntimeIdentifier
$baseImage = $env:ContainerBaseImage
$publishArgs = @('-c', 'Release')
if ($rid) {
Write-Host "Environment RuntimeIdentifier: $rid"
$publishArgs += @('-r', $rid)
}
if ($baseImage) {
Write-Host "Using ContainerBaseImage: $baseImage"
$publishArgs += "-p:ContainerBaseImage=$baseImage"
}
dotnet publish @publishArgs | Write-Host
$LASTEXITCODE | Should -Be 0
$tfm = (Get-ChildItem -Path "bin/Release" -Directory | Select-Object -First 1).Name
if (-not $rid) {
$rid = (Get-ChildItem -Path "bin/Release/$tfm" -Directory | Select-Object -First 1).Name
}
& "bin/Release/$tfm/$rid/publish/hello-sentry" | Write-Host
$LASTEXITCODE | Should -Be 0
}
It 'Container' -Skip:(!$IsLinux -or !(Get-Command docker -ErrorAction SilentlyContinue)) {
dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer | Write-Host
$LASTEXITCODE | Should -Be 0
docker run --rm hello-sentry | Write-Host
$LASTEXITCODE | Should -Be 0
}
}