diff --git a/tests/.gitignore b/tests/.gitignore
index c2ba73828914..62f9bd88c725 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -18,6 +18,13 @@ build
*-unifiedXM45.sln
*-unified-32.sln
*-unifiedXM45-32.sln
+*-mac.?sproj
+*-mac-32.?sproj
+*-macXM45.?sproj
+*-macXM45-32.?sproj
+*-macXM45.sln
+*-mac-32.sln
+*-macXM45-32.sln
*-today.?sproj
*-today-extension.?sproj
*-today.sln
diff --git a/tests/mono-native/.gitignore b/tests/mono-native/.gitignore
index a1f447a8043b..3276b07be9d6 100644
--- a/tests/mono-native/.gitignore
+++ b/tests/mono-native/.gitignore
@@ -1 +1,5 @@
mono-native-compat.csproj
+*-full.?sproj
+*-full-32.?sproj
+*-modern.?sproj
+*-modern-32.?sproj
diff --git a/tests/mono-native/Entitlements-mac.plist b/tests/mono-native/Entitlements-mac.plist
new file mode 100644
index 000000000000..9ae599370b42
--- /dev/null
+++ b/tests/mono-native/Entitlements-mac.plist
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/mono-native/Info-mac.plist b/tests/mono-native/Info-mac.plist
new file mode 100644
index 000000000000..087768976449
--- /dev/null
+++ b/tests/mono-native/Info-mac.plist
@@ -0,0 +1,30 @@
+
+
+
+
+ CFBundleName
+ mononativetests
+ CFBundleIdentifier
+ com.xamarin.mononativetests
+ CFBundleShortVersionString
+ 1.0
+ CFBundleVersion
+ 1
+ LSMinimumSystemVersion
+ 10.10
+ CFBundleDevelopmentRegion
+ en
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundlePackageType
+ APPL
+ CFBundleSignature
+ ????
+ NSHumanReadableCopyright
+ Xamarin Inc. (http://www.xamarin.com)
+ NSPrincipalClass
+ NSApplication
+ NSMainStoryboardFile
+ Main
+
+
diff --git a/tests/mono-native/MacAppDelegate.cs b/tests/mono-native/MacAppDelegate.cs
new file mode 100644
index 000000000000..eb2742288919
--- /dev/null
+++ b/tests/mono-native/MacAppDelegate.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using NUnitLite;
+using AppKit;
+using Foundation;
+
+namespace Mono.Native.Tests
+{
+ [Register ("AppDelegate")]
+ public class MacAppDelegate : NSApplicationDelegate
+ {
+ public override void DidFinishLaunching (NSNotification notification)
+ {
+ }
+
+ public override void WillTerminate (NSNotification notification)
+ {
+ // Insert code here to tear down your application
+ }
+ }
+}
diff --git a/tests/mono-native/MacMain.cs b/tests/mono-native/MacMain.cs
new file mode 100644
index 000000000000..9fa02d1ce7e8
--- /dev/null
+++ b/tests/mono-native/MacMain.cs
@@ -0,0 +1,12 @@
+using NUnitLite;
+
+namespace mononativetests
+{
+ public class Application
+ {
+ static int Main (string[] args)
+ {
+ return new AutoRun ().Execute (args);
+ }
+ }
+}
diff --git a/tests/mono-native/mono-native-mac.csproj.template b/tests/mono-native/mono-native-mac.csproj.template
new file mode 100644
index 000000000000..65803758067d
--- /dev/null
+++ b/tests/mono-native/mono-native-mac.csproj.template
@@ -0,0 +1,63 @@
+
+
+
+ Debug
+ AnyCPU
+ {2B174B45-CC6B-443D-870F-6B5394FDE3FD}
+ {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Exe
+ Mono.Native.Tests
+ mononativetests
+ Resources
+ 67,168,169,219,414,612,618,649,672
+ v4.7.1
+ true
+
+
+ false
+ bin\Mac
+ 4
+ false
+ false
+ false
+ false
+ false
+ HttpClientHandler
+ None
+ None
+
+
+
+
+
+
+
+
+
+
+
+
+ MacTestMain.cs
+
+
+ Assert.cs
+
+
+
+ MonoNativePlatform.cs
+
+
+ MonoNativePlatformType.cs
+
+
+ NativePlatformTest.cs
+
+
+
+
+ {D12F0F7B-8DE3-43EC-BA49-41052D065A9B}
+ GuiUnit_NET_4_5
+
+
+
+
\ No newline at end of file
diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs
index f666ccfdc107..3d686ff1cfff 100644
--- a/tests/xharness/Harness.cs
+++ b/tests/xharness/Harness.cs
@@ -290,6 +290,19 @@ void AutoConfigureMac ()
MacTestProjects.Add (bclTestProject);
}
}
+
+ foreach (var flavor in new MonoNativeFlavor[] { MonoNativeFlavor.Compat, MonoNativeFlavor.Unified }) {
+ foreach (var macFlavor in new MacFlavors[] { MacFlavors.Full, MacFlavors.Modern }) {
+ var monoNativeInfo = new MacMonoNativeInfo (this, flavor, macFlavor);
+ var macTestProject = new MacTestProject (monoNativeInfo.ProjectPath, targetFrameworkFlavor: macFlavor, generateVariations: true) {
+ MonoNativeInfo = monoNativeInfo,
+ Name = monoNativeInfo.ProjectName,
+ Platform = "AnyCPU"
+ };
+
+ MacTestProjects.Add (macTestProject);
+ }
+ }
}
void AutoConfigureIOS ()
@@ -440,22 +453,28 @@ void ConfigureMac ()
foreach (var bclTestInfo in MacTestProjects.Where (x => x.BCLInfo != null).Select (x => x.BCLInfo))
bclTestInfo.Convert ();
-
+ foreach (var monoNativeInfo in MacTestProjects.Where (x => x.MonoNativeInfo != null).Select (x => x.MonoNativeInfo))
+ monoNativeInfo.Convert ();
+
foreach (var proj in MacTestProjects.Where ((v) => v.GenerateVariations)) {
var file = Path.ChangeExtension (proj.Path, "csproj");
- if (!File.Exists (file))
+ if (proj.MonoNativeInfo != null)
+ file = proj.MonoNativeInfo.TemplatePath;
+ if (!File.Exists (file))
throw new FileNotFoundException (file);
foreach (bool thirtyTwoBit in new bool[] { false, true })
{
if (proj.GenerateModern) {
var modern = new MacUnifiedTarget (true, thirtyTwoBit);
+ modern.MonoNativeInfo = proj.MonoNativeInfo;
configureTarget (modern, file, proj.IsNUnitProject);
unified_targets.Add (modern);
}
if (proj.GenerateFull) {
var full = new MacUnifiedTarget (false, thirtyTwoBit);
+ full.MonoNativeInfo = proj.MonoNativeInfo;
configureTarget (full, file, proj.IsNUnitProject);
unified_targets.Add (full);
}
@@ -468,9 +487,11 @@ void ConfigureMac ()
unified_targets.Add (system);
}
- var classic = new MacClassicTarget ();
- configureTarget (classic, file, false);
- classic_targets.Add (classic);
+ if (proj.MonoNativeInfo == null) {
+ var classic = new MacClassicTarget ();
+ configureTarget (classic, file, false);
+ classic_targets.Add (classic);
+ }
}
foreach (var proj in MacTestProjects.Where (v => !v.GenerateVariations)) {
diff --git a/tests/xharness/Jenkins.cs b/tests/xharness/Jenkins.cs
index 06842801b260..c732fd30d3f5 100644
--- a/tests/xharness/Jenkins.cs
+++ b/tests/xharness/Jenkins.cs
@@ -240,6 +240,9 @@ IEnumerable GetTestData (RunTestTask test)
break;
}
break;
+ case "mono-native-compat":
+// yield return new TestData { Variation = "XXXX Debug (all optimizations)", MonoBundlingExtraArgs = "--registrar:static --optimize:all,-remove-uithread-checks", Debug = true, LinkMode = "Full", Defines = "OPTIMIZEALL", Ignored = !IncludeAll };
+ break;
}
break;
default:
@@ -714,12 +717,21 @@ async Task PopulateTasksAsync ()
if (!IsIncluded (project))
ignored = true;
+ if (project.MonoNativeInfo != null) {
+ Console.Error.WriteLine ($"HANDLE MONO NATIVE: {project.MonoNativeInfo.FlavorSuffix}!");
+ }
+
var configurations = project.Configurations;
if (configurations == null)
configurations = new string [] { "Debug" };
foreach (var config in configurations) {
BuildProjectTask build;
- if (project.GenerateVariations) {
+ if (project.MonoNativeInfo != null) {
+ Console.Error.WriteLine ($"POPULATE TASKS: {project.Path} {project.MonoNativeInfo} {config}");
+ build = new XBuildTask ();
+ build.Platform = TestPlatform.Mac_Unified;
+ build.CloneTestProject (project);
+ } else if (project.GenerateVariations) {
build = new MdtoolTask ();
build.Platform = TestPlatform.Mac_Classic;
build.TestProject = project;
@@ -765,11 +777,17 @@ async Task PopulateTasksAsync ()
}
exec.Variation = configurations.Length > 1 ? config : project.TargetFrameworkFlavor.ToString ();
+ if (project.MonoNativeInfo != null) {
+ Console.Error.WriteLine ($"POPULATE TASKS #1: {project.Path} {project.MonoNativeInfo} {config} {execs.Count ()}");
+ }
+
Tasks.AddRange (execs);
foreach (var e in execs) {
- if (project.GenerateVariations) {
+ if (project.MonoNativeInfo != null) {
+ Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified32, "-32", ignored32, true));
+ } else if (project.GenerateVariations) {
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified, "-unified", ignored));
- Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified32, "-unified-32", ignored32, true));
+ Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified32, "-unified" + "-32", ignored32, true));
if (project.GenerateFull) {
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_UnifiedXM45, "-unifiedXM45", ignored));
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_UnifiedXM45_32, "-unifiedXM45-32", ignored32, true));
@@ -895,6 +913,7 @@ RunTestTask CloneExecuteTask (RunTestTask task, TestProject original_project, Te
Ignored = ignore,
TestName = task.TestName,
IsUnitTest = macExec.IsUnitTest,
+ Variation = task.Variation
};
}
var nunit = task as NUnitExecuteTask;
@@ -2347,6 +2366,7 @@ public virtual string TestName {
var rv = Path.GetFileNameWithoutExtension (ProjectFile);
if (rv == null)
return $"unknown test name ({GetType ().Name}";
+
switch (Platform) {
case TestPlatform.Mac:
case TestPlatform.Mac_Classic:
diff --git a/tests/xharness/MacTarget.cs b/tests/xharness/MacTarget.cs
index 769c64abbbc6..ed41c88b70bc 100644
--- a/tests/xharness/MacTarget.cs
+++ b/tests/xharness/MacTarget.cs
@@ -6,6 +6,8 @@ public class MacTarget : Target
{
public bool ThirtyTwoBit;
+ public MonoNativeInfo MonoNativeInfo { get; set; }
+
protected override bool FixProjectReference (string name)
{
switch (name) {
diff --git a/tests/xharness/MacUnifiedTarget.cs b/tests/xharness/MacUnifiedTarget.cs
index 9add3e03cf7f..ac51a125c2b6 100644
--- a/tests/xharness/MacUnifiedTarget.cs
+++ b/tests/xharness/MacUnifiedTarget.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
+using System.Xml;
namespace xharness
{
@@ -29,6 +31,8 @@ protected override void CalculateName ()
if (IsBCL)
Name = Name + BCLInfo.FlavorSuffix;
+ if (MonoNativeInfo != null)
+ Name = Name + MonoNativeInfo.FlavorSuffix;
}
public override bool ShouldSkipProjectGeneration
@@ -38,15 +42,18 @@ public override bool ShouldSkipProjectGeneration
return SkipProjectGeneration;
}
}
-
+
public override string Suffix {
get {
if (SkipProjectGeneration)
return "";
-
+ if (MonoNativeInfo != null) {
+ if (System)
+ return MonoNativeInfo.FlavorSuffix + "-system";
+ return MonoNativeInfo.FlavorSuffix + (ThirtyTwoBit ? "-32" : "");
+ }
if (System)
return "-system";
-
var suffix = (Mobile ? "" : "XM45") + (ThirtyTwoBit ? "-32" : "");
return "-unified" + (IsBCL ? "" : suffix);
}
@@ -60,7 +67,7 @@ public override string MakefileWhereSuffix {
return "unified" + (IsBCL ? "" : suffix);
}
}
-
+
protected override string ProjectTypeGuids {
get {
return "{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};" + LanguageGuid;
@@ -139,5 +146,41 @@ public override Dictionary NewPropertiesToAdd
return props;
}
}
+
+ protected override string GetMinimumOSVersion (string templateMinimumOSVersion)
+ {
+ if (MonoNativeInfo == null)
+ return templateMinimumOSVersion;
+ switch (MonoNativeInfo.Flavor) {
+ case MonoNativeFlavor.Compat:
+ return "10.9";
+ case MonoNativeFlavor.Unified:
+ return "10.12";
+ default:
+ throw new Exception ($"Unknown MonoNativeFlavor: {MonoNativeInfo.Flavor}");
+ }
+ }
+
+ protected override void ProcessProject ()
+ {
+ base.ProcessProject ();
+
+ if (MonoNativeInfo == null)
+ return;
+
+ MonoNativeInfo.AddProjectDefines (inputProject);
+ inputProject.AddAdditionalDefines ("MONO_NATIVE_MAC");
+
+ XmlDocument info_plist = new XmlDocument ();
+ var target_info_plist = Path.Combine (TargetDirectory, "Info" + Suffix + ".plist");
+ info_plist.LoadWithoutNetworkAccess (Path.Combine (TargetDirectory, "Info-mac.plist"));
+ BundleIdentifier = info_plist.GetCFBundleIdentifier ();
+ var plist_min_version = info_plist.GetPListStringValue ("LSMinimumSystemVersion");
+ info_plist.SetPListStringValue ("LSMinimumSystemVersion", GetMinimumOSVersion (plist_min_version));
+
+ inputProject.FixInfoPListInclude (Suffix);
+
+ Harness.Save (info_plist, target_info_plist);
+ }
}
}
diff --git a/tests/xharness/MonoNativeInfo.cs b/tests/xharness/MonoNativeInfo.cs
index 0eb8320656a5..fef45966bc07 100644
--- a/tests/xharness/MonoNativeInfo.cs
+++ b/tests/xharness/MonoNativeInfo.cs
@@ -45,10 +45,11 @@ public MonoNativeInfo (Harness harness, MonoNativeFlavor flavor)
Flavor = flavor;
}
- public string FlavorSuffix => Flavor == MonoNativeFlavor.Compat ? "-compat" : "-unified";
- public string ProjectName => "mono-native" + FlavorSuffix;
- public string ProjectPath => Path.Combine (Harness.RootDirectory, "mono-native", ProjectName + ".csproj");
- public string TemplatePath => Path.Combine (Harness.RootDirectory, "mono-native", "mono-native.csproj.template");
+ string NativeFlavorSuffix => Flavor == MonoNativeFlavor.Compat ? "-compat" : "-unified";
+ public virtual string FlavorSuffix => NativeFlavorSuffix;
+ public string ProjectName => "mono-native" + NativeFlavorSuffix;
+ public string ProjectPath => Path.Combine (Harness.RootDirectory, "mono-native", "mono-native" + FlavorSuffix + ".csproj");
+ public string TemplatePath => Path.Combine (Harness.RootDirectory, "mono-native", "mono-native" + (Harness.Mac ? "-mac" : string.Empty) + ".csproj.template");
public void Convert ()
{
@@ -62,6 +63,10 @@ public void Convert ()
AddProjectDefines (inputProject);
+ Convert (inputProject);
+
+ Console.Error.WriteLine ($"CONVERT: {Harness.Mac} {ProjectPath}");
+
Harness.Save (inputProject, ProjectPath);
}
@@ -83,4 +88,38 @@ public void AddProjectDefines (XmlDocument project)
}
}
}
+
+ public class MacMonoNativeInfo : MonoNativeInfo
+ {
+ public MacFlavors MacFlavor { get; set; }
+
+ public override string FlavorSuffix => base.FlavorSuffix + (MacFlavor == MacFlavors.Full ? "-full" : "-modern");
+
+ public MacMonoNativeInfo (Harness harness, MonoNativeFlavor flavor, MacFlavors macFlavor)
+ : base (harness, flavor)
+ {
+ if (macFlavor == MacFlavors.All)
+ throw new ArgumentException ("Each target must be a specific flavor");
+
+ MacFlavor = macFlavor;
+ }
+
+ protected override void Convert (XmlDocument inputProject)
+ {
+ switch (MacFlavor) {
+ case MacFlavors.Modern:
+ inputProject.SetTargetFrameworkIdentifier ("Xamarin.Mac");
+ inputProject.SetTargetFrameworkVersion ("v2.0");
+ inputProject.RemoveNode ("UseXamMacFullFramework");
+ inputProject.AddAdditionalDefines ("MOBILE;XAMMAC");
+ inputProject.AddReference ("Mono.Security");
+ break;
+ case MacFlavors.Full:
+ inputProject.AddAdditionalDefines ("XAMMAC_4_5");
+ break;
+ }
+
+ base.Convert (inputProject);
+ }
+ }
}
diff --git a/tests/xharness/ProjectFileExtensions.cs b/tests/xharness/ProjectFileExtensions.cs
index df9970739522..088399ed1bcd 100644
--- a/tests/xharness/ProjectFileExtensions.cs
+++ b/tests/xharness/ProjectFileExtensions.cs
@@ -141,7 +141,12 @@ static bool EvaluateCondition (XmlNode node, string platform, string configurati
public static string GetOutputPath (this XmlDocument csproj, string platform, string configuration)
{
- return GetElementValue (csproj, platform, configuration, "OutputPath");
+ try {
+ return GetElementValue (csproj, platform, configuration, "OutputPath");
+ } catch (Exception ex) {
+ Console.Error.WriteLine ($"OUTPUT PATH FAILED: {platform} {configuration} {ex.Message}");
+ throw;
+ }
}
static string GetElementValue (this XmlDocument csproj, string platform, string configuration, string elementName)
diff --git a/tests/xharness/TVOSTarget.cs b/tests/xharness/TVOSTarget.cs
index 7c1926834c4d..4722bb9f4b17 100644
--- a/tests/xharness/TVOSTarget.cs
+++ b/tests/xharness/TVOSTarget.cs
@@ -8,6 +8,12 @@ namespace xharness
public class TVOSTarget : iOSTarget
{
public override string Suffix {
+ get {
+ return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix + "-tvos" : "-tvos";
+ }
+ }
+
+ public override string ExtraLinkerDefsSuffix {
get {
return "-tvos";
}
diff --git a/tests/xharness/Target.cs b/tests/xharness/Target.cs
index 4846790af470..406299b42f51 100644
--- a/tests/xharness/Target.cs
+++ b/tests/xharness/Target.cs
@@ -178,6 +178,9 @@ public void Execute ()
templateName = Path.GetFileNameWithoutExtension (templateName);
templateName = Path.GetFileNameWithoutExtension (templateName);
+ if (templateName.Equals ("mono-native-mac"))
+ templateName = "mono-native";
+
ProjectPath = Path.Combine (targetDirectory, templateName + ProjectFileSuffix + "." + ProjectFileExtension);
if (!ShouldSkipProjectGeneration)
diff --git a/tests/xharness/TestProject.cs b/tests/xharness/TestProject.cs
index 454bfc422d4a..491c0d92fd29 100644
--- a/tests/xharness/TestProject.cs
+++ b/tests/xharness/TestProject.cs
@@ -172,6 +172,9 @@ public class MacTestProject : TestProject
// Optional
public MacBCLTestInfo BCLInfo { get; set; }
+ // Optional
+ public MacMonoNativeInfo MonoNativeInfo { get; set; }
+
public bool GenerateModern => TargetFrameworkFlavor == MacFlavors.All || TargetFrameworkFlavor == MacFlavors.NonSystem || TargetFrameworkFlavor == MacFlavors.Modern;
public bool GenerateFull => TargetFrameworkFlavor == MacFlavors.All || TargetFrameworkFlavor == MacFlavors.NonSystem || TargetFrameworkFlavor == MacFlavors.Full;
public bool GenerateSystem => TargetFrameworkFlavor == MacFlavors.All || TargetFrameworkFlavor == MacFlavors.System;
diff --git a/tests/xharness/UnifiedTarget.cs b/tests/xharness/UnifiedTarget.cs
index dce4009c9e08..aecbc3a754d1 100644
--- a/tests/xharness/UnifiedTarget.cs
+++ b/tests/xharness/UnifiedTarget.cs
@@ -8,7 +8,7 @@ public class UnifiedTarget : iOSTarget
{
public override string Suffix {
get {
- return "-ios";
+ return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix : "-ios";
}
}
@@ -124,7 +124,7 @@ protected override bool SupportsBitcode {
protected override void ExecuteInternal ()
{
- if (true || MonoNativeInfo == null)
+ if (MonoNativeInfo == null)
return;
MonoNativeInfo.AddProjectDefines (inputProject);
diff --git a/tests/xharness/WatchOSTarget.cs b/tests/xharness/WatchOSTarget.cs
index fcdc2268cc6e..0d087ff80542 100644
--- a/tests/xharness/WatchOSTarget.cs
+++ b/tests/xharness/WatchOSTarget.cs
@@ -234,6 +234,12 @@ protected override string GetMinimumOSVersion (string templateMinimumOSVersion)
}
public override string Suffix {
+ get {
+ return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix + "-watchos" : "-watchos";
+ }
+ }
+
+ public override string ExtraLinkerDefsSuffix {
get {
return "-watchos";
}