@@ -12,39 +12,37 @@ BeforeDiscovery {
1212 $script :emulator = Get-AndroidEmulatorId
1313}
1414
15- Describe ' MAUI app' - ForEach @ (
16- @ { tfm = " net9.0-android35.0" }
15+ Describe ' MAUI app (<tfm>, <configuration>)' - ForEach @ (
16+ @ { tfm = " net9.0-android35.0" ; configuration = " Release" }
17+ @ { tfm = " net9.0-android35.0" ; configuration = " Debug" }
1718) - Skip:(-not $script :emulator ) {
1819 BeforeAll {
1920 Remove-Item - Path " $PSScriptRoot /mobile-app" - Recurse - Force - ErrorAction SilentlyContinue
2021 Copy-Item - Path " $PSScriptRoot /net9-maui" - Destination " $PSScriptRoot /mobile-app" - Recurse - Force
2122 Push-Location $PSScriptRoot / mobile- app
2223
23- function InstallAndroidApp
24- {
25- param ([string ] $Dsn )
26- $dsn = $Dsn.Replace (' http://' , ' http://key@' ) + ' /0'
27-
28- # replace {{SENTRY_DSN}} in MauiProgram.cs
29- (Get-Content MauiProgram.cs) `
30- -replace ' \{\{SENTRY_DSN\}\}' , $dsn `
31- | Set-Content MauiProgram.cs
24+ # replace {{SENTRY_DSN}} in MauiProgram.cs
25+ (Get-Content MauiProgram.cs) `
26+ -replace ' \{\{SENTRY_DSN\}\}' , ' http://key@127.0.0.1:8000/0' `
27+ | Set-Content MauiProgram.cs
3228
33- $arch = [System.Runtime.InteropServices.RuntimeInformation ]::OSArchitecture.ToString().ToLower()
34- $rid = " android-$arch "
29+ $arch = [System.Runtime.InteropServices.RuntimeInformation ]::OSArchitecture.ToString().ToLower()
30+ $rid = " android-$arch "
3531
36- Write-Host " ::group::Build Sentry.Maui.Device.IntegrationTestApp.csproj"
37- dotnet build Sentry.Maui.Device.IntegrationTestApp.csproj `
38- -- configuration Release `
39- -- framework $tfm `
40- -- runtime $rid
41- | ForEach-Object { Write-Host $_ }
42- Write-Host ' ::endgroup::'
43- $LASTEXITCODE | Should - Be 0
32+ Write-Host " ::group::Build Sentry.Maui.Device.IntegrationTestApp.csproj"
33+ dotnet build Sentry.Maui.Device.IntegrationTestApp.csproj `
34+ -- configuration $configuration `
35+ -- framework $tfm `
36+ -- runtime $rid
37+ | ForEach-Object { Write-Host $_ }
38+ Write-Host ' ::endgroup::'
39+ $LASTEXITCODE | Should - Be 0
4440
45- Write-Host " ::group::Install bin/Release/$tfm /$rid /io.sentry.dotnet.maui.device.integrationtestapp-Signed.apk"
41+ function InstallAndroidApp
42+ {
43+ Write-Host " ::group::Install bin/$configuration /$tfm /$rid /io.sentry.dotnet.maui.device.integrationtestapp-Signed.apk"
4644 xharness android install - v `
47- -- app bin/ Release / $tfm / $rid / io.sentry.dotnet.maui.device.integrationtestapp- Signed.apk `
45+ -- app bin/ $configuration / $tfm / $rid / io.sentry.dotnet.maui.device.integrationtestapp- Signed.apk `
4846 -- package- name io.sentry.dotnet.maui.device.integrationtestapp `
4947 -- output- directory= test_output
5048 | ForEach-Object { Write-Host $_ }
@@ -58,35 +56,25 @@ Describe 'MAUI app' -ForEach @(
5856 [string ] $Dsn ,
5957 [string ] $TestArg = ' None'
6058 )
59+ Write-Host " ::group::Run Android app (TestArg=$TestArg )"
60+ $dsn = $Dsn.Replace (' http://' , ' http://key@' ) + ' /0'
61+ xharness android adb - v `
62+ -- shell am start - S - n io.sentry.dotnet.maui.device.integrationtestapp/ .MainActivity `
63+ - e SENTRY_DSN $dsn `
64+ - e SENTRY_TEST_ARG $TestArg
65+ | ForEach-Object { Write-Host $_ }
66+ Write-Host ' ::endgroup::'
67+ $LASTEXITCODE | Should - Be 0
6168
62- try
69+ do
6370 {
64- # Setup port forwarding for accessing sentry-server at 127.0.0.1:8000 from the emulator
65- $port = $Dsn.Split (' :' )[2 ].Split(' /' )[0 ]
66- xharness android adb - v -- reverse tcp:$port tcp:$port
67-
68- Write-Host " ::group::Run Android app (TestArg=$TestArg )"
69- xharness android adb - v `
70- -- shell am start - S - n io.sentry.dotnet.maui.device.integrationtestapp/ .MainActivity `
71- - e SENTRY_TEST_ARG $TestArg
72- | ForEach-Object { Write-Host $_ }
73- Write-Host ' ::endgroup::'
74- $LASTEXITCODE | Should - Be 0
71+ Write-Host " Waiting for app..."
72+ Start-Sleep - Seconds 1
7573
76- do
77- {
78- Write-Host " Waiting for app..."
79- Start-Sleep - Seconds 1
74+ $procid = (& xharness android adb -- shell pidof " io.sentry.dotnet.maui.device.integrationtestapp" ) -replace ' \s' , ' '
75+ $activity = (& xharness android adb -- shell dumpsys activity activities) -match " io\.sentry\.dotnet\.maui\.device\.integrationtestapp"
8076
81- $procid = (& xharness android adb -- shell pidof " io.sentry.dotnet.maui.device.integrationtestapp" ) -replace ' \s' , ' '
82- $activity = (& xharness android adb -- shell dumpsys activity activities) -match " io\.sentry\.dotnet\.maui\.device\.integrationtestapp"
83-
84- } while ($procid -and $activity )
85- }
86- finally
87- {
88- xharness android adb - v -- reverse -- remove-all
89- }
77+ } while ($procid -and $activity )
9078 }
9179
9280 function UninstallAndroidApp
@@ -111,20 +99,27 @@ Describe 'MAUI app' -ForEach @(
11199 Write-Host ' ::endgroup::'
112100 }
113101 }
102+
103+ # Setup port forwarding for accessing sentry-server at 127.0.0.1:8000 from the emulator
104+ xharness android adb - v -- reverse tcp:8000 tcp:8000
114105 }
115106
116107 AfterAll {
117108 Pop-Location
109+ xharness android adb - v -- reverse -- remove tcp:8000
110+ }
111+
112+ BeforeEach {
113+ InstallAndroidApp
118114 }
119115
120116 AfterEach {
121117 UninstallAndroidApp
122118 }
123119
124- It ' Managed crash' {
120+ It ' Managed crash (<configuration>) ' {
125121 $result = Invoke-SentryServer {
126122 param ([string ]$url )
127- InstallAndroidApp - Dsn $url
128123 RunAndroidApp - Dsn $url - TestArg " Managed"
129124 RunAndroidApp - Dsn $url
130125 }
@@ -133,12 +128,12 @@ Describe 'MAUI app' -ForEach @(
133128 $result.HasErrors () | Should - BeFalse
134129 $result.Envelopes () | Should - AnyElementMatch " `" type`" :`" System.ApplicationException`" "
135130 $result.Envelopes () | Should -Not - AnyElementMatch " `" type`" :`" SIGABRT`" "
131+ $result.Envelopes () | Should - HaveCount 1
136132 }
137133
138- It ' Java crash' {
134+ It ' Java crash (<configuration>) ' {
139135 $result = Invoke-SentryServer {
140136 param ([string ]$url )
141- InstallAndroidApp - Dsn $url
142137 RunAndroidApp - Dsn $url - TestArg " Java"
143138 RunAndroidApp - Dsn $url
144139 }
@@ -147,20 +142,39 @@ Describe 'MAUI app' -ForEach @(
147142 $result.HasErrors () | Should - BeFalse
148143 $result.Envelopes () | Should - AnyElementMatch " `" type`" :`" RuntimeException`" "
149144 $result.Envelopes () | Should -Not - AnyElementMatch " `" type`" :`" System.\w+Exception`" "
145+ $result.Envelopes () | Should - HaveCount 1
146+ }
147+
148+ It ' Native crash (<configuration>)' {
149+ $result = Invoke-SentryServer {
150+ param ([string ]$url )
151+ RunAndroidApp - Dsn $url - TestArg " Native"
152+ RunAndroidApp - Dsn $url
153+ }
154+
155+ Dump- ServerErrors - Result $result
156+ $result.HasErrors () | Should - BeFalse
157+ $result.Envelopes () | Should - AnyElementMatch " `" type`" :`" SIG[A-Z]+`" " # SIGILL (x86_64), SIGTRAP (arm64-v8a)
158+ $result.Envelopes () | Should -Not - AnyElementMatch " `" type`" :`" System.\w+Exception`" "
159+ $result.Envelopes () | Should - HaveCount 1
150160 }
151161
152- It ' Null reference exception' {
162+ It ' Null reference exception (<configuration>) ' {
153163 $result = Invoke-SentryServer {
154164 param ([string ]$url )
155- InstallAndroidApp - Dsn $url
156165 RunAndroidApp - Dsn $url - TestArg " NullReferenceException"
157166 RunAndroidApp - Dsn $url
158167 }
159168
160169 Dump- ServerErrors - Result $result
161170 $result.HasErrors () | Should - BeFalse
162171 $result.Envelopes () | Should - AnyElementMatch " `" type`" :`" System.NullReferenceException`" "
163- # TODO: fix redundant RuntimeException (#3954)
164- { $result.Envelopes () | Should -Not - AnyElementMatch " `" type`" :`" SIGSEGV`" " } | Should - Throw
172+ # TODO: fix redundant SIGSEGV in Release (#3954)
173+ if ($configuration -eq " Release" ) {
174+ { $result.Envelopes () | Should -Not - AnyElementMatch " `" type`" :`" SIGSEGV`" " } | Should - Throw
175+ } else {
176+ $result.Envelopes () | Should -Not - AnyElementMatch " `" type`" :`" SIGSEGV`" "
177+ $result.Envelopes () | Should - HaveCount 1
178+ }
165179 }
166180}
0 commit comments