diff --git a/tests/Makefile b/tests/Makefile index 81114cdb54..391f3778cf 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -291,6 +291,10 @@ wrench-mac-binding-project: cd mac-binding-project && $(MAKE) cd mac-binding-project && git clean -xfdq +wrench-mac-introspection: + $(Q) $(MAKE) run-mac-introspection + $(Q) $(MAKE) clean-mac-introspection + else wrench-mac-%: @echo "Mac tests have been disabled [$@]" diff --git a/tests/introspection/ApiTypoTest.cs b/tests/introspection/ApiTypoTest.cs index c39d371b45..97a3f167c0 100644 --- a/tests/introspection/ApiTypoTest.cs +++ b/tests/introspection/ApiTypoTest.cs @@ -26,10 +26,18 @@ using System.Reflection; using System.Text; using NUnit.Framework; #if XAMCORE_2_0 +#if MONOMAC +using AppKit; +#else using UIKit; +#endif using Foundation; #else +#if MONOMAC +using MonoMac.AppKit; +#else using MonoTouch.UIKit; +#endif using MonoTouch.Foundation; #endif diff --git a/tests/introspection/Mac/introspection-mac.csproj b/tests/introspection/Mac/introspection-mac.csproj index f940c1ce74..e4a1bbae99 100644 --- a/tests/introspection/Mac/introspection-mac.csproj +++ b/tests/introspection/Mac/introspection-mac.csproj @@ -6,8 +6,8 @@ {FD385098-B3FD-4331-92BF-CC1F918E3334} {42C0BBD9-55CE-4FC1-8D90-A7348ABAFB23};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Exe - dontlink - dontlink-mac + introspection + introspection Resources v4.5 @@ -46,6 +46,7 @@ + @@ -112,7 +113,7 @@ - + {D12F0F7B-8DE3-43EC-BA49-41052D065A9B} GuiUnit_NET_4_5 diff --git a/tests/introspection/Mac/introspection-mac.sln b/tests/introspection/Mac/introspection-mac.sln new file mode 100644 index 0000000000..1b50772ad8 --- /dev/null +++ b/tests/introspection/Mac/introspection-mac.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "introspection-mac", "introspection-mac.csproj", "{FD385098-B3FD-4331-92BF-CC1F918E3334}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GuiUnit_NET_4_5", "..\..\..\external\guiunit\src\framework\GuiUnit_NET_4_5.csproj", "{D12F0F7B-8DE3-43EC-BA49-41052D065A9B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FD385098-B3FD-4331-92BF-CC1F918E3334}.Debug|x86.ActiveCfg = Debug|x86 + {FD385098-B3FD-4331-92BF-CC1F918E3334}.Debug|x86.Build.0 = Debug|x86 + {FD385098-B3FD-4331-92BF-CC1F918E3334}.Release|x86.ActiveCfg = Release|x86 + {FD385098-B3FD-4331-92BF-CC1F918E3334}.Release|x86.Build.0 = Release|x86 + {D12F0F7B-8DE3-43EC-BA49-41052D065A9B}.Debug|x86.ActiveCfg = Debug|Any CPU + {D12F0F7B-8DE3-43EC-BA49-41052D065A9B}.Debug|x86.Build.0 = Debug|Any CPU + {D12F0F7B-8DE3-43EC-BA49-41052D065A9B}.Release|x86.ActiveCfg = Release|Any CPU + {D12F0F7B-8DE3-43EC-BA49-41052D065A9B}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/tests/introspection/iOS/introspection-ios.csproj b/tests/introspection/iOS/introspection-ios.csproj index 974d78ac42..5802a80363 100644 --- a/tests/introspection/iOS/introspection-ios.csproj +++ b/tests/introspection/iOS/introspection-ios.csproj @@ -164,19 +164,19 @@ - + - - - - - - - - - - + + + + + + + + + + diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 6eb0c07ed9..fa3cf24ab5 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -134,6 +134,7 @@ namespace xharness //var bcl_suites = new string[] { "mscorlib", "System", "System.Core", "System.Data", "System.Net.Http", "System.Numerics", "System.Runtime.Serialization", "System.Transactions", "System.Web.Services", "System.Xml", "System.Xml.Linq", "Mono.Security", "System.ComponentModel.DataAnnotations", "System.Json", "System.ServiceModel.Web", "Mono.Data.Sqlite" }; foreach (var p in test_suites) TestProjects.Add (Path.GetFullPath (Path.Combine (RootDirectory, p + "/" + p + ".csproj"))); + TestProjects.Add (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "Mac", "introspection-mac.csproj"))); foreach (var p in hard_coded_test_suites) HardCodedTestProjects.Add (Path.GetFullPath (Path.Combine (RootDirectory, p + "/" + p + ".csproj"))); //foreach (var p in fsharp_test_suites) @@ -169,7 +170,7 @@ namespace xharness TestProjects.Add (Path.GetFullPath (Path.Combine (RootDirectory, p + "/" + p + ".fsproj"))); foreach (var p in bcl_suites) TestProjects.Add (Path.GetFullPath (Path.Combine (RootDirectory, "bcl-test/" + p + "/" + p + ".csproj"))); - + TestProjects.Add (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "iOS", "introspection-ios.csproj"))); BclTests.AddRange (bcl_suites); WatchOSContainerTemplate = Path.GetFullPath (Path.Combine (RootDirectory, "watchos/Container")); diff --git a/tests/xharness/MacTarget.cs b/tests/xharness/MacTarget.cs index 9b01f4cb4e..aed5244cd5 100644 --- a/tests/xharness/MacTarget.cs +++ b/tests/xharness/MacTarget.cs @@ -4,6 +4,15 @@ namespace xharness { public class MacTarget : Target { + protected override bool FixProjectReference (string name) + { + switch (name) { + case "GuiUnit_NET_4_5": + return false; + default: + return base.FixProjectReference (name); + } + } public string SimplifiedName { get { return Name.EndsWith ("-mac", StringComparison.Ordinal) ? Name.Substring (0, Name.Length - 4) : Name; diff --git a/tests/xharness/MakefileGenerator.cs b/tests/xharness/MakefileGenerator.cs index adda1a2256..27b4ed549f 100644 --- a/tests/xharness/MakefileGenerator.cs +++ b/tests/xharness/MakefileGenerator.cs @@ -112,16 +112,21 @@ namespace xharness allTargetNames.Add (MakeMacClassicTargetName (target, MacTargetNameType.Build)); allTargetCleanNames.Add (MakeMacClassicTargetName (target, MacTargetNameType.Clean)); + // mdtool can only find referenced projects if the referenced + // projects are included in the solution. This requires us to + // build the solution (if it exists), not the project. + var slnPath = Path.ChangeExtension (target.ProjectPath, "sln"); + var fileToBuild = File.Exists (slnPath) ? slnPath : target.ProjectPath; writer.WriteTarget (MakeMacClassicTargetName (target, MacTargetNameType.Build), "$(GUI_UNIT_PATH)/bin/net_4_5/GuiUnit.exe"); - writer.WriteLine ("\t$(Q) $(MDTOOL) build {0}", target.ProjectPath); + writer.WriteLine ("\t$(Q) $(MDTOOL) build {0}", fileToBuild); writer.WriteLine (); writer.WriteTarget (MakeMacClassicTargetName (target, MacTargetNameType.Clean), ""); - writer.WriteLine ("\t$(Q) $(MDTOOL) build -t:clean {0}", target.ProjectPath); + writer.WriteLine ("\t$(Q) $(MDTOOL) build -t:clean {0}", fileToBuild); writer.WriteLine (); writer.WriteTarget (MakeMacClassicTargetName (target, MacTargetNameType.Exec), ""); - writer.WriteLine ("\t$(Q) ./{0}/bin/x86/Debug/{0}.app/Contents/MacOS/{0}", make_escaped_name); + writer.WriteLine ("\t$(Q) {0}/bin/x86/Debug/{1}.app/Contents/MacOS/{1}", Path.GetDirectoryName (target.ProjectPath), make_escaped_name); writer.WriteLine (); writer.WriteTarget (MakeMacClassicTargetName (target, MacTargetNameType.Run), ""); @@ -144,7 +149,7 @@ namespace xharness writer.WriteLine (); writer.WriteTarget (MakeMacUnifiedTargetName (target, MacTargetNameType.Exec), ""); - writer.WriteLine ("\t$(Q) ./{0}/bin/x86/Debug{1}/{0}.app/Contents/MacOS/{0}", make_escaped_name, target.Suffix); + writer.WriteLine ("\t$(Q) {2}/bin/x86/Debug{1}/{0}.app/Contents/MacOS/{0}", make_escaped_name, target.Suffix, Path.GetDirectoryName (target.ProjectPath)); writer.WriteLine (); writer.WriteTarget (MakeMacUnifiedTargetName (target, MacTargetNameType.Run), ""); diff --git a/tests/xharness/ProjectFileExtensions.cs b/tests/xharness/ProjectFileExtensions.cs index e33aac86aa..7bc77f4c8a 100644 --- a/tests/xharness/ProjectFileExtensions.cs +++ b/tests/xharness/ProjectFileExtensions.cs @@ -321,12 +321,15 @@ namespace xharness return imports [0].Attributes ["Project"].Value; } - public static void FixProjectReferences (this XmlDocument csproj, string suffix) + public static void FixProjectReferences (this XmlDocument csproj, string suffix, Func fixCallback = null) { var nodes = csproj.SelectNodes ("/*/*/*[local-name() = 'ProjectReference']"); if (nodes.Count == 0) return; foreach (XmlNode n in nodes) { + var name = n ["Name"].InnerText; + if (fixCallback != null && !fixCallback (name)) + continue; var include = n.Attributes ["Include"]; include.Value = include.Value.Replace (".csproj", suffix + ".csproj"); include.Value = include.Value.Replace (".fsproj", suffix + ".fsproj"); diff --git a/tests/xharness/Target.cs b/tests/xharness/Target.cs index 6d3e68b089..074cd091ad 100644 --- a/tests/xharness/Target.cs +++ b/tests/xharness/Target.cs @@ -61,6 +61,11 @@ namespace xharness public string LanguageGuid { get { return IsFSharp ? FSharpGuid : CSharpGuid; } } + protected virtual bool FixProjectReference (string name) + { + return true; + } + protected virtual void ProcessProject () { if (SupportsBitcode) { @@ -84,7 +89,7 @@ namespace xharness foreach (var k in newProperties.Keys) inputProject.SetTopLevelPropertyGroupValue (k, newProperties[k]); - inputProject.FixProjectReferences (Suffix); + inputProject.FixProjectReferences (Suffix, FixProjectReference); inputProject.SetAssemblyReference ("OpenTK", "OpenTK-1.0"); inputProject.SetProjectTypeGuids (IsBindingProject ? BindingsProjectTypeGuids : ProjectTypeGuids); inputProject.SetImport ("$(MSBuildExtensionsPath)\\Xamarin\\" + (IsBindingProject ? BindingsImports : Imports)); @@ -142,6 +147,8 @@ namespace xharness { targetDirectory = Path.GetDirectoryName (TemplateProjectPath); Name = Path.GetFileName (targetDirectory); + if (string.Equals (Name, "ios", StringComparison.OrdinalIgnoreCase) || string.Equals (Name, "mac", StringComparison.OrdinalIgnoreCase)) + Name = Path.GetFileName (Path.GetDirectoryName (targetDirectory)); ProjectPath = Path.Combine (targetDirectory, Path.GetFileNameWithoutExtension (TemplateProjectPath) + ProjectFileSuffix + "." + ProjectFileExtension);