Skip to content

Commit a1f8657

Browse files
authored
Move mobile test runners to libs.pretest instead of P2P (#36473)
1 parent 10c60fc commit a1f8657

File tree

7 files changed

+29
-16
lines changed

7 files changed

+29
-16
lines changed

eng/testing/tests.mobile.targets

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- OutDir is not set early enough to set this property in .props file. -->
44
<BundleDir>$([MSBuild]::NormalizeDirectory('$(OutDir)', 'AppBundle'))</BundleDir>
55
<RunScriptOutputPath>$([MSBuild]::NormalizePath('$(BundleDir)', '$(RunScriptOutputName)'))</RunScriptOutputPath>
6-
<RunAOTCompilation Condition="'$(TargetOS)' == 'iOS' and ('$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm')">true</RunAOTCompilation>
6+
<RunAOTCompilation Condition="'$(TargetOS)' == 'iOS' and $(TargetArchitecture.StartsWith('arm'))">true</RunAOTCompilation>
77
</PropertyGroup>
88

99
<!-- Generate a self-contained app bundle for Android with tests. -->
@@ -104,6 +104,16 @@
104104
<!-- This app is now can be consumed by xharness CLI to deploy on a device or simulator -->
105105
</Target>
106106

107+
<Target Name="AddTestRunnersToPublishedFiles"
108+
AfterTargets="ComputeFilesToPublish">
109+
<ItemGroup>
110+
<_runnerFilesToPublish Include="$(AndroidTestRunnerDir)*" Condition="'$(TargetOS)' == 'Android'" />
111+
<_runnerFilesToPublish Include="$(AppleTestRunnerDir)*" Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS'" />
112+
113+
<ResolvedFileToPublish Include="@(_runnerFilesToPublish)" RelativePath="%(FileName)%(Extension)" CopyToPublishDirectory="PreserveNewest" />
114+
</ItemGroup>
115+
</Target>
116+
107117
<Target Name="AddFrameworkReference">
108118
<ItemGroup>
109119
<FrameworkReference Include="$(SharedFrameworkName)" />

eng/testing/tests.props

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121
</PropertyGroup>
2222

2323
<PropertyGroup Condition="'$(TargetsMobile)' == 'true'">
24-
<MobileHelpersDirSuffix>$(NetCoreAppCurrent)-$(MonoConfiguration)</MobileHelpersDirSuffix>
25-
<AppleAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleAppBuilder', '$(MobileHelpersDirSuffix)'))</AppleAppBuilderDir>
26-
<AndroidAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidAppBuilder', '$(MobileHelpersDirSuffix)'))</AndroidAppBuilderDir>
27-
<MonoAOTCompilerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'MonoAOTCompiler', '$(MobileHelpersDirSuffix)'))</MonoAOTCompilerDir>
24+
<MobileHelperTasksDirSuffix>$(NetCoreAppCurrent)-$(MonoConfiguration)</MobileHelperTasksDirSuffix>
25+
<AppleAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleAppBuilder', '$(MobileHelperTasksDirSuffix)'))</AppleAppBuilderDir>
26+
<AndroidAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidAppBuilder', '$(MobileHelperTasksDirSuffix)'))</AndroidAppBuilderDir>
27+
<MonoAOTCompilerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'MonoAOTCompiler', '$(MobileHelperTasksDirSuffix)'))</MonoAOTCompilerDir>
28+
29+
<!-- Test runners are built as part of libs.pretest so we need to use libraries configuration -->
30+
<MobileRunnersDirSuffix>$(NetCoreAppCurrent)-$(Configuration)</MobileRunnersDirSuffix>
31+
<AppleTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleTestRunner', '$(MobileRunnersDirSuffix)'))</AppleTestRunnerDir>
32+
<AndroidTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(MobileRunnersDirSuffix)'))</AndroidTestRunnerDir>
2833

2934
<RuntimeIdentifier>$(PackageRID)</RuntimeIdentifier>
3035
<SelfContained>true</SelfContained>

src/libraries/Common/tests/AndroidTestRunner/AndroidTestRunner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ protected override void TerminateWithSuccess() {}
9292

9393
public string? Locale { get; }
9494

95+
#pragma warning disable CS8764
9596
public override TextWriter? Logger => null;
97+
#pragma warning restore CS8764
9698

9799
public override string TestsResultsFinalPath
98100
{

src/libraries/Common/tests/AndroidTestRunner/AndroidTestRunner.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<Nullable>enable</Nullable>
5-
<TargetFrameworks>$(NetCoreAppCurrent);$(NetFrameworkCurrent)</TargetFrameworks>
5+
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
66
</PropertyGroup>
7-
<!-- Since this is referenced by test projects that are restored for NetFrameworkCurrent, we need to suppor it for restored
8-
at runtime this is a no-op as tests can't run in NetFrameworkCurrent on Android so we will never build this for that tfm. -->
9-
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
7+
<ItemGroup>
108
<Compile Include="AndroidTestRunner.cs" />
119
<PackageReference Include="Microsoft.DotNet.XHarness.Tests.Runners" Version="$(MicrosoftDotNetXHarnessTestsRunnersVersion)" />
1210
</ItemGroup>

src/libraries/Common/tests/AppleTestRunner/AppleTestRunner.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<Nullable>enable</Nullable>
5-
<TargetFrameworks>$(NetCoreAppCurrent);$(NetFrameworkCurrent)</TargetFrameworks>
5+
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
66
</PropertyGroup>
7-
<!-- Since this is referenced by test projects that are restored for NetFrameworkCurrent, we need to suppor it for restored
8-
at runtime this is a no-op as tests can't run in NetFrameworkCurrent on iOS so we will never build this for that tfm. -->
9-
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
7+
<ItemGroup>
108
<Compile Include="AppleTestRunner.cs" />
119
<PackageReference Include="Microsoft.DotNet.XHarness.Tests.Runners" Version="$(MicrosoftDotNetXHarnessTestsRunnersVersion)" />
1210
</ItemGroup>

src/libraries/Directory.Build.props

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,6 @@
323323

324324
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
325325
<ProjectReference Include="$(CommonTestPath)TestUtilities\TestUtilities.csproj" />
326-
327-
<ProjectReference Include="$(CommonTestPath)AppleTestRunner\AppleTestRunner.csproj" Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS'" />
328-
<ProjectReference Include="$(CommonTestPath)AndroidTestRunner\AndroidTestRunner.csproj" Condition="'$(TargetOS)' == 'Android'" />
329326
</ItemGroup>
330327

331328
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">

src/libraries/pretest.proj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<ItemGroup>
1717
<RuntimeProject Include="restore\runtime\runtime.depproj" />
1818
<ProjectReference Include="@(RuntimeProject)" Condition="'$(MSBuildRestoreSessionId)' != ''" />
19+
20+
<ProjectReference Include="$(CommonTestPath)AppleTestRunner\AppleTestRunner.csproj" Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS'"/>
21+
<ProjectReference Include="$(CommonTestPath)AndroidTestRunner\AndroidTestRunner.csproj" Condition="'$(TargetOS)' == 'Android'" />
1922
</ItemGroup>
2023

2124
<Target Name="RestoreTestHost"

0 commit comments

Comments
 (0)