-
-
Notifications
You must be signed in to change notification settings - Fork 58
chore: Utilize app-runner for iOS #2562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
65bfb99
d90e410
323d187
5b30b7d
20554a9
b899cc5
7c93e12
3dceec0
e999f6e
b6fc8a2
f39fb13
3902b68
0638d92
f05f223
160f355
f5e1c10
10ba69c
c2e1256
a0318cf
aa815ff
fc3c734
ab6d14e
af19c5e
9588ff9
0ffce53
8be86be
d6c5084
bf353f6
d0e10ea
0cc6ab4
641f5e1
36943c3
8322cbd
9cf1ec5
7f03d3f
5915218
0965ded
0457ff8
5f18483
5af6bdd
0f34226
3d035ca
5a96ca9
8ce299c
8803de8
8d11278
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| +2 −3 | app-runner/Private/DeviceProviders/iOSSimulatorProvider.ps1 | |
| +11 −19 | app-runner/Tests/iOSSimulator.Tests.ps1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| #!/usr/bin/env pwsh | ||
| # | ||
| # Integration tests for Sentry Unity SDK (iOS Simulator) | ||
| # | ||
| # Environment variables: | ||
| # SENTRY_TEST_APP: path to the test .app bundle | ||
| # SENTRY_IOS_VERSION: iOS simulator version (e.g. "17.0" or "latest") | ||
| # SENTRY_TEST_DSN: test DSN | ||
| # SENTRY_AUTH_TOKEN: authentication token for Sentry API | ||
JoshuaMoelans marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Set-StrictMode -Version latest | ||
| $ErrorActionPreference = "Stop" | ||
|
|
||
| # Import app-runner modules | ||
| . $PSScriptRoot/../../modules/app-runner/import-modules.ps1 | ||
|
|
||
| # Import shared test cases and utility functions | ||
| . $PSScriptRoot/CommonTestCases.ps1 | ||
|
|
||
|
|
||
| BeforeAll { | ||
| $script:BundleId = "com.DefaultCompany.IntegrationTest" | ||
|
|
||
| # Run integration test action on device | ||
| function Invoke-TestAction { | ||
| param ( | ||
| [Parameter(Mandatory=$true)] | ||
| [string]$Action | ||
| ) | ||
|
|
||
| Write-Host "Running $Action..." | ||
|
|
||
| $appArgs = @("--test", $Action) | ||
|
|
||
| $runResult = Invoke-DeviceApp -ExecutablePath $script:BundleId -Arguments $appArgs | ||
|
|
||
| # Save result to JSON file | ||
| $runResult | ConvertTo-Json -Depth 5 | Out-File -FilePath (Get-OutputFilePath "${Action}-result.json") | ||
|
|
||
| # Launch app again to ensure crash report is sent | ||
| if ($Action -eq "crash-capture") { | ||
| Write-Host "Running crash-send to ensure crash report is sent..." | ||
|
|
||
| $sendArgs = @("--test", "crash-send") | ||
| $sendResult = Invoke-DeviceApp -ExecutablePath $script:BundleId -Arguments $sendArgs | ||
|
|
||
| # Save crash-send result to JSON for debugging | ||
| $sendResult | ConvertTo-Json -Depth 5 | Out-File -FilePath (Get-OutputFilePath "crash-send-result.json") | ||
|
|
||
| # Print crash-send output | ||
| Write-Host "::group::App output (crash-send)" | ||
| $sendResult.Output | ForEach-Object { Write-Host $_ } | ||
| Write-Host "::endgroup::" | ||
|
|
||
| # Attach to runResult for test access | ||
| $runResult | Add-Member -NotePropertyName "CrashSendOutput" -NotePropertyValue $sendResult.Output | ||
| } | ||
|
|
||
| # Print app output so it's visible in CI logs | ||
| Write-Host "::group::App output ($Action)" | ||
| $runResult.Output | ForEach-Object { Write-Host $_ } | ||
| Write-Host "::endgroup::" | ||
|
|
||
| return $runResult | ||
| } | ||
|
|
||
| # Create directory for the test results | ||
| New-Item -ItemType Directory -Path "$PSScriptRoot/results/" -ErrorAction Continue 2>&1 | Out-Null | ||
| Set-OutputDir -Path "$PSScriptRoot/results/" | ||
|
|
||
| # Initialize test parameters | ||
| $script:TestSetup = [PSCustomObject]@{ | ||
| Platform = "iOS" | ||
| AppPath = $env:SENTRY_TEST_APP | ||
| iOSVersion = $env:SENTRY_IOS_VERSION | ||
| Dsn = $env:SENTRY_TEST_DSN | ||
| AuthToken = $env:SENTRY_AUTH_TOKEN | ||
| } | ||
|
|
||
| # Validate environment | ||
| if ([string]::IsNullOrEmpty($script:TestSetup.AppPath)) { | ||
| throw "SENTRY_TEST_APP environment variable is not set." | ||
| } | ||
| if (-not (Test-Path $script:TestSetup.AppPath)) { | ||
| throw "App not found at: $($script:TestSetup.AppPath)" | ||
| } | ||
| if ([string]::IsNullOrEmpty($script:TestSetup.iOSVersion)) { | ||
| throw "SENTRY_IOS_VERSION environment variable is not set." | ||
| } | ||
| if ([string]::IsNullOrEmpty($script:TestSetup.Dsn)) { | ||
| throw "SENTRY_TEST_DSN environment variable is not set." | ||
| } | ||
| if ([string]::IsNullOrEmpty($script:TestSetup.AuthToken)) { | ||
| throw "SENTRY_AUTH_TOKEN environment variable is not set." | ||
| } | ||
|
|
||
| Connect-SentryApi ` | ||
| -ApiToken $script:TestSetup.AuthToken ` | ||
| -DSN $script:TestSetup.Dsn | ||
|
|
||
| $target = $script:TestSetup.iOSVersion | ||
| # Convert bare version numbers (e.g. "17.0") to "iOS 17.0" format expected by iOSSimulatorProvider | ||
| if ($target -match '^\d+\.\d+$') { | ||
| $target = "iOS $target" | ||
| } | ||
| Connect-Device -Platform "iOSSimulator" -Target $target | ||
| Install-DeviceApp -Path $script:TestSetup.AppPath | ||
| } | ||
|
|
||
|
|
||
| AfterAll { | ||
| Disconnect-SentryApi | ||
| Disconnect-Device | ||
| } | ||
|
|
||
|
|
||
| Describe "Unity iOS Integration Tests" { | ||
|
|
||
| Context "Message Capture" { | ||
| BeforeAll { | ||
| $script:runEvent = $null | ||
| $script:runResult = Invoke-TestAction -Action "message-capture" | ||
|
|
||
| $eventId = Get-EventIds -AppOutput $script:runResult.Output -ExpectedCount 1 | ||
| if ($eventId) { | ||
| Write-Host "::group::Getting event content" | ||
| $script:runEvent = Get-SentryTestEvent -EventId "$eventId" | ||
| Write-Host "::endgroup::" | ||
| } | ||
| } | ||
|
|
||
| It "<Name>" -ForEach $CommonTestCases { | ||
| & $testBlock -SentryEvent $runEvent -TestType "message-capture" -RunResult $runResult -TestSetup $script:TestSetup | ||
| } | ||
bitsandfoxes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| It "Has message level info" { | ||
| ($runEvent.tags | Where-Object { $_.key -eq "level" }).value | Should -Be "info" | ||
| } | ||
|
|
||
| It "Has message content" { | ||
| $runEvent.title | Should -Not -BeNullOrEmpty | ||
| } | ||
| } | ||
|
|
||
| Context "Exception Capture" { | ||
| BeforeAll { | ||
| $script:runEvent = $null | ||
| $script:runResult = Invoke-TestAction -Action "exception-capture" | ||
|
|
||
| $eventId = Get-EventIds -AppOutput $script:runResult.Output -ExpectedCount 1 | ||
| if ($eventId) { | ||
| Write-Host "::group::Getting event content" | ||
| $script:runEvent = Get-SentryTestEvent -EventId "$eventId" | ||
| Write-Host "::endgroup::" | ||
| } | ||
| } | ||
|
|
||
| It "<Name>" -ForEach $CommonTestCases { | ||
| & $testBlock -SentryEvent $runEvent -TestType "exception-capture" -RunResult $runResult -TestSetup $script:TestSetup | ||
| } | ||
|
|
||
| It "Has exception information" { | ||
| $runEvent.exception | Should -Not -BeNullOrEmpty | ||
| $runEvent.exception.values | Should -Not -BeNullOrEmpty | ||
| } | ||
|
|
||
| It "Has exception with stacktrace" { | ||
| $exception = $runEvent.exception.values[0] | ||
| $exception | Should -Not -BeNullOrEmpty | ||
| $exception.type | Should -Not -BeNullOrEmpty | ||
| $exception.stacktrace | Should -Not -BeNullOrEmpty | ||
| } | ||
|
|
||
| It "Has error level" { | ||
| ($runEvent.tags | Where-Object { $_.key -eq "level" }).value | Should -Be "error" | ||
| } | ||
| } | ||
|
|
||
| Context "Crash Capture" { | ||
| BeforeAll { | ||
| $script:runEvent = $null | ||
| $script:runResult = Invoke-TestAction -Action "crash-capture" | ||
|
|
||
| $eventId = Get-EventIds -AppOutput $script:runResult.Output -ExpectedCount 1 | ||
| if ($eventId) { | ||
| Write-Host "::group::Getting event content" | ||
| $script:runEvent = Get-SentryTestEvent -TagName "test.crash_id" -TagValue "$eventId" -TimeoutSeconds 120 | ||
| Write-Host "::endgroup::" | ||
| } | ||
| } | ||
|
|
||
| It "<Name>" -ForEach $CommonTestCases { | ||
| & $testBlock -SentryEvent $runEvent -TestType "crash-capture" -RunResult $runResult -TestSetup $script:TestSetup | ||
| } | ||
|
|
||
| It "Has fatal level" { | ||
| ($runEvent.tags | Where-Object { $_.key -eq "level" }).value | Should -Be "fatal" | ||
| } | ||
|
|
||
| It "Has exception with stacktrace" { | ||
| $runEvent.exception | Should -Not -BeNullOrEmpty | ||
| $runEvent.exception.values | Should -Not -BeNullOrEmpty | ||
| $exception = $runEvent.exception.values[0] | ||
| $exception | Should -Not -BeNullOrEmpty | ||
| $exception.stacktrace | Should -Not -BeNullOrEmpty | ||
| } | ||
|
|
||
| It "Reports crashedLastRun as Crashed on relaunch" { | ||
| $crashedLastRunLine = $runResult.CrashSendOutput | Where-Object { | ||
| $_ -match "crashedLastRun=Crashed" | ||
| } | ||
| $crashedLastRunLine | Should -Not -BeNullOrEmpty -Because "Native SDK should report crashedLastRun=Crashed after a native crash" | ||
| } | ||
|
|
||
| It "Crash-send completes flush successfully" { | ||
| $flushLine = $runResult.CrashSendOutput | Where-Object { | ||
| $_ -match "Flush complete" | ||
| } | ||
| $flushLine | Should -Not -BeNullOrEmpty -Because "crash-send should complete its flush before quitting" | ||
| } | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Near-complete duplication of integration test fileLow Severity
Additional Locations (1)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||



Uh oh!
There was an error while loading. Please reload this page.