diff --git a/NUnitLite/TouchRunner/MacRunner.cs b/NUnitLite/TouchRunner/MacRunner.cs new file mode 100644 index 0000000..bbc6392 --- /dev/null +++ b/NUnitLite/TouchRunner/MacRunner.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Threading.Tasks; + +using AppKit; +using Foundation; + +namespace MonoTouch.NUnit.UI { + public class MacRunner : BaseTouchRunner { + public static async Task MainAsync (IList arguments, params Assembly[] assemblies) + { + NSApplication.Init (); + + var options = new TouchOptions (arguments); + TouchOptions.Current = options; + return await RunTestsAsync (options, assemblies) ? 0 : 1; + } + + static async Task RunTestsAsync (TouchOptions options, Assembly[] assemblies) + { + var runner = new MacRunner (); + if (assemblies == null || assemblies.Length == 0) + assemblies = AppDomain.CurrentDomain.GetAssemblies (); + + foreach (var asm in assemblies) + runner.Load (asm); + + await runner.RunAsync (); + + return !runner.Result.IsFailure (); + } + + protected override void WriteDeviceInformation (TextWriter writer) + { + var piinfo = NSProcessInfo.ProcessInfo; + writer.WriteLine ("[macOS: {0}]", piinfo.OperatingSystemVersionString); + } + } +} diff --git a/NUnitLite/TouchRunner/TcpTextWriter.cs b/NUnitLite/TouchRunner/TcpTextWriter.cs index e2ee4c8..0c503d9 100644 --- a/NUnitLite/TouchRunner/TcpTextWriter.cs +++ b/NUnitLite/TouchRunner/TcpTextWriter.cs @@ -7,7 +7,9 @@ using System.Net.Sockets; using System.Text; +#if __IOS__ using UIKit; +#endif namespace MonoTouch.NUnit { diff --git a/NUnitLite/TouchRunner/TouchOptions.cs b/NUnitLite/TouchRunner/TouchOptions.cs index ab48dd7..d5b407a 100644 --- a/NUnitLite/TouchRunner/TouchOptions.cs +++ b/NUnitLite/TouchRunner/TouchOptions.cs @@ -19,11 +19,14 @@ // using System; +using System.Collections.Generic; using Foundation; +#if !__MACOS__ using UIKit; +#endif -#if !__WATCHOS__ +#if !__WATCHOS__ && !__MACOS__ using MonoTouch.Dialog; #endif @@ -43,9 +46,19 @@ public enum XmlVersion { public class TouchOptions { - static public TouchOptions Current = new TouchOptions (); + static TouchOptions current; + static public TouchOptions Current { + get { + if (current == null) + current = new TouchOptions (); + return current; + } + set { + current = value; + } + } - public TouchOptions () + public TouchOptions (IList arguments) { var defaults = NSUserDefaults.StandardUserDefaults; TerminateAfterExecution = defaults.BoolForKey ("execution.autoexit"); @@ -103,11 +116,16 @@ public TouchOptions () }; try { - os.Parse (Environment.GetCommandLineArgs ()); + os.Parse (arguments); } catch (OptionException oe) { Console.WriteLine ("{0} for options '{1}'", oe.Message, oe.OptionName); } } + + public TouchOptions () + : this (Environment.GetCommandLineArgs ()) + { + } private bool EnableNetwork { get; set; } @@ -137,7 +155,7 @@ public bool ShowUseNetworkLogger { public bool SortNames { get; set; } -#if !__WATCHOS__ +#if !__WATCHOS__ && !__MACOS__ public UIViewController GetViewController () { #if TVOS diff --git a/NUnitLite/TouchRunner/TouchRunner.cs b/NUnitLite/TouchRunner/TouchRunner.cs index 4a3e970..bce8578 100644 --- a/NUnitLite/TouchRunner/TouchRunner.cs +++ b/NUnitLite/TouchRunner/TouchRunner.cs @@ -30,10 +30,12 @@ using Foundation; using ObjCRuntime; +#if !__MACOS__ using UIKit; +#endif using Constants = global::ObjCRuntime.Constants; -#if !__WATCHOS__ +#if !__WATCHOS__ && !__MACOS__ using MonoTouch.Dialog; #endif @@ -202,6 +204,12 @@ public void AutoRun () }); } + public Task RunAsync () + { + Run (); + return Task.CompletedTask; + } + bool running; public void Run () { @@ -387,7 +395,7 @@ public bool OpenWriter (string message) // returns true if test run should still start bool ShowConnectionErrorAlert (string hostname, int port, Exception ex) { -#if __TVOS__ || __WATCHOS__ +#if __TVOS__ || __WATCHOS__ || __MACOS__ return true; #else // Don't show any alerts if we're running automated. @@ -652,7 +660,7 @@ protected override void WriteDeviceInformation (TextWriter writer) } #endif -#if !__WATCHOS__ +#if !__WATCHOS__ && !__MACOS__ public class ConsoleRunner : BaseTouchRunner { protected override void WriteDeviceInformation (TextWriter writer) { diff --git a/Touch.Client/macOS/full/Touch.Client-macOS-full.csproj b/Touch.Client/macOS/full/Touch.Client-macOS-full.csproj new file mode 100644 index 0000000..9ddd82f --- /dev/null +++ b/Touch.Client/macOS/full/Touch.Client-macOS-full.csproj @@ -0,0 +1,78 @@ + + + + Debug + AnyCPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6} + {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Touch.Client + Resources + Touch.Client + v4.5 + true + PackageReference + + + bin\Debug + true + full + false + DEBUG;NUNITLITE_NUGET + prompt + 4 + + + bin\Release + full + true + NUNITLITE_NUGET + prompt + 4 + + + + + + + + + + + + + + HttpTextWriter.cs + + + NUnitOutputTextWriter.cs + + + Options.cs + + + TcpTextWriter.cs + + + TestRocks.cs + + + TouchOptions.cs + + + TouchRunner.cs + + + MacRunner.cs + + + + + 3.12.0 + + + 3.6.0 + + + + \ No newline at end of file diff --git a/Touch.Client/macOS/mobile/Touch.Client-macOS-mobile.csproj b/Touch.Client/macOS/mobile/Touch.Client-macOS-mobile.csproj new file mode 100644 index 0000000..0a79a9d --- /dev/null +++ b/Touch.Client/macOS/mobile/Touch.Client-macOS-mobile.csproj @@ -0,0 +1,78 @@ + + + + Debug + AnyCPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06} + {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Touch.Client + Resources + Touch.Client + v2.0 + Xamarin.Mac + PackageReference + + + bin\Debug + true + full + false + DEBUG;NUNITLITE_NUGET + prompt + 4 + + + bin\Release + full + true + NUNITLITE_NUGET + prompt + 4 + + + + + + + + + + + + + + HttpTextWriter.cs + + + NUnitOutputTextWriter.cs + + + Options.cs + + + TcpTextWriter.cs + + + TestRocks.cs + + + TouchOptions.cs + + + TouchRunner.cs + + + MacRunner.cs + + + + + 3.12.0 + + + 3.6.0 + + + + \ No newline at end of file diff --git a/Touch.Unit.sln b/Touch.Unit.sln index ab97a2a..8361915 100644 --- a/Touch.Unit.sln +++ b/Touch.Unit.sln @@ -14,6 +14,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Touch.Client-iOS", "Touch.C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Touch.Client-watchOS", "Touch.Client\watchOS\Touch.Client-watchOS.csproj", "{5A3AB2C1-17A9-40C0-B889-2B5795C1C10E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Touch.Client-macOS-mobile", "Touch.Client\macOS\mobile\Touch.Client-macOS-mobile.csproj", "{88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Touch.Client-macOS-full", "Touch.Client\macOS\full\Touch.Client-macOS-full.csproj", "{A1209F3A-3876-4EAC-ADA7-99F660002AB6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|iPhoneSimulator = Debug|iPhoneSimulator @@ -138,6 +142,38 @@ Global {5A3AB2C1-17A9-40C0-B889-2B5795C1C10E}.AdHoc|iPhone.Build.0 = Debug|Any CPU {5A3AB2C1-17A9-40C0-B889-2B5795C1C10E}.AppStore|iPhone.ActiveCfg = Debug|Any CPU {5A3AB2C1-17A9-40C0-B889-2B5795C1C10E}.AppStore|iPhone.Build.0 = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.Debug|iPhone.Build.0 = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.Release|iPhone.ActiveCfg = Release|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.Release|iPhone.Build.0 = Release|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.AdHoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.AdHoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.AdHoc|iPhone.ActiveCfg = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.AdHoc|iPhone.Build.0 = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06}.AppStore|iPhone.Build.0 = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.Debug|iPhone.Build.0 = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.Release|iPhone.ActiveCfg = Release|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.Release|iPhone.Build.0 = Release|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.AdHoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.AdHoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.AdHoc|iPhone.ActiveCfg = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.AdHoc|iPhone.Build.0 = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {A1209F3A-3876-4EAC-ADA7-99F660002AB6}.AppStore|iPhone.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = Touch.Unit.csproj