Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/testing/AndroidRunnerTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ EXECUTION_DIR=$(dirname $0)
TEST_NAME=$1
TARGET_ARCH=$2

APK=$EXECUTION_DIR/Bundle/bin/$TEST_NAME.apk
APK=$EXECUTION_DIR/bin/$TEST_NAME.apk

# it doesn't support parallel execution yet, so, here is a hand-made semaphore:
LOCKDIR=/tmp/androidtests.lock
Expand All @@ -20,4 +20,4 @@ done

dotnet xharness android test -i="net.dot.MonoRunner" \
--package-name="net.dot.$TEST_NAME" \
--app=$APK -o=$EXECUTION_DIR/Bundle/TestResults -v
--app=$APK -o=$EXECUTION_DIR/TestResults -v
4 changes: 2 additions & 2 deletions eng/testing/AppleRunnerTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi

# "Release" in SCHEME_SDK is what xcode produces (see "bool Optimized" property in AppleAppBuilderTask)

APP_BUNDLE=$EXECUTION_DIR/Bundle/$TEST_NAME/$SCHEME_SDK/$TEST_NAME.app
APP_BUNDLE=$EXECUTION_DIR/$TEST_NAME/$SCHEME_SDK/$TEST_NAME.app

# it doesn't support parallel execution yet, so, here is a hand-made semaphore:
LOCKDIR=/tmp/runonsim.lock
Expand All @@ -39,7 +39,7 @@ while true; do
fi
done

XHARNESS_OUT="$EXECUTION_DIR/Bundle/xharness-output"
XHARNESS_OUT="$EXECUTION_DIR/xharness-output"

dotnet xharness ios test --app="$APP_BUNDLE" \
--targets=$TARGET \
Expand Down
114 changes: 114 additions & 0 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<Project>
<PropertyGroup>
<!-- OutDir is not set early enough to set this property in .props file. -->
<BundleDir>$([MSBuild]::NormalizeDirectory('$(OutDir)', 'AppBundle'))</BundleDir>
<RunScriptOutputPath>$([MSBuild]::NormalizePath('$(BundleDir)', '$(RunScriptOutputName)'))</RunScriptOutputPath>
</PropertyGroup>

<!-- Generate a self-contained app bundle for Android with tests. -->
<UsingTask TaskName="AndroidAppBuilderTask"
AssemblyFile="$(AndroidAppBuilderDir)AndroidAppBuilder.dll" />
<Target Condition="'$(TargetOS)' == 'Android'" Name="BundleTestAndroidApp">
<PropertyGroup>
<AndroidAbi Condition="'$(TargetArchitecture)'=='arm64'">arm64-v8a</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)'=='arm'">armeabi</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)'=='x64'">x86_64</AndroidAbi>
<AndroidAbi Condition="'$(AndroidAbi)'==''">$(TargetArchitecture)</AndroidAbi>
</PropertyGroup>
<ItemGroup>
<AndroidTestRunnerBinaries Include="$(AndroidTestRunnerDir)*.*" />
</ItemGroup>

<Error Condition="'@(AndroidTestRunnerBinaries)' == ''" Text="Could not find AndroidTestRunner in $(AndroidTestRunnerDir)" />
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />

<RemoveDir Directories="$(BundleDir)" />
<Copy SourceFiles="@(AndroidTestRunnerBinaries)" DestinationFolder="$(OutDir)%(RecursiveDir)" SkipUnchangedFiles="true"/>

<!-- TEMP: consume OpenSSL binaries from external sources via env. variables -->
<Copy Condition="'$(AndroidOpenSslCryptoLib)' != ''"
SourceFiles="$(AndroidOpenSslCryptoLib)"
DestinationFolder="$(OutDir)" SkipUnchangedFiles="true"/>
<Copy Condition="'$(AndroidOpenSslLib)' != ''"
SourceFiles="$(AndroidOpenSslLib)"
DestinationFolder="$(OutDir)" SkipUnchangedFiles="true"/>

<WriteLinesToFile File="$(OutDir)xunit-excludes.txt" Lines="$(_withoutCategories.Replace(';', '%0dcategory='))" />

<AndroidAppBuilderTask
Abi="$(AndroidAbi)"
ProjectName="$(AssemblyName)"
MonoRuntimeHeaders="$(RuntimePackNativeDir)\include\mono-2.0"
MainLibraryFileName="AndroidTestRunner.dll"
OutputDir="$(BundleDir)"
SourceDir="$(OutDir)">
<Output TaskParameter="ApkPackageId" PropertyName="ApkPackageId" />
<Output TaskParameter="ApkBundlePath" PropertyName="ApkBundlePath" />
</AndroidAppBuilderTask>
<Message Importance="High" Text="PackageId: $(ApkPackageId)"/>
<Message Importance="High" Text="Instrumentation: net.dot.MonoRunner"/>
<Message Importance="High" Text="Apk: $(ApkBundlePath)"/>
</Target>

<!-- Generate a self-contained app bundle for iOS with tests. -->
<UsingTask TaskName="AppleAppBuilderTask"
AssemblyFile="$(AppleAppBuilderDir)AppleAppBuilder.dll" />
<Target Condition="'$(TargetOS)' == 'iOS'" Name="BundleTestAppleApp">
<ItemGroup>
<AppleTestRunnerBinaries Include="$(AppleTestRunnerDir)*.*" />
</ItemGroup>

<Error Condition="'@(AppleTestRunnerBinaries)' == ''" Text="Could not find AppleTestRunner in $(AppleTestRunnerDir) doesn't exist" />
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />

<RemoveDir Directories="$(BundleDir)" />
<Copy SourceFiles="@(AppleTestRunnerBinaries)" DestinationFolder="$(OutDir)%(RecursiveDir)" SkipUnchangedFiles="true"/>

<WriteLinesToFile File="$(OutDir)xunit-excludes.txt" Lines="$(_withoutCategories.Replace(';', '%0dcategory='))" />
<!-- Run App bundler, it should AOT libs (if needed), link all native bits, compile simple UI (written in ObjC)
and produce an app bundle (with xcode project) -->
<AppleAppBuilderTask
Arch="$(TargetArchitecture)"
ProjectName="$(AssemblyName)"
MonoRuntimeHeaders="$(RuntimePackNativeDir)\include\mono-2.0"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akoeplinger you said you were going to clean these \ up in a follow up PR since you're touching files, but since I'm touching them here, do you want me to do it instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get this in and I'll do the cleanup, I will need to touch this whole file anyway.

CrossCompiler="$(RuntimePackNativeDir)\cross\mono-aot-cross"
MainLibraryFileName="AppleTestRunner.dll"
UseConsoleUITemplate="True"
GenerateXcodeProject="True"
BuildAppBundle="True"
Optimized="True"
UseLlvm="$(MonoEnableLLVM)"
LlvmPath="$(RuntimePackNativeDir)\cross"
DevTeamProvisioning="$(DevTeamProvisioning)"
OutputDirectory="$(BundleDir)"
AppDir="$(OutDir)">
<Output TaskParameter="AppBundlePath" PropertyName="AppBundlePath" />
<Output TaskParameter="XcodeProjectPath" PropertyName="XcodeProjectPath" />
</AppleAppBuilderTask>
<Message Importance="High" Text="Xcode: $(XcodeProjectPath)"/>
<Message Importance="High" Text="App: $(AppBundlePath)"/>
<Error Condition="$(TargetArchitecture.StartsWith('arm')) and '$(DevTeamProvisioning)' == ''"
Text="'DevTeamProvisioning' shouldn't be empty for arm64" />
<!-- This app is now can be consumed by xharness CLI to deploy on a device or simulator -->
</Target>

<Target Name="AddFrameworkReference">
<ItemGroup>
<FrameworkReference Include="$(SharedFrameworkName)" />
</ItemGroup>
</Target>

<Target Name="UpdateRuntimePack"
Condition="'$(IsCrossTargetingBuild)' != 'true'"
AfterTargets="BeforeBuild"
DependsOnTargets="AddFrameworkReference;ResolveFrameworkReferences">
<ItemGroup>
<ResolvedRuntimePack Update="@(ResolvedRuntimePack)" PackageDirectory="$(RuntimePackDir)" />
</ItemGroup>
</Target>

<Target Name="PublishTestAsSelfContained"
Condition="'$(IsCrossTargetingBuild)' != 'true'"
AfterTargets="PrepareForRun"
DependsOnTargets="BundleTestAppleApp;BundleTestAndroidApp" />
</Project>
7 changes: 6 additions & 1 deletion eng/testing/tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
<_withoutCategories Condition="!$(_withCategories.Contains('failing'))">$(_withoutCategories);failing</_withoutCategories>
</PropertyGroup>

<PropertyGroup>
<PropertyGroup Condition="'$(TargetsMobile)' == 'true'">
<MobileHelpersDirSuffix>$(NetCoreAppCurrent)-$(MonoConfiguration)</MobileHelpersDirSuffix>
<AppleAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleAppBuilder', '$(MobileHelpersDirSuffix)'))</AppleAppBuilderDir>
<AppleTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleTestRunner', '$(MobileHelpersDirSuffix)'))</AppleTestRunnerDir>
<AndroidAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidAppBuilder', '$(MobileHelpersDirSuffix)'))</AndroidAppBuilderDir>
<AndroidTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(MobileHelpersDirSuffix)'))</AndroidTestRunnerDir>

<RuntimeIdentifier>$(PackageRID)</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
<PlatformManifestFile />
</PropertyGroup>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it too early to enable PublishTrimmed here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I did try that in my branch and you'll need to disable trimming on corelib or it crashes at startup. Let's do that in a separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not disable it but fix it instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah of course, but still in another PR :)


<!--
Expand Down
117 changes: 1 addition & 116 deletions eng/testing/tests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -101,122 +101,7 @@
<Error Condition="'$(TestRunExitCode)' != '0'" Text="$(TestRunErrorMessage)" />
</Target>

<!-- Generate a self-contained app bundle for Android with tests.
This target is executed once build is done for a test lib (after CopyFilesToOutputDirectory target) -->
<UsingTask TaskName="AndroidAppBuilderTask"
AssemblyFile="$(AndroidAppBuilderDir)AndroidAppBuilder.dll" />
<Target Condition="'$(TargetOS)' == 'Android'" Name="BundleTestAndroidApp" AfterTargets="CopyFilesToOutputDirectory">
<PropertyGroup>
<BundleDir>$(OutDir)\Bundle</BundleDir>
<AndroidAbi Condition="'$(TargetArchitecture)'=='arm64'">arm64-v8a</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)'=='arm'">armeabi</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)'=='x64'">x86_64</AndroidAbi>
<AndroidAbi Condition="'$(AndroidAbi)'==''">$(TargetArchitecture)</AndroidAbi>
</PropertyGroup>
<!-- TEMP: We need to copy additional stuff into $(OutDir)\Bundle
1) The whole BCL
2) Test Runner (with xharness client-side lib)
-->
<ItemGroup>
<TestBinaries Include="$(OutDir)\*.*"/>
<AndroidTestRunnerBinaries Include="$(AndroidTestRunnerDir)*.*" />
<BclBinaries Include="$(RuntimePackLibDir)\*.*"
Exclude="$(RuntimePackLibDir)\System.Runtime.WindowsRuntime.dll" />
<BclBinaries Include="$(RuntimePackNativeDir)\*.*" Exclude="$(RuntimePackNativeDir)\libmono.dylib" />

<!-- remove PDBs and DBGs to save some space until we integrate ILLink -->
<BclBinaries Remove="$(RuntimePackLibDir)\*.pdb" />
<BclBinaries Remove="$(RuntimePackLibDir)\*.dbg" />
</ItemGroup>

<Error Condition="'@(AndroidTestRunnerBinaries)' == ''" Text="Could not find AndroidTestRunner in $(AndroidTestRunnerDir)" />
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />
<RemoveDir Directories="$(BundleDir)" />
<Copy SourceFiles="@(TestBinaries)" DestinationFolder="$(BundleDir)" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(AndroidTestRunnerBinaries)" DestinationFolder="$(BundleDir)\%(RecursiveDir)" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(BclBinaries)" DestinationFolder="$(BundleDir)\%(RecursiveDir)" SkipUnchangedFiles="true"/>

<!-- TEMP: consume OpenSSL binaries from external sources via env. variables -->
<Copy Condition="'$(AndroidOpenSslCryptoLib)' != ''"
SourceFiles="$(AndroidOpenSslCryptoLib)"
DestinationFolder="$(BundleDir)" SkipUnchangedFiles="true"/>
<Copy Condition="'$(AndroidOpenSslLib)' != ''"
SourceFiles="$(AndroidOpenSslLib)"
DestinationFolder="$(BundleDir)" SkipUnchangedFiles="true"/>

<WriteLinesToFile File="$(BundleDir)\xunit-excludes.txt" Lines="$(_withoutCategories.Replace(';', '%0dcategory='))" />

<AndroidAppBuilderTask
Abi="$(AndroidAbi)"
ProjectName="$(AssemblyName)"
MonoRuntimeHeaders="$(RuntimePackNativeDir)\include\mono-2.0"
MainLibraryFileName="AndroidTestRunner.dll"
OutputDir="$(BundleDir)"
SourceDir="$(BundleDir)">
<Output TaskParameter="ApkPackageId" PropertyName="ApkPackageId" />
<Output TaskParameter="ApkBundlePath" PropertyName="ApkBundlePath" />
</AndroidAppBuilderTask>
<Message Importance="High" Text="PackageId: $(ApkPackageId)"/>
<Message Importance="High" Text="Instrumentation: net.dot.MonoRunner"/>
<Message Importance="High" Text="Apk: $(ApkBundlePath)"/>
</Target>

<!-- Generate a self-contained app bundle for iOS with tests.
This target is executed once build is done for a test lib (after CopyFilesToOutputDirectory target) -->
<UsingTask TaskName="AppleAppBuilderTask"
AssemblyFile="$(AppleAppBuilderDir)AppleAppBuilder.dll" />
<Target Condition="'$(TargetOS)' == 'iOS'" Name="BundleTestAppleApp" AfterTargets="CopyFilesToOutputDirectory">
<PropertyGroup>
<BundleDir>$(OutDir)\Bundle</BundleDir>
</PropertyGroup>
<!-- We need to copy additional stuff into $(OutDir)\Bundle
1) The whole BCL
2) Test Runner (with xharness client-side lib)
-->
<ItemGroup>
<TestBinaries Include="$(OutDir)*.*"/>
<AppleTestRunnerBinaries Include="$(AppleTestRunnerDir)*.*" />
<BclBinaries Include="$(RuntimePackLibDir)*.*" Exclude="$(RuntimePackLibDir)\System.Runtime.WindowsRuntime.dll" />
<BclBinaries Include="$(RuntimePackNativeDir)*.*" Exclude="$(RuntimePackNativeDir)\libmono.dylib" /> <!-- we use static libmono.a -->

<!-- remove PDBs to save some space until we integrate ILLink -->
<BclBinaries Remove="$(RuntimePackLibDir)\*.pdb" />
</ItemGroup>
<Error Condition="'@(AppleTestRunnerBinaries)' == ''" Text="Could not find AppleTestRunner in $(AppleTestRunnerDir) doesn't exist" />
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />
<RemoveDir Directories="$(BundleDir)" />
<Copy SourceFiles="@(TestBinaries)" DestinationFolder="$(BundleDir)" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(AppleTestRunnerBinaries)" DestinationFolder="$(BundleDir)\%(RecursiveDir)" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(BclBinaries)" DestinationFolder="$(BundleDir)\%(RecursiveDir)" SkipUnchangedFiles="true"/>

<WriteLinesToFile File="$(BundleDir)\xunit-excludes.txt" Lines="$(_withoutCategories.Replace(';', '%0dcategory='))" />
<!-- Run App bundler, it should AOT libs (if needed), link all native bits, compile simple UI (written in ObjC)
and produce an app bundle (with xcode project) -->
<AppleAppBuilderTask
Arch="$(TargetArchitecture)"
ProjectName="$(AssemblyName)"
MonoRuntimeHeaders="$(RuntimePackNativeDir)\include\mono-2.0"
CrossCompiler="$(RuntimePackNativeDir)\cross\mono-aot-cross"
MainLibraryFileName="AppleTestRunner.dll"
UseConsoleUITemplate="True"
GenerateXcodeProject="True"
BuildAppBundle="True"
Optimized="True"
UseLlvm="$(MonoEnableLLVM)"
LlvmPath="$(RuntimePackNativeDir)\cross"
DevTeamProvisioning="$(DevTeamProvisioning)"
OutputDirectory="$(BundleDir)"
AppDir="$(BundleDir)">
<Output TaskParameter="AppBundlePath" PropertyName="AppBundlePath" />
<Output TaskParameter="XcodeProjectPath" PropertyName="XcodeProjectPath" />
</AppleAppBuilderTask>
<Message Importance="High" Text="Xcode: $(XcodeProjectPath)"/>
<Message Importance="High" Text="App: $(AppBundlePath)"/>
<Error Condition="$(TargetArchitecture.StartsWith('arm')) and '$(DevTeamProvisioning)' == ''"
Text="'DevTeamProvisioning' shouldn't be empty for arm64" />
<!-- This app is now can be consumed by xharness CLI to deploy on a device or simulator -->
</Target>

<Import Project="$(MSBuildThisFileDirectory)tests.mobile.targets" Condition="'$(TargetsMobile)' == 'true'" />
<Import Project="$(MSBuildThisFileDirectory)xunit\xunit.targets" Condition="'$(TestFramework)' == 'xunit'" />

<!-- Main test targets -->
Expand Down