diff --git a/modules/app-runner b/modules/app-runner index c8d126df8..0f464be81 160000 --- a/modules/app-runner +++ b/modules/app-runner @@ -1 +1 @@ -Subproject commit c8d126df8144b208d6fd11681e6aceb7e49949ee +Subproject commit 0f464be810b19684b99620c72ca7e8dc2b87c9cc diff --git a/test/IntegrationTest/Integration.Tests.ps1 b/test/IntegrationTest/Integration.Tests.ps1 index b76c225bb..dafec356d 100644 --- a/test/IntegrationTest/Integration.Tests.ps1 +++ b/test/IntegrationTest/Integration.Tests.ps1 @@ -223,6 +223,39 @@ BeforeAll { } } + # A launch that hangs before the Unity engine starts logs no Unity line, and app-runner force-stops it + # after the run timeout. Relaunch once per run. After a second such launch, stop launching: each one + # costs the full run timeout and the job would time out instead of reporting the failure. + function Invoke-App { + param([string]$Action) + + if ($script:AndroidUninitialisedLaunches -ge 2) { + throw "Not launching ${Action}: the Android app already failed to initialise twice." + } + + $runResult = Invoke-DeviceApp -ExecutablePath $script:ExecutablePath -Arguments (Get-AppArguments -Action $Action) + + if ($script:Platform -eq "Android" -and -not (Test-AndroidAppInitialised $runResult)) { + $script:AndroidUninitialisedLaunches++ + Write-Host "::group::App output ($Action, never initialised)" + $runResult.Output | ForEach-Object { Write-Host $_ } + Write-Host "::endgroup::" + + if ($script:AndroidUninitialisedLaunches -eq 1) { + Write-Host "::warning::Android app never initialised, relaunching (1/1)" + return Invoke-App -Action $Action + } + } + + return $runResult + } + + function Test-AndroidAppInitialised { + param($RunResult) + + return [bool]($RunResult.Output | Where-Object { $_ -match 'EVENT_CAPTURED:|\s[VDIWEF] Unity\s*:' }) + } + # Run integration test action function Invoke-TestAction { param ( @@ -236,8 +269,7 @@ BeforeAll { return Invoke-WebGLTestAction -Action $Action } - $appArgs = Get-AppArguments -Action $Action - $runResult = Invoke-DeviceApp -ExecutablePath $script:ExecutablePath -Arguments $appArgs + $runResult = Invoke-App -Action $Action # On Xbox, console output is not available in non-development builds. # Retrieve the log file the app writes directly to disk. @@ -252,8 +284,7 @@ BeforeAll { if ($Action -eq "crash-capture") { Write-Host "Running crash-send to ensure crash report is sent..." - $sendArgs = Get-AppArguments -Action "crash-send" - $sendResult = Invoke-DeviceApp -ExecutablePath $script:ExecutablePath -Arguments $sendArgs + $sendResult = Invoke-App -Action "crash-send" if ($script:Platform -eq "Xbox") { $sendResult = Get-XboxLogOutput -RunResult $sendResult -Action "crash-send" @@ -279,6 +310,8 @@ BeforeAll { return $runResult } + $script:AndroidUninitialisedLaunches = 0 + $script:Platform = $env:SENTRY_TEST_PLATFORM if ([string]::IsNullOrEmpty($script:Platform)) { throw "SENTRY_TEST_PLATFORM environment variable is not set. Expected: Android, Desktop, iOS, WebGL, or Xbox"