-
-
Notifications
You must be signed in to change notification settings - Fork 206
/
cli.Tests.ps1
190 lines (169 loc) · 8.1 KB
/
cli.Tests.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# This file contains test cases for https://pester.dev/
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
. $PSScriptRoot/common.ps1
Describe 'Console apps (<framework>) - normal build' -ForEach @(
@{ framework = "net8.0" }
) {
BeforeAll {
DotnetNew 'console' 'console-app' $framework
}
BeforeEach {
Remove-Item "./console-app/bin/Release/$framework/*.src.zip" -ErrorAction SilentlyContinue
}
It "uploads symbols and sources" {
$result = RunDotnetWithSentryCLI 'build' 'console-app' $True $True $framework
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @('console-app.pdb')
$result.ScriptOutput | Should -AnyElementMatch 'Found 1 debug information file \(1 with embedded sources\)'
$result.ScriptOutput | Should -AnyElementMatch 'Resolved source code for 0 debug information files'
}
It "uploads symbols" {
$result = RunDotnetWithSentryCLI 'build' 'console-app' $True $False $framework
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @('console-app.pdb')
$result.ScriptOutput | Should -AnyElementMatch 'Found 1 debug information file \(1 with embedded sources\)'
}
It "uploads sources" {
$result = RunDotnetWithSentryCLI 'build' 'console-app' $False $True $framework
$result.ScriptOutput | Should -AnyElementMatch 'Skipping embedded source file: .*/console-app/Program.cs'
$result.UploadedDebugFiles() | Should -BeNullOrEmpty
}
It "uploads nothing when disabled" {
$result = RunDotnetWithSentryCLI 'build' 'console-app' $False $False $framework
$result.UploadedDebugFiles() | Should -BeNullOrEmpty
}
}
Describe 'Console apps (<framework>) - native AOT publish' -ForEach @(
@{ framework = "net8.0" }
) {
BeforeAll {
DotnetNew 'console' 'console-app' $framework
}
BeforeEach {
Remove-Item "./console-app/bin/Release/$framework/publish" -Recurse -ErrorAction SilentlyContinue
}
It "uploads symbols and sources" {
$result = RunDotnetWithSentryCLI 'publish' 'console-app' $True $True $framework
$result.ScriptOutput | Should -AnyElementMatch "Preparing upload to Sentry for project 'console-app'"
if ($IsWindows)
{
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @("console-app.pdb")
$result.ScriptOutput | Should -AnyElementMatch 'Found 1 debug information file'
$result.ScriptOutput | Should -AnyElementMatch 'Resolved source code for 1 debug information file'
}
else
{
# On macOS, only the dwarf is uploaded from dSYM so it has the same name as the actual executable.
$debugExtension = $IsLinux ? '.dbg' : ''
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be (@(
'console-app', "console-app$debugExtension") | Sort-Object -Unique)
$result.ScriptOutput | Should -AnyElementMatch 'Found 2 debug information files'
$result.ScriptOutput | Should -AnyElementMatch 'Resolved source code for 1 debug information file'
}
}
It "uploads symbols" {
$result = RunDotnetWithSentryCLI 'publish' 'console-app' $True $False $framework
$result.ScriptOutput | Should -AnyElementMatch "Preparing upload to Sentry for project 'console-app'"
if ($IsWindows)
{
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @("console-app.pdb")
$result.ScriptOutput | Should -AnyElementMatch 'Found 1 debug information file'
}
else
{
# On macOS, only the dwarf is uploaded from dSYM so it has the same name as the actual executable.
$debugExtension = $IsLinux ? '.dbg' : ''
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be (@(
'console-app', "console-app$debugExtension") | Sort-Object -Unique)
$result.ScriptOutput | Should -AnyElementMatch 'Found 2 debug information files'
}
}
It "uploads sources" {
$result = RunDotnetWithSentryCLI 'publish' 'console-app' $False $True $framework
$result.ScriptOutput | Should -AnyElementMatch "Preparing upload to Sentry for project 'console-app'"
$sourceBundle = 'console-app.src.zip'
if ($IsMacOS)
{
$sourceBundle = 'console-app.src.zip'
}
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @($sourceBundle)
}
It "uploads nothing when disabled" {
$result = RunDotnetWithSentryCLI 'publish' 'console-app' $False $False $framework
$result.UploadedDebugFiles() | Should -BeNullOrEmpty
}
}
Describe 'MAUI' -ForEach @(
@{ framework = "net8.0" }
) {
BeforeAll {
RegisterLocalPackage 'Sentry.Android.AssemblyReader'
RegisterLocalPackage 'Sentry.Bindings.Android'
RegisterLocalPackage 'Sentry.Extensions.Logging'
RegisterLocalPackage 'Sentry.Maui'
if ($IsMacOS)
{
RegisterLocalPackage 'Sentry.Bindings.Cocoa'
}
$name = 'maui-app'
DotnetNew 'maui' $name $framework
# Workaround for the missing "ios" workload on Linux, see https://github.com/dotnet/maui/pull/18580
$tfs = $IsMacos ? "$framework-android;$framework-ios;$framework-maccatalyst" : "$framework-android"
(Get-Content $name/$name.csproj) -replace '<TargetFrameworks>[^<]+</TargetFrameworks>', "<TargetFrameworks>$tfs</TargetFrameworks>" | Set-Content $name/$name.csproj
dotnet remove $name/$name.csproj package 'Microsoft.Extensions.Logging.Debug' | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0)
{
throw "Failed to remove package"
}
if (Test-Path env:CI)
{
dotnet workload restore $name/$name.csproj | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0)
{
throw "Failed to restore workloads."
}
}
AddPackageReference $name 'Sentry.Maui'
if (Test-Path env:CI)
{
dotnet build $name/$name.csproj -t:InstallAndroidDependencies -f:$framework-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath="/usr/local/lib/android/sdk/" | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0)
{
throw "Failed to install android dependencies."
}
}
}
It "uploads symbols and sources for an Android build" {
$result = RunDotnetWithSentryCLI 'build' 'maui-app' $True $True "$framework-android"
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @(
'libsentry-android.so',
'libsentry.so',
'libsentrysupplemental.so',
'libxamarin-app.so',
'maui-app.pdb'
)
$result.ScriptOutput | Should -AnyElementMatch 'Uploaded a total of 1 new mapping files'
$result.ScriptOutput | Should -AnyElementMatch 'Found 17 debug information files \(1 with embedded sources\)'
}
It "uploads symbols and sources for an iOS build" -Skip:(!$IsMacOS) {
$result = RunDotnetWithSentryCLI 'build' 'maui-app' $True $True "$framework-ios"
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @(
'libmono-component-debugger.dylib',
'libmono-component-diagnostics_tracing.dylib',
'libmono-component-hot_reload.dylib',
'libmono-component-marshal-ilgen.dylib',
'libmonosgen-2.0.dylib',
'libSystem.Globalization.Native.dylib',
'libSystem.IO.Compression.Native.dylib',
'libSystem.Native.dylib',
'libSystem.Net.Security.Native.dylib',
'libSystem.Security.Cryptography.Native.Apple.dylib',
'libxamarin-dotnet-debug.dylib',
'libxamarin-dotnet.dylib',
'maui-app',
'maui-app.pdb',
'Sentry'
)
$nonZeroNumberRegex = '[1-9][0-9]*';
$result.ScriptOutput | Should -AnyElementMatch "Found $nonZeroNumberRegex debug information files \($nonZeroNumberRegex with embedded sources\)"
}
}