Skip to content

Commit 52dcf32

Browse files
authored
fix: Android device crash tests (#2098)
1 parent 66804c7 commit 52dcf32

File tree

3 files changed

+14
-54
lines changed

3 files changed

+14
-54
lines changed

.github/workflows/android-smoke-test-run.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
adb wait-for-device
8181
adb shell input keyevent 82
8282
adb devices -l
83-
pwsh ./scripts/smoke-test-android.ps1 -IsIntegrationTest -WarnIfFlaky
83+
pwsh ./scripts/smoke-test-android.ps1 -WarnIfFlaky
8484
8585
- name: Upload artifacts on failure
8686
if: ${{ failure() }}

scripts/smoke-test-android.ps1

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,52 +22,14 @@ Write-Host "# |___/_| |_|\___/|_|\_\___| |_| |___|___/ |_| #"
2222
Write-Host "# #"
2323
Write-Host "#####################################################"
2424

25-
if ($IsIntegrationTest)
26-
{
27-
$BuildDir = $(GetNewProjectBuildPath)
28-
$ApkFileName = "test.apk"
29-
$ProcessName = "com.DefaultCompany.$(GetNewProjectName)"
30-
31-
if ($Action -eq "Build")
32-
{
33-
$buildCallback = {
34-
Write-Host "::group::Gradle build $BuildDir"
35-
Push-Location $BuildDir
36-
try
37-
{
38-
MakeExecutable "./gradlew"
39-
& ./gradlew --info --no-daemon assembleRelease | ForEach-Object {
40-
Write-Host " $_"
41-
}
42-
if (-not $?)
43-
{
44-
throw "Gradle execution failed"
45-
}
46-
Copy-Item -Path launcher/build/outputs/apk/release/launcher-release.apk -Destination $ApkFileName
47-
}
48-
finally
49-
{
50-
Pop-Location
51-
Write-Host "::endgroup::"
52-
}
53-
}
54-
55-
$symbolServerOutput = RunWithSymbolServer -Callback $buildCallback
56-
CheckSymbolServerOutput 'Android' $symbolServerOutput $UnityVersion
57-
return;
58-
}
59-
}
60-
else
61-
{
62-
$BuildDir = "samples/artifacts/builds/Android"
63-
$ApkFileName = "IL2CPP_Player.apk"
64-
$ProcessName = "io.sentry.samples.unityofbugs"
65-
}
25+
$BuildDir = $(GetNewProjectBuildPath)
26+
$ApkFileName = "test.apk"
27+
$ProcessName = "com.DefaultCompany.$(GetNewProjectName)"
6628
$TestActivityName = "$ProcessName/com.unity3d.player.UnityPlayerActivity"
6729
$FallBackTestActivityName = "$ProcessName/com.unity3d.player.UnityPlayerGameActivity"
6830

69-
$_ArtifactsPath = ((Test-Path env:ARTIFACTS_PATH) ? $env:ARTIFACTS_PATH : "./$BuildDir/../test-artifacts/") `
70-
+ $(Get-Date -Format "HHmmss")
31+
$_ArtifactsPath = (Test-Path env:ARTIFACTS_PATH) ? $env:ARTIFACTS_PATH : (Join-Path $BuildDir "../test-artifacts/" $(Get-Date -Format "HHmmss"))
32+
7133
function ArtifactsPath
7234
{
7335
if (-not (Test-Path $_ArtifactsPath))
@@ -332,8 +294,8 @@ function RunTest([string] $Name, [string] $SuccessString, [string] $FailureStrin
332294
$logCache = ProcessNewLogs -newLogs $newLogs -lastLogCount ([ref]$lastLogCount) -logCache $logCache
333295

334296
# The SmokeTester logs "SmokeTester is quitting." in OnApplicationQuit() to reliably inform when tests finish running.
335-
# For crash tests, we expect to see a native crash log "terminating with uncaught exception of type char const*".
336-
if (($newLogs | Select-String "SmokeTester is quitting.") -or ($newLogs | Select-String "terminating with uncaught exception of type char const*"))
297+
# For crash tests, we're checking for `sentry-native` logging "crash has been captured" to reliably inform when tests finished running.
298+
if (($newLogs | Select-String "SmokeTester is quitting.") -or ($newLogs | Select-String "crash has been captured"))
337299
{
338300
Write-Host "Process finished marker detected. Finish waiting for tests to run."
339301
$processFinished = $true

test/Scripts.Integration.Test/integration-test.ps1

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,16 @@ If (-not(Test-Path -Path "$(GetNewProjectPath)"))
8282
./test/Scripts.Integration.Test/configure-sentry.ps1 "$UnityPath" -Platform $Platform -CheckSymbols
8383
}
8484

85+
# Support rebuilding the integration test project. I.e. if you make changes to the SmokeTester.cs during
8586
If ($Rebuild -or -not(Test-Path -Path $(GetNewProjectBuildPath)))
8687
{
8788
Write-Host "Building Project"
8889

89-
If (("iOS", "Android-Export") -contains $Platform)
90+
If ("iOS" -eq $Platform)
9091
{
91-
# Workaround for having `exportAsGoogleAndroidProject` remain `false` in Unity 6 on first build
92+
# We're exporting an Xcode project and building that in a separate step.
9293
./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$UnityPath" -UnityVersion $UnityVersion -Platform $Platform
93-
Remove-Item -Path $(GetNewProjectBuildPath) -Recurse -Force -Confirm:$false
94-
95-
./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$UnityPath" -UnityVersion $UnityVersion -Platform $Platform
96-
& "./scripts/smoke-test-$($Platform -eq 'iOS' ? 'ios' : 'android').ps1" Build -IsIntegrationTest -UnityVersion $UnityVersion
94+
& "./scripts/smoke-test-ios.ps1" Build -IsIntegrationTest -UnityVersion $UnityVersion
9795
}
9896
Else
9997
{
@@ -109,9 +107,9 @@ Switch -Regex ($Platform)
109107
{
110108
./test/Scripts.Integration.Test/run-smoke-test.ps1 -Smoke -Crash
111109
}
112-
"^(Android|Android-Export)$"
110+
"^(Android)$"
113111
{
114-
./scripts/smoke-test-android.ps1 -IsIntegrationTest
112+
./scripts/smoke-test-android.ps1
115113
}
116114
"^iOS$"
117115
{

0 commit comments

Comments
 (0)