Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions test/IntegrationTest/Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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.
Expand All @@ -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"
Expand All @@ -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"
Expand Down
Loading