forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunApkTests.targets
137 lines (125 loc) · 6.32 KB
/
RunApkTests.targets
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?xml version="1.0" encoding="UTF-8" ?>
<Project DefaultTargets="RunApkTests" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props'))" />
<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.SetEnvironmentVariable" />
<PropertyGroup>
<OutputPath>$(TestOutputDirectory)</OutputPath>
<_TopDir>$(MSBuildThisFileDirectory)..</_TopDir>
</PropertyGroup>
<Import Project="..\Configuration.props" />
<!--
Note that the `.csproj` for each `@(TestApk)` entry *must* be added to
`$(TEST_APK_PROJECTS)` and/or `$(TEST_APK_PROJECTS_RELEASE)`
in the toplevel Makefile so that the `.apk` is built.
The `<Import/>` should have `Condition=" '$(Configuration)' == 'Debug' "`
if the test should only be run in the Debug configuration. If it will be
built in Release configuration, *also* update
`$(TEST_APK_PROJECTS_RELEASE)` within the toplevel `Makefile`.
-->
<Import Project="..\samples\VSAndroidAppProxy.projitems" />
<Import Project="..\tests\BCL-Tests\Xamarin.Android.Bcl-Tests\Xamarin.Android.Bcl-Tests.projitems" Condition=" '$(AotAssemblies)' != 'True' " />
<Import Project="..\tests\CodeGen-Binding\Xamarin.Android.JcwGen-Tests\Xamarin.Android.JcwGen-Tests.projitems" Condition=" '$(AotAssemblies)' != 'True' " />
<Import Project="..\tests\EmbeddedDSOs\EmbeddedDSO\EmbeddedDSO.projitems" />
<Import Project="..\tests\locales\Xamarin.Android.Locale-Tests\Xamarin.Android.Locale-Tests.projitems" />
<Import Project="..\tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.projitems" />
<Import Project="..\build-tools\scripts\TestApks.targets" />
<ItemGroup Condition=" '$(ApkTests)' != '' ">
<_ApkTests Include="$(ApkTests)">
<Package>%(Identity)</Package>
</_ApkTests>
</ItemGroup>
<ItemGroup>
<_DeviceTestAssembly Include="$(_TopDir)\bin\Test$(Configuration)\MSBuildDeviceIntegration\net472\MSBuildDeviceIntegration.dll" />
</ItemGroup>
<PropertyGroup>
<RunNUnitDeviceTestsDependsOn>
AcquireAndroidTarget;
RunMSBuildDeviceIntegration;
ReleaseAndroidTarget;
</RunNUnitDeviceTestsDependsOn>
</PropertyGroup>
<Target Name="RunNUnitDeviceTests" DependsOnTargets="$(RunNUnitDeviceTestsDependsOn)"/>
<Target Name="RunMSBuildDeviceIntegration">
<ItemGroup>
<NUnitTarget Include="@(_DeviceTestAssembly)">
<TestFilename>%(_DeviceTestAssembly.Filename)</TestFilename>
<NUnitOutput Condition=" '$(HostOS)' != 'Windows' " >| tee "bin\Test$(Configuration)\TestOutput-%(_DeviceTestAssembly.Filename).txt"</NUnitOutput>
<NUnitOutput Condition=" '$(HostOS)' == 'Windows' ">--output="bin\Test$(Configuration)\TestOutput-%(_DeviceTestAssembly.Filename).txt"</NUnitOutput>
</NUnitTarget>
</ItemGroup>
<Exec
ContinueOnError="ErrorAndContinue"
Command="$(_NUnit) $(NUNIT_EXTRA) %(NUnitTarget.Identity) $(_Test) --labels=all --result="TestResult-%(NUnitTarget.TestFilename).xml;format=nunit2" %(NUnitTarget.NUnitOutput)"
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(_TopDir)"
/>
<ItemGroup>
<_RenameNUnitTestCasesGlob Include="@(NUnitTarget->'$(_TopDir)\TestResult-%(TestFilename).xml')" />
</ItemGroup>
<PropertyGroup>
<_RenamedTestCases>@(_RenameNUnitTestCasesGlob)</_RenamedTestCases>
</PropertyGroup>
<MSBuild
Condition=" '$(_RenamedTestCases)' != '' "
ContinueOnError="ErrorAndContinue"
Projects="..\build-tools\scripts\TestApks.targets"
Targets="RenameTestCases"
Properties="Configuration=$(Configuration);RenameTestCasesGlob=$(_RenamedTestCases)"
/>
</Target>
<PropertyGroup>
<RunApkTestsDependsOn>
FilterApkTests;
AcquireAndroidTarget;
UndeployTestApks;
DeployTestApks;
DeployTestAabs;
CheckAndRecordApkSizes;
RunTestApks;
ReleaseAndroidTarget;
RenameApkTestCases;
ReportComponentFailures;
</RunApkTestsDependsOn>
</PropertyGroup>
<Target Name="FilterApkTests">
<ItemGroup Condition=" '$(ApkTests)' != '' ">
<TestApk Remove="@(TestApk)" Condition=" '%(Package)' != '' And '@(_ApkTests)' == '' " />
</ItemGroup>
<ItemGroup Condition=" '$(ApkTests)' != '' ">
<TestApkInstrumentation Remove="@(TestApkInstrumentation)" Condition=" '%(Package)' != '' And '@(_ApkTests)' == '' " />
</ItemGroup>
<ItemGroup Condition=" '$(ApkTests)' != '' ">
<TestApkPermission Remove="@(TestApkPermission)" Condition=" '%(Package)' != '' And '@(_ApkTests)' == '' " />
</ItemGroup>
<Message Text="@(TestApk) " />
</Target>
<ItemGroup>
<_ApkPerfTests Include="Mono.Android_Tests;Xamarin.Android.Locale_Tests;Xamarin.Forms_Performance_Integration">
<Package>%(Identity)</Package>
</_ApkPerfTests>
</ItemGroup>
<Target Name="PrefilterPerformance">
<ItemGroup>
<_AllArchives Remove="@(_AllArchives)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' == '' " />
<TestApk Remove="@(TestApk)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' == '' " />
<TestApkInstrumentation Remove="@(TestApkInstrumentation)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' == '' " />
<TestApkPermission Remove="@(TestApkPermission)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' == '' " />
</ItemGroup>
<Message Text="Performance apk test: @(TestApk)" />
</Target>
<Target Name="PrefilterNonPerformance">
<ItemGroup>
<_AllArchives Remove="@(_AllArchives)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' != '' " />
<TestApk Remove="@(TestApk)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' != '' " />
<TestApkInstrumentation Remove="@(TestApkInstrumentation)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' != '' " />
<TestApkPermission Remove="@(TestApkPermission)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' != '' " />
</ItemGroup>
<Message Text="Non performance apk test: @(TestApk)" />
</Target>
<Target Name="RunApkTests"
DependsOnTargets="PrefilterNonPerformance;$(RunApkTestsDependsOn)">
</Target>
<Target Name="RunPerformanceApkTests"
DependsOnTargets="PrefilterPerformance;$(RunApkTestsDependsOn)">
</Target>
</Project>