Skip to content

Commit

Permalink
[tests/dotnet] Add .NET/Mac Catalyst test projects for dont link, lin…
Browse files Browse the repository at this point in the history
…k sdk and link all. (#12154)

* Add proper .NET project files for dont link, link sdk and link all. This
  includes a Mac Catalyst variant, and adding helpful Makefile targets for
  simple execution.

* Adjust various tests to work with Mac Catalyst.

* Add the new Mac Catalyst variants to xharness.

This is a partial fix for #10833.
  • Loading branch information
rolfbjarne authored Jul 21, 2021
2 parents fccd43f + 1bdf96d commit de7f08d
Show file tree
Hide file tree
Showing 35 changed files with 508 additions and 453 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

<PropertyGroup>
<RunCommand>open</RunCommand>
<RunArguments>$(TargetDir)/$(AssemblyName).app --args</RunArguments>
<RunArguments>"$(TargetDir)/$(AssemblyName).app" --args</RunArguments>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

<PropertyGroup>
<RunCommand>open</RunCommand>
<RunArguments>$(TargetDir)/$(AssemblyName).app --args</RunArguments>
<RunArguments>"$(TargetDir)/$(AssemblyName).app" --args</RunArguments>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions tests/dotnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ strip-dotnet:

# this target will copy NuGet.config and global.json to the directories that need it for their .NET build to work correctly.
copy-dotnet-config: $(TARGETS)
$(Q) for dir in $(shell ls -d $(abspath $(TOP)/tests/*/dotnet)); do \
$(CP) -c NuGet.config global.json $$dir; \
$(Q) for dir in $(abspath $(TOP))/tests/*/dotnet $(abspath $(TOP))/tests/linker/*/*/dotnet; do \
$(CP) -c NuGet.config global.json "$$dir"; \
done
$(Q) $(CP) -c NuGet.config global.json $(TOP)/external/Touch.Unit/Touch.Client/dotnet
12 changes: 12 additions & 0 deletions tests/linker/ios/dont link/dotnet/MacCatalyst/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"[]>
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>DontLinkTest</string>
<key>CFBundleIdentifier</key>
<string>com.xamarin.dontlink</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions tests/linker/ios/dont link/dotnet/MacCatalyst/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
15 changes: 15 additions & 0 deletions tests/linker/ios/dont link/dotnet/MacCatalyst/dont link.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-maccatalyst</TargetFramework>
<AssetTargetFallback>xamarinios10;$(AssetTargetFallback)</AssetTargetFallback>
<RootTestsDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\..\..\..'))</RootTestsDirectory> <!-- this can't be in shared.csproj, because xharness won't see it there -->
</PropertyGroup>

<ItemGroup>
<!-- this empty item group is here for xharness -->
</ItemGroup>

<Import Project="$(RootTestsDirectory)/linker/ios/dont link/dotnet/shared.csproj" />

</Project>
4 changes: 4 additions & 0 deletions tests/linker/ios/dont link/dotnet/iOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include ../shared.mk

dev:
$(DOTNET6) build /bl *.csproj $(MSBUILD_VERBOSITY) /p:RuntimeIdentifier=ios-arm64
49 changes: 3 additions & 46 deletions tests/linker/ios/dont link/dotnet/iOS/dont link.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-ios</TargetFramework>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
<DefineConstants>NET</DefineConstants>
<LangVersion>latest</LangVersion>
<RootNamespace>dontlink</RootNamespace>
<AssemblyName>dont link</AssemblyName>
<MtouchLink>None</MtouchLink>
<AssetTargetFallback>xamarinios10;$(AssetTargetFallback)</AssetTargetFallback>
<RootTestsDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\..\..\..'))</RootTestsDirectory> <!-- this can't be in shared.csproj, because xharness won't see it there -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
<ProjectReference Include="..\..\..\..\..\..\external\Touch.Unit\Touch.Client\dotnet\iOS\Touch.Client-iOS.dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />
<ProjectReference Include="..\..\..\..\..\BundledResources\dotnet\iOS\BundledResources.csproj" />
</ItemGroup>
<Import Project="$(RootTestsDirectory)/linker/ios/dont link/dotnet/shared.csproj" />

<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Main.cs" />
<Compile Include="..\..\AppDelegate.cs" />
<Compile Include="..\..\DontLinkRegressionTests.cs" />
<Compile Include="..\..\TableViewSourceTest.cs" />
<Compile Include="..\..\CalendarTest.cs" />
<Compile Include="..\..\..\..\CommonDontLinkTest.cs">
<Link>CommonDontLinkTest.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="..\..\LaunchScreen.storyboard" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\Contents.json" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\Icon-app-60%403x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-57.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-57%402x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-60%402x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-72.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-72%402x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-76.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-76%402x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-83.5%402x.png" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\BoardingPass.pkpass">
<Link>BoardingPass.pkpass</Link>
</Content>
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
</ItemGroup>
</Project>
54 changes: 54 additions & 0 deletions tests/linker/ios/dont link/dotnet/shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<DefineConstants>NET;$(DefineConstants)</DefineConstants>
<LangVersion>latest</LangVersion>
<RootNamespace>dontlink</RootNamespace>
<AssemblyName>dont link</AssemblyName>
<MtouchLink>None</MtouchLink>
<ThisTestDirectory>$(RootTestsDirectory)\linker\ios\dont link</ThisTestDirectory>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />
<ProjectReference Include="$(RootTestsDirectory)\BundledResources\dotnet\$(_PlatformName)\BundledResources.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(ThisTestDirectory)\Main.cs" />
<Compile Include="$(ThisTestDirectory)\AppDelegate.cs" />
<Compile Include="$(ThisTestDirectory)\DontLinkRegressionTests.cs" />
<Compile Include="$(ThisTestDirectory)\TableViewSourceTest.cs" />
<Compile Include="$(ThisTestDirectory)\CalendarTest.cs" />
<Compile Include="$(ThisTestDirectory)\..\..\CommonDontLinkTest.cs">
<Link>CommonDontLinkTest.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="$(ThisTestDirectory)\LaunchScreen.storyboard" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\Contents.json" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\Icon-app-60%403x.png" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\icon-app-57.png" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\icon-app-57%402x.png" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\icon-app-60%402x.png" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\icon-app-72.png" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\icon-app-72%402x.png" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\icon-app-76.png" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\icon-app-76%402x.png" />
<ImageAsset Include="$(ThisTestDirectory)\Assets.xcassets\AppIcons.appiconset\icon-app-83.5%402x.png" />
</ItemGroup>
<ItemGroup>
<Content Include="$(ThisTestDirectory)\BoardingPass.pkpass">
<Link>BoardingPass.pkpass</Link>
</Content>
</ItemGroup>
</Project>
30 changes: 30 additions & 0 deletions tests/linker/ios/dont link/dotnet/shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
TOP=../../../../../..

include $(TOP)/Make.config
include $(TOP)/mk/colors.mk

reload:
$(Q) rm -Rf $(TOP)/tests/dotnet/packages
$(Q) $(MAKE) -C $(TOP) -j8 all
$(Q) $(MAKE) -C $(TOP) -j8 install
$(Q) git clean -xfdq

prepare:
$(Q) $(MAKE) -C $(TOP)/tests/dotnet copy-dotnet-config

reload-and-build:
$(Q) $(MAKE) reload
$(Q) $(MAKE) build

reload-and-run:
$(Q) $(MAKE) reload
$(Q) $(MAKE) run

build: prepare
$(DOTNET6) build /bl:$@.binlog *.csproj $(MSBUILD_VERBOSITY)

run: prepare
$(DOTNET6) build /bl:$@.binlog *.csproj /v:diag -t:Run

diag:
$(DOTNET6) build /v:diag msbuild.binlog
1 change: 1 addition & 0 deletions tests/linker/ios/dont link/dotnet/tvOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
49 changes: 3 additions & 46 deletions tests/linker/ios/dont link/dotnet/tvOS/dont link.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-tvos</TargetFramework>
<RuntimeIdentifier>tvossimulator-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
<DefineConstants>NET</DefineConstants>
<LangVersion>latest</LangVersion>
<RootNamespace>dontlink</RootNamespace>
<AssemblyName>dont link</AssemblyName>
<MtouchLink>None</MtouchLink>
<AssetTargetFallback>xamarintvos10;$(AssetTargetFallback)</AssetTargetFallback>
<RootTestsDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\..\..\..'))</RootTestsDirectory> <!-- this can't be in shared.csproj, because xharness won't see it there -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
<ProjectReference Include="..\..\..\..\..\..\external\Touch.Unit\Touch.Client\dotnet\tvOS\Touch.Client-tvOS.dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />
<ProjectReference Include="..\..\..\..\..\BundledResources\dotnet\tvOS\BundledResources.csproj" />
</ItemGroup>
<Import Project="$(RootTestsDirectory)/linker/ios/dont link/dotnet/shared.csproj" />

<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Main.cs" />
<Compile Include="..\..\AppDelegate.cs" />
<Compile Include="..\..\DontLinkRegressionTests.cs" />
<Compile Include="..\..\TableViewSourceTest.cs" />
<Compile Include="..\..\CalendarTest.cs" />
<Compile Include="..\..\..\..\CommonDontLinkTest.cs">
<Link>CommonDontLinkTest.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="..\..\LaunchScreen.storyboard" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\Contents.json" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\Icon-app-60%403x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-57.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-57%402x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-60%402x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-72.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-72%402x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-76.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-76%402x.png" />
<ImageAsset Include="..\..\Assets.xcassets\AppIcons.appiconset\icon-app-83.5%402x.png" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\BoardingPass.pkpass">
<Link>BoardingPass.pkpass</Link>
</Content>
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions tests/linker/ios/link all/LinkAllTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public void UnusedMethod () {}
// we want the tests to be available because we use the linker
[Preserve (AllMembers = true)]
public class LinkAllRegressionTest {
#if __IOS__
#if __MACCATALYST__
public const string NamespacePrefix = "";
public const string AssemblyName = "Xamarin.MacCatalyst";
#elif __IOS__
public const string NamespacePrefix = "";
public const string AssemblyName = "Xamarin.iOS";
#elif __TVOS__
Expand Down Expand Up @@ -211,7 +214,8 @@ public void DetectPlatform ()
{
#if !__WATCHOS__
// for (future) nunit[lite] platform detection - if this test fails then platform detection won't work
Assert.NotNull (Helper.GetType (NamespacePrefix + "UIKit.UIApplicationDelegate, " + AssemblyName), "UIApplicationDelegate");
var typename = NamespacePrefix + "UIKit.UIApplicationDelegate, " + AssemblyName;
Assert.NotNull (Helper.GetType (typename), typename);
#endif
#if NET
Assert.Null (Helper.GetType ("Mono.Runtime"), "Mono.Runtime");
Expand Down
12 changes: 12 additions & 0 deletions tests/linker/ios/link all/dotnet/MacCatalyst/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"[]>
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>LinkAll</string>
<key>CFBundleIdentifier</key>
<string>com.xamarin.linkall</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions tests/linker/ios/link all/dotnet/MacCatalyst/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
14 changes: 14 additions & 0 deletions tests/linker/ios/link all/dotnet/MacCatalyst/link all.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-maccatalyst</TargetFramework>
<AssetTargetFallback>xamarinios10;$(AssetTargetFallback)</AssetTargetFallback>
<RootTestsDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\..\..\..'))</RootTestsDirectory> <!-- this can't be in shared.csproj, because xharness won't see it there -->
</PropertyGroup>

<ItemGroup>
<!-- this empty item group is here for xharness -->
</ItemGroup>

<Import Project="$(RootTestsDirectory)/linker/ios/link all/dotnet/shared.csproj" />
</Project>
4 changes: 4 additions & 0 deletions tests/linker/ios/link all/dotnet/iOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include ../shared.mk

dev:
$(DOTNET6) build /bl *.csproj $(MSBUILD_VERBOSITY) /p:RuntimeIdentifier=ios-arm64
Loading

7 comments on commit de7f08d

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ [CI Build] Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (no change)

Packages generated

View packages

🎉 All 224 tests passed 🎉

Pipeline on Agent XAMBOT-1033.BigSur'
[tests/dotnet] Add .NET/Mac Catalyst test projects for dont link, link sdk and link all. (#12154)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Tests failed catastrophically on VSTS: device tests tvOS 🔥

Not enough free space in the host.

Pipeline on Agent
[tests/dotnet] Add .NET/Mac Catalyst test projects for dont link, link sdk and link all. (#12154)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[tests/dotnet] Add .NET/Mac Catalyst test projects for dont link, link sdk and link all. (#12154)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[tests/dotnet] Add .NET/Mac Catalyst test projects for dont link, link sdk and link all. (#12154)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ Tests passed on macOS Mac Catalina (10.15) ✅

Tests passed

All tests on macOS X Mac Catalina (10.15) passed.

Pipeline on Agent
[tests/dotnet] Add .NET/Mac Catalyst test projects for dont link, link sdk and link all. (#12154)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ Tests passed on macOS Mac Mojave (10.14) ✅

Tests passed

All tests on macOS X Mac Mojave (10.14) passed.

Pipeline on Agent
[tests/dotnet] Add .NET/Mac Catalyst test projects for dont link, link sdk and link all. (#12154)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ Tests passed on macOS Mac High Sierra (10.13) ✅

Tests passed

All tests on macOS X Mac High Sierra (10.13) passed.

Pipeline on Agent
[tests/dotnet] Add .NET/Mac Catalyst test projects for dont link, link sdk and link all. (#12154)

Please sign in to comment.