-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathdevice-test.ps1
More file actions
102 lines (93 loc) · 3 KB
/
device-test.ps1
File metadata and controls
102 lines (93 loc) · 3 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
param(
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[ValidateSet('android', 'ios')] # TODO , 'maccatalyst'
[String] $Platform,
[Switch] $Build,
[Switch] $Run
)
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
if (!$Build -and !$Run)
{
$Build = $true
$Run = $true
}
$CI = Test-Path env:CI
Push-Location $PSScriptRoot/..
try
{
$tfm = 'net8.0-'
$arch = (!$IsWindows -and $(uname -m) -eq 'arm64') ? 'arm64' : 'x64'
if ($Platform -eq 'android')
{
$tfm += 'android'
$group = 'android'
$buildDir = $CI ? 'bin' : "test/Sentry.Maui.Device.TestApp/bin/Release/$tfm/android-$arch"
$arguments = @(
'--app', "$buildDir/io.sentry.dotnet.maui.device.testapp-Signed.apk",
'--package-name', 'io.sentry.dotnet.maui.device.testapp',
'--launch-timeout', '00:10:00',
'--instrumentation', 'Sentry.Maui.Device.TestApp.SentryInstrumentation'
)
if ($CI)
{
$arguments += '--arg'
$arguments += 'IsGitHubActions=true'
}
}
elseif ($Platform -eq 'ios')
{
$tfm += 'ios'
$group = 'apple'
# Always use x64 on iOS, since arm64 doesn't support JIT, which is required for tests using NSubstitute
$arch = 'x64'
$buildDir = "test/Sentry.Maui.Device.TestApp/bin/Release/$tfm/iossimulator-$arch"
$envValue = $CI ? 'true' : 'false'
$arguments = @(
'--app', "$buildDir/Sentry.Maui.Device.TestApp.app",
'--target', 'ios-simulator-64',
'--launch-timeout', '00:10:00',
'--set-env', 'CI=$envValue'
)
}
if ($Build)
{
# We disable AOT for device tests: https://github.com/nsubstitute/NSubstitute/issues/834
dotnet build -f $tfm -c Release -p:EnableAot=false test/Sentry.Maui.Device.TestApp
if ($LASTEXITCODE -ne 0)
{
throw 'Failed to build Sentry.Maui.Device.TestApp'
}
}
if ($Run)
{
if (!(Get-Command xharness -ErrorAction SilentlyContinue))
{
Push-Location ($CI ? $env:RUNNER_TEMP : $IsWindows ? $env:TMP : $IsMacos ? $env:TMPDIR : '/temp')
dotnet tool install Microsoft.DotNet.XHarness.CLI --global --version '10.0.0-prerelease*' `
--add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json
Pop-Location
}
Remove-Item -Recurse -Force test_output -ErrorAction SilentlyContinue
try
{
xharness $group test $arguments --output-directory=test_output
if ($LASTEXITCODE -ne 0)
{
throw 'xharness run failed with non-zero exit code'
}
}
finally
{
if ($CI)
{
scripts/parse-xunit2-xml.ps1 (Get-Item ./test_output/*.xml).FullName | Out-File $env:GITHUB_STEP_SUMMARY
}
}
}
}
finally
{
Pop-Location
}