Skip to content

Commit

Permalink
[tests] Add/improve interdependent-binding-projects on .NET (#12429)
Browse files Browse the repository at this point in the history
* [tests] Share project logic in the .NET version of interdependent-binding-projects.

* [tests] Make interdependent-binding-projects work on macOS.
  • Loading branch information
rolfbjarne authored Aug 13, 2021
1 parent bd7e5c2 commit e0e7f0f
Show file tree
Hide file tree
Showing 17 changed files with 153 additions and 148 deletions.
18 changes: 17 additions & 1 deletion tests/common/mac/MacMain.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -12,7 +14,11 @@ static async Task<int> Main (string [] args)
var arguments = new List<string> (args);
arguments.RemoveAll ((arg) => arg.StartsWith ("-psn_", StringComparison.Ordinal));

var exit_code = await MonoTouch.NUnit.UI.MacRunner.MainAsync (arguments, true, _exit, typeof (MainClass).Assembly);
var assemblies = new List<Assembly> ();
assemblies.Add (typeof (MainClass).Assembly);
TestLoader.AddTestAssemblies (assemblies);

var exit_code = await MonoTouch.NUnit.UI.MacRunner.MainAsync (arguments, true, _exit, assemblies.ToArray ());

#if NET
var exit_monitor = new Thread (() =>
Expand All @@ -37,4 +43,14 @@ static async Task<int> Main (string [] args)
[DllImport ("/usr/lib/libSystem.dylib")]
static extern void _exit (int exit_code);
}

public static partial class TestLoader
{
static partial void AddTestAssembliesImpl (List<Assembly> assemblies);

public static void AddTestAssemblies (List<Assembly> assemblies)
{
AddTestAssembliesImpl (assemblies);
}
}
}
26 changes: 25 additions & 1 deletion tests/interdependent-binding-projects/Main.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
using System;
using System.Collections.Generic;
using System.Reflection;

using Foundation;
#if !__MACOS__
using UIKit;
#endif

using MonoTouch.NUnit.UI;
using NUnit.Framework;
using NUnit.Framework.Internal;

#if !__WATCHOS__
#if __MACOS__
namespace Xamarin.Mac.Tests {
public static partial class TestLoader {
static partial void AddTestAssembliesImpl (List<Assembly> assemblies)
{
assemblies.Add (typeof (Xamarin.BindingTests2.BindingTest).Assembly);
assemblies.Add (typeof (Xamarin.BindingTests.ProtocolTest).Assembly);
}
}
}
#elif !__WATCHOS__
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
Expand Down Expand Up @@ -48,3 +62,13 @@ static partial void AddTestAssembliesImpl (BaseTouchRunner runner)
}

#endif // !__WATCHOS__

// In some cases NUnit fails if asked to run tests from an assembly that doesn't have any tests. So add a dummy test here to not fail in that scenario.
[TestFixture]
public class DummyTest
{
public void TestMe ()
{
Assert.True (true, "YAY!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
<string>com.xamarin.dotnet.interdependentbindingprojects</string>
<key>CFBundleName</key>
<string>InterdependentBindingProject</string>
<key>MinimumOSVersion</key>
<string>7.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-maccatalyst</TargetFramework>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
<LangVersion>latest</LangVersion>
<RuntimeIdentifier>maccatalyst-x64</RuntimeIdentifier>
<AssetTargetFallback>xamarinios10;$(AssetTargetFallback)</AssetTargetFallback>
<RootTestsDirectory>..\..\..\</RootTestsDirectory>
<!-- This is needed because the packages/ directory might be in the same folder as this project file, and some some packages might have C# files, which would then automatically be included -->
<DefaultItemExcludes>$(DefaultItemExcludes);packages/**;</DefaultItemExcludes>
<AssemblyOriginatorKeyFile>$(RootTestsDirectory)\..\product.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
<!-- 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)\..\external\Touch.Unit\Touch.Client\dotnet\MacCatalyst\Touch.Client-MacCatalyst.dotnet.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\MacCatalyst\bindings-test.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test2\dotnet\MacCatalyst\bindings-test2.csproj" />
</ItemGroup>
<!-- Imports of the form '../shared.csproj' will be inlined by xharness -->
<Import Project="../shared.csproj" />

<ItemGroup>
<None Include="Info.plist" />
<Compile Include="$(RootTestsDirectory)\interdependent-binding-projects\Main.cs" />
<!-- this empty item group is here for xharness -->
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions tests/interdependent-binding-projects/dotnet/iOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-ios</TargetFramework>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
<LangVersion>latest</LangVersion>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<AssetTargetFallback>xamarinios10;$(AssetTargetFallback)</AssetTargetFallback>
<RootTestsDirectory>..\..\..\</RootTestsDirectory>
<!-- This is needed because the packages/ directory might be in the same folder as this project file, and some some packages might have C# files, which would then automatically be included -->
<DefaultItemExcludes>$(DefaultItemExcludes);packages/**;</DefaultItemExcludes>
<AssemblyOriginatorKeyFile>$(RootTestsDirectory)\..\product.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
<!-- 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)\..\external\Touch.Unit\Touch.Client\dotnet\iOS\Touch.Client-iOS.dotnet.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\iOS\bindings-test.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test2\dotnet\iOS\bindings-test2.csproj" />
</ItemGroup>
<!-- Imports of the form '../shared.csproj' will be inlined by xharness -->
<Import Project="../shared.csproj" />

<ItemGroup>
<None Include="Info.plist" />
<Compile Include="$(RootTestsDirectory)\interdependent-binding-projects\Main.cs" />
<!-- this empty item group is here for xharness -->
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleIdentifier</key>
<string>com.xamarin.dotnet.interdependentbindingprojects</string>
<key>CFBundleName</key>
<string>CFBundleIdentifier</string>
<string>InterdependentBindingProject</string>
<key>LSMinimumSystemVersion</key>
<string>10.14</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-macos</TargetFramework>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
<LangVersion>latest</LangVersion>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<RootTestsDirectory>..\..\..\</RootTestsDirectory>
<!-- This is needed because the packages/ directory might be in the same folder as this project file, and some some packages might have C# files, which would then automatically be included -->
<DefaultItemExcludes>$(DefaultItemExcludes);packages/**;</DefaultItemExcludes>
<AssemblyOriginatorKeyFile>$(RootTestsDirectory)\..\product.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\macOS\Touch.Client-macOS.dotnet.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\macOS\bindings-test.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test2\dotnet\macOS\bindings-test2.csproj" />
</ItemGroup>
<!-- Imports of the form '../shared.csproj' will be inlined by xharness -->
<Import Project="../shared.csproj" />

<ItemGroup>
<None Include="Info.plist" />
<Compile Include="$(RootTestsDirectory)\interdependent-binding-projects\Main.cs" />
<!-- this empty item group is here for xharness -->
</ItemGroup>
</Project>
39 changes: 39 additions & 0 deletions tests/interdependent-binding-projects/dotnet/shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<DefineConstants>$(DefineConstants);NET</DefineConstants>
<LangVersion>latest</LangVersion>
<RootNamespace>interdependentbindingprojects</RootNamespace>

<SignAssembly>true</SignAssembly>

<RootTestsDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..\..'))</RootTestsDirectory>
<TestLibrariesDirectory>$(RootTestsDirectory)\test-libraries</TestLibrariesDirectory>
<ThisTestDirectory>$(RootTestsDirectory)\interdependent-binding-projects</ThisTestDirectory>

<AssemblyOriginatorKeyFile>$(RootTestsDirectory)\..\product.snk</AssemblyOriginatorKeyFile>

<!-- Don't remove native symbols, because it makes debugging native crashes harder -->
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>

<DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);DEBUG</DefineConstants>
</PropertyGroup>

<Import Project="$(RootTestsDirectory)/common/shared-dotnet.csproj" />

<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)\bindings-test\dotnet\$(_PlatformName)\bindings-test.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test2\dotnet\$(_PlatformName)\bindings-test2.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(ThisTestDirectory)\Main.cs" />
<Compile Include="$(RootTestsDirectory)\common\mac\MacMain.cs" Condition="$(TargetFramework.EndsWith('-macos'))" Link="MacMain.cs" />
</ItemGroup>
</Project>
29 changes: 29 additions & 0 deletions tests/interdependent-binding-projects/dotnet/shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
TOP=../../../..
include $(TOP)/Make.config
include $(TOP)/mk/colors.mk

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

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

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

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

build: prepare
$(Q) $(DOTNET6) build /bl *.csproj $(MSBUILD_VERBOSITY) $(BUILD_ARGUMENTS)

run: prepare
$(Q) $(DOTNET6) build /bl *.csproj $(MSBUILD_VERBOSITY) $(BUILD_ARGUMENTS) -t:Run

diag: prepare
$(Q) $(DOTNET6) build /v:diag msbuild.binlog
1 change: 1 addition & 0 deletions tests/interdependent-binding-projects/dotnet/tvOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-tvos</TargetFramework>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
<LangVersion>latest</LangVersion>
<RuntimeIdentifier>tvossimulator-x64</RuntimeIdentifier>
<AssetTargetFallback>xamarintvos10;$(AssetTargetFallback)</AssetTargetFallback>
<RootTestsDirectory>..\..\..\</RootTestsDirectory>
<!-- This is needed because the packages/ directory might be in the same folder as this project file, and some some packages might have C# files, which would then automatically be included -->
<DefaultItemExcludes>$(DefaultItemExcludes);packages/**;</DefaultItemExcludes>
<AssemblyOriginatorKeyFile>$(RootTestsDirectory)\..\product.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
<!-- 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)\..\external\Touch.Unit\Touch.Client\dotnet\tvOS\Touch.Client-tvOS.dotnet.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\tvOS\bindings-test.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test2\dotnet\tvOS\bindings-test2.csproj" />
</ItemGroup>
<!-- Imports of the form '../shared.csproj' will be inlined by xharness -->
<Import Project="../shared.csproj" />

<ItemGroup>
<None Include="Info.plist" />
<Compile Include="$(RootTestsDirectory)\interdependent-binding-projects\Main.cs" />
<!-- this empty item group is here for xharness -->
</ItemGroup>
</Project>
35 changes: 0 additions & 35 deletions tests/interdependent-binding-projects/dotnet/watchOS/Info.plist

This file was deleted.

This file was deleted.

Loading

4 comments on commit e0e7f0f

@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 failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

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

Packages generated

View packages

Test results

4 tests failed, 237 tests passed.

Failed tests

  • xammac tests/Mac Modern/Debug (all optimizations): Failed (Test run failed.
    Tests run: 2469 Passed: 2408 Inconclusive: 13 Failed: 1 Ignored: 60)
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): Failed
  • monotouch-test/tvOS - simulator/Debug (static registrar) [dotnet]: Failed
  • Documentation/All: Failed

Pipeline on Agent XAMBOT-1036.BigSur'
[tests] Add/improve interdependent-binding-projects on .NET (#12429)

@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] Add/improve interdependent-binding-projects on .NET (#12429)

@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] Add/improve interdependent-binding-projects on .NET (#12429)

@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 on macOS M1 - Mac Big Sur (11.5) ❌

Tests failed on M1 - Mac Big Sur (11.5).

Failed tests are:

  • xammac_tests

Pipeline on Agent
[tests] Add/improve interdependent-binding-projects on .NET (#12429)

Please sign in to comment.