-
-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathios.Tests.ps1
More file actions
134 lines (117 loc) · 5 KB
/
ios.Tests.ps1
File metadata and controls
134 lines (117 loc) · 5 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
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
# This file contains test cases for https://pester.dev/
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
. $PSScriptRoot/pester.ps1
. $PSScriptRoot/../scripts/device-test-utils.ps1
BeforeDiscovery {
# Skip iOS integration tests unless a simulator has already been booted by
# iOS Device Tests, or manually when testing locally. This avoids slowing
# down the macOS build job further.
$script:simulator = Get-IosSimulatorUdid -PreferredStates @('Booted')
}
Describe 'iOS app (<tfm>, <configuration>)' -ForEach @(
@{ tfm = "net9.0-ios18.0"; configuration = "Release" }
@{ tfm = "net9.0-ios18.0"; configuration = "Debug" }
) -Skip:(-not $script:simulator) {
BeforeAll {
. $PSScriptRoot/../scripts/device-test-utils.ps1
Remove-Item -Path "$PSScriptRoot/mobile-app" -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$PSScriptRoot/net9-maui" -Destination "$PSScriptRoot/mobile-app" -Recurse -Force
Push-Location $PSScriptRoot/mobile-app
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower()
$rid = "iossimulator-$arch"
Write-Host "::group::Build Sentry.Maui.Device.IntegrationTestApp.csproj"
dotnet build Sentry.Maui.Device.IntegrationTestApp.csproj `
--configuration $configuration `
--framework $tfm `
--runtime $rid
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0
function InstallIosApp
{
Write-Host "::group::Install bin/$configuration/$tfm/$rid/Sentry.Maui.Device.IntegrationTestApp.app"
xcrun simctl install $simulator `
bin/$configuration/$tfm/$rid/Sentry.Maui.Device.IntegrationTestApp.app
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0
}
function UninstallIosApp
{
Write-Host "::group::Uninstall io.sentry.dotnet.maui.device.integrationtestapp"
xcrun simctl uninstall $simulator `
io.sentry.dotnet.maui.device.integrationtestapp
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0
}
function RunIosApp
{
param(
[string] $Dsn,
[string] $TestArg = 'None'
)
$Dsn = $Dsn.Replace('http://', 'http://key@') + '/0'
Write-Host "::group::Run iOS app (TestArg=$TestArg)"
xcrun simctl spawn $simulator launchctl setenv SENTRY_DSN $Dsn
xcrun simctl spawn $simulator launchctl setenv SENTRY_TEST_ARG $TestArg
xcrun simctl launch `
--console `
--terminate-running-process `
$simulator `
io.sentry.dotnet.maui.device.integrationtestapp
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0
}
}
AfterAll {
Pop-Location
}
BeforeEach {
InstallIosApp
}
AfterEach {
UninstallIosApp
}
It 'captures managed crash (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
RunIosApp -Dsn $url -TestArg "Managed"
RunIosApp -Dsn $url
}
$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.ApplicationException`""
# TODO: fix redundant SIGABRT (#3954)
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGABRT`"" } | Should -Throw
{ $result.Envelopes() | Should -HaveCount 1 } | Should -Throw
}
It 'captures native crash (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
RunIosApp -Dsn $url -TestArg "Native"
RunIosApp -Dsn $url
}
$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"EXC_[A-Z_]+`""
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
$result.Envelopes() | Should -HaveCount 1
}
It 'captures null reference exception (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
RunIosApp -Dsn $url -TestArg "NullReferenceException"
RunIosApp -Dsn $url
}
$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`""
# TODO: fix redundant EXC_BAD_ACCESS in Release (#3954)
if ($configuration -eq 'Release') {
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`"" } | Should -Throw
} else {
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`""
$result.Envelopes() | Should -HaveCount 1
}
}
}