xamarin-android/tests/RunApkTests.targets

138 строки
6.3 KiB
XML

<?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 &quot;bin\Test$(Configuration)\TestOutput-%(_DeviceTestAssembly.Filename).txt&quot;</NUnitOutput>
<NUnitOutput Condition=" '$(HostOS)' == 'Windows' ">--output=&quot;bin\Test$(Configuration)\TestOutput-%(_DeviceTestAssembly.Filename).txt&quot;</NUnitOutput>
</NUnitTarget>
</ItemGroup>
<Exec
ContinueOnError="ErrorAndContinue"
Command="$(_NUnit) $(NUNIT_EXTRA) %(NUnitTarget.Identity) $(_Test) --labels=all --result=&quot;TestResult-%(NUnitTarget.TestFilename).xml;format=nunit2&quot; %(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>