diff --git a/tests/xharness/.vscode/launch.json b/tests/xharness/.vscode/launch.json deleted file mode 100644 index f3c709410174..000000000000 --- a/tests/xharness/.vscode/launch.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "C#: xharness Debug Site", - "preLaunchTask": "dotnet: build", - "type": "coreclr", - "request": "launch", - "program": "${workspaceFolder}/bin/Debug/xharness.dll", - "args": [ - "--verbose", - "--jenkins:server", - "--rootdir", - "..", - ], - "cwd": "${workspaceFolder}", - } - ] -} \ No newline at end of file diff --git a/tests/xharness/.vscode/tasks.json b/tests/xharness/.vscode/tasks.json deleted file mode 100644 index b1c79f68e643..000000000000 --- a/tests/xharness/.vscode/tasks.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "type": "dotnet", - "task": "build", - "group": "build", - "problemMatcher": [], - "label": "dotnet: build" - } - ] -} \ No newline at end of file diff --git a/tests/xharness/AppBundleLocator.cs b/tests/xharness/AppBundleLocator.cs index 3257b5f01250..9add4d86f504 100644 --- a/tests/xharness/AppBundleLocator.cs +++ b/tests/xharness/AppBundleLocator.cs @@ -31,7 +31,7 @@ public AppBundleLocator (IProcessManager processManager, Func getLog, stri this.dotnetPath = dotnetPath; } - public async Task LocateAppBundle (XmlDocument projectFile, string projectFilePath, TestTarget target, string buildConfiguration) + public async Task LocateAppBundle (XmlDocument projectFile, string projectFilePath, TestTarget target, string buildConfiguration) { string platform = string.Empty; if (target != TestTarget.None) @@ -47,7 +47,7 @@ public async Task LocateAppBundle (XmlDocument projectFile, string proje return await GetPropertyByMSBuildEvaluationAsync (projectFile, projectFilePath, "OutputPath", "_GenerateBundleName", properties); } else { - return projectFile.GetOutputPath (platform, buildConfiguration).Replace ('\\', Path.DirectorySeparatorChar); + return projectFile.GetOutputPath (platform, buildConfiguration)?.Replace ('\\', Path.DirectorySeparatorChar); } } @@ -56,7 +56,7 @@ public async Task LocateAppBundle (XmlDocument projectFile, string proje // * Will import the project file we're inspecting // * Has a target that will print a given property // and then executing MSBuild on this custom MSBuild file. - private async Task GetPropertyByMSBuildEvaluationAsync (XmlDocument csproj, string projectPath, string evaluateProperty, string dependsOnTargets = "", Dictionary properties = null) + async Task GetPropertyByMSBuildEvaluationAsync (XmlDocument csproj, string projectPath, string evaluateProperty, string dependsOnTargets = "", Dictionary? properties = null) { var xml = @" @@ -74,7 +74,7 @@ private async Task GetPropertyByMSBuildEvaluationAsync (XmlDocument cspr "; - var dir = Path.GetDirectoryName (projectPath); + var dir = Path.GetDirectoryName (projectPath)!; var inspector = Path.Combine (dir, "PropertyInspector.csproj"); var output = Path.Combine (dir, "PropertyInspector.txt"); try { @@ -94,12 +94,14 @@ private async Task GetPropertyByMSBuildEvaluationAsync (XmlDocument cspr args.Add ("/p:ProjectFile=" + projectPath); args.Add ("/p:OutputFile=" + output); - foreach (var prop in properties) - args.Add ($"/p:{prop.Key}={prop.Value}"); + if (properties is not null) { + foreach (var prop in properties) + args.Add ($"/p:{prop.Key}={prop.Value}"); + } args.Add (inspector); - var env = new Dictionary { + var env = new Dictionary { { "MSBUILD_EXE_PATH", null }, }; @@ -146,13 +148,13 @@ public string GetDotNetExecutable (string directory) } // Find the first global.json up the directory hierarchy (stopping at the root directory) - string global_json = null; + string? global_json = null; var dir = directory; while (dir.Length > 2) { global_json = Path.Combine (dir, "global.json"); if (File.Exists (global_json)) break; - dir = Path.GetDirectoryName (dir); + dir = Path.GetDirectoryName (dir)!; } if (!File.Exists (global_json)) throw new Exception ($"Could not find any global.json file in {directory} or above"); @@ -164,7 +166,9 @@ public string GetDotNetExecutable (string directory) var doc = new XmlDocument (); doc.Load (reader); - var version = doc.SelectSingleNode ("/root/sdk").InnerText; + var version = doc.SelectSingleNode ("/root/sdk")?.InnerText; + if (version is null) + throw new Exception ($"Could not find SDK version in {global_json}"); string executable; switch (version [0]) { diff --git a/tests/xharness/AppRunner.cs b/tests/xharness/AppRunner.cs index 4dd6d865ee34..4cc1a11b2690 100644 --- a/tests/xharness/AppRunner.cs +++ b/tests/xharness/AppRunner.cs @@ -25,24 +25,24 @@ public class AppRunner { readonly ISimulatorLoaderFactory simulatorsLoaderFactory; readonly ISimpleListenerFactory listenerFactory; readonly IDeviceLoaderFactory devicesLoaderFactory; - readonly ICrashSnapshotReporterFactory snapshotReporterFactory; + readonly CrashSnapshotReporterFactory snapshotReporterFactory; readonly ICaptureLogFactory captureLogFactory; - readonly IDeviceLogCapturerFactory deviceLogCapturerFactory; + readonly DeviceLogCapturerFactory deviceLogCapturerFactory; readonly ITestReporterFactory testReporterFactory; readonly IAppBundleInformationParser appBundleInformationParser; readonly RunMode runMode; readonly bool isSimulator; readonly TestTarget target; - readonly IHarness harness; + readonly Harness harness; readonly double timeoutMultiplier; - readonly IBuildToolTask buildTask; - readonly string variation; + readonly BuildToolTask? buildTask; + readonly string? variation; readonly string projectFilePath; - readonly string buildConfiguration; + readonly string? buildConfiguration; - string deviceName; - ISimulatorDevice simulator; + string? deviceName; + ISimulatorDevice? simulator; bool ensureCleanSimulatorState = true; bool EnsureCleanSimulatorState { @@ -50,13 +50,16 @@ bool EnsureCleanSimulatorState { set => ensureCleanSimulatorState = value; } - public AppBundleInformation AppInformation { get; private set; } + AppBundleInformation? appInformation; + public AppBundleInformation AppInformation { + get => appInformation!; + } - bool IsExtension => AppInformation.Extension.HasValue; + bool IsExtension => AppInformation?.Extension.HasValue ?? false; public TestExecutingResult Result { get; private set; } - public string FailureMessage { get; private set; } + public string? FailureMessage { get; private set; } public IFileBackedLog MainLog { get; set; } @@ -67,22 +70,22 @@ public AppRunner (IMlaunchProcessManager processManager, ISimulatorLoaderFactory simulatorsFactory, ISimpleListenerFactory simpleListenerFactory, IDeviceLoaderFactory devicesFactory, - ICrashSnapshotReporterFactory snapshotReporterFactory, + CrashSnapshotReporterFactory snapshotReporterFactory, ICaptureLogFactory captureLogFactory, - IDeviceLogCapturerFactory deviceLogCapturerFactory, + DeviceLogCapturerFactory deviceLogCapturerFactory, ITestReporterFactory reporterFactory, TestTarget target, - IHarness harness, + Harness harness, IFileBackedLog mainLog, ILogs logs, string projectFilePath, - string buildConfiguration, - ISimulatorDevice simulator = null, - string deviceName = null, + string? buildConfiguration, + ISimulatorDevice? simulator = null, + string? deviceName = null, bool ensureCleanSimulatorState = false, double timeoutMultiplier = 1, - string variation = null, - IBuildToolTask buildTask = null) + string? variation = null, + BuildToolTask? buildTask = null) { this.processManager = processManager ?? throw new ArgumentNullException (nameof (processManager)); this.simulatorsLoaderFactory = simulatorsFactory ?? throw new ArgumentNullException (nameof (simulatorsFactory)); @@ -112,7 +115,7 @@ public AppRunner (IMlaunchProcessManager processManager, public async Task InitializeAsync () { - AppInformation = await appBundleInformationParser.ParseFromProject2 (harness.AppBundleLocator, projectFilePath, target, buildConfiguration); + appInformation = await appBundleInformationParser.ParseFromProject2 (harness.AppBundleLocator, projectFilePath, target, buildConfiguration!); AppInformation.Variation = variation; } @@ -307,7 +310,7 @@ public async Task RunAsync () args.Add (new SetStdoutArgument (stdout_log)); args.Add (new SetStderrArgument (stderr_log)); - var simulators = new [] { simulator }; + var simulators = new [] { simulator! }; var systemLogs = new List (); foreach (var sim in simulators) { // Upload the system log @@ -344,7 +347,7 @@ public async Task RunAsync () } MainLog.WriteLine ("Enabled verbose logging"); - args.Add (new SimulatorUDIDArgument (simulator.UDID)); + args.Add (new SimulatorUDIDArgument (simulator!.UDID)); await crashReporter.StartCaptureAsync (); @@ -373,7 +376,7 @@ public async Task RunAsync () args.Add (new DeviceNameArgument (deviceName)); var deviceSystemLog = Logs.Create ($"device-{deviceName}-{Harness.Helpers.Timestamp}.log", "Device log"); - var deviceLogCapturer = deviceLogCapturerFactory.Create (harness.HarnessLog, deviceSystemLog, deviceName); + var deviceLogCapturer = deviceLogCapturerFactory.Create (harness.HarnessLog!, deviceSystemLog, deviceName); deviceLogCapturer.StartCapture (); try { @@ -429,14 +432,14 @@ public async Task RunAsync () FailureMessage = "Test app failed to launch."; } - return testReporter.Success.Value ? 0 : 1; + return testReporter?.Success == true ? 0 : 1; } static bool IsLaunchFailure (IFileBackedLog log) { try { using var reader = log.GetReader (); - string line; + string? line; while ((line = reader.ReadLine ()) is not null) { if (line.Contains ("Could not launch the app", StringComparison.Ordinal)) return true; diff --git a/tests/xharness/CrashSnapshotReporterFactory.cs b/tests/xharness/CrashSnapshotReporterFactory.cs index bb8c31af7155..d2bc2158570d 100644 --- a/tests/xharness/CrashSnapshotReporterFactory.cs +++ b/tests/xharness/CrashSnapshotReporterFactory.cs @@ -5,11 +5,7 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Logging; namespace Xharness { - public interface ICrashSnapshotReporterFactory { - ICrashSnapshotReporter Create (ILog log, ILogs logs, bool isDevice, string deviceName); - } - - public class CrashSnapshotReporterFactory : ICrashSnapshotReporterFactory { + public class CrashSnapshotReporterFactory { readonly IMlaunchProcessManager processManager; public CrashSnapshotReporterFactory (IMlaunchProcessManager processManager) @@ -17,7 +13,7 @@ public CrashSnapshotReporterFactory (IMlaunchProcessManager processManager) this.processManager = processManager ?? throw new ArgumentNullException (nameof (processManager)); } - public ICrashSnapshotReporter Create (ILog log, ILogs logs, bool isDevice, string deviceName) => + public ICrashSnapshotReporter Create (ILog log, ILogs logs, bool isDevice, string? deviceName) => new CrashSnapshotReporter (processManager, log, logs, isDevice, deviceName); } } diff --git a/tests/xharness/DeviceLogCapturerFactory.cs b/tests/xharness/DeviceLogCapturerFactory.cs index eafd26927c8e..e70ba1c7d796 100644 --- a/tests/xharness/DeviceLogCapturerFactory.cs +++ b/tests/xharness/DeviceLogCapturerFactory.cs @@ -4,12 +4,8 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Logging; namespace Xharness { - public interface IDeviceLogCapturerFactory { - IDeviceLogCapturer Create (ILog mainLog, ILog deviceLog, string deviceName); - } - - public class DeviceLogCapturerFactory : IDeviceLogCapturerFactory { - public IDeviceLogCapturer Create (ILog mainLog, ILog deviceLog, string deviceName) + public class DeviceLogCapturerFactory { + public IDeviceLogCapturer Create (ILog mainLog, ILog deviceLog, string? deviceName) { return new DeviceLogCapturer (mainLog, deviceLog, deviceName); } diff --git a/tests/xharness/GitHub.cs b/tests/xharness/GitHub.cs index 125e9ac2198a..11d8d4a266cb 100644 --- a/tests/xharness/GitHub.cs +++ b/tests/xharness/GitHub.cs @@ -31,10 +31,10 @@ public class GitHub : IVersionControlSystem { const string PullsApiUrl = "https://api.github.com/repos/dotnet/macios/pulls"; - readonly IHarness harness; + readonly Harness harness; readonly IProcessManager processManager; - public GitHub (IHarness harness, IProcessManager processManager) + public GitHub (Harness harness, IProcessManager processManager) { if (harness is null) throw new ArgumentNullException (nameof (harness)); @@ -196,7 +196,7 @@ IEnumerable GetModifiedFilesRemotely (int pullRequest) var output = new MemoryLog () { Timestamp = false // ensure we do not add the timestap or the logic for the file check will be hard and having it adds no value }; - var rv = processManager.RunAsync (git, harness.HarnessLog, stdoutLog: output, stderrLog: output).Result; + var rv = processManager.RunAsync (git, harness.HarnessLog!, stdoutLog: output, stderrLog: output).Result; if (rv.Succeeded) return output.ToString ().Split (new char [] { '\n' }, StringSplitOptions.RemoveEmptyEntries); diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index a281e9f4b701..33cf6b5ffb93 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Runtime.InteropServices; @@ -33,14 +34,14 @@ public class HarnessConfiguration { public Dictionary EnvironmentVariables { get; set; } = new Dictionary (); public bool? IncludeSystemPermissionTests { get; set; } public List TestProjects { get; set; } = new List (); - public string JenkinsConfiguration { get; set; } + public string JenkinsConfiguration { get; set; } = string.Empty; public HashSet Labels { get; set; } = new HashSet (); public string LogDirectory { get; set; } = Environment.CurrentDirectory; - public string MarkdownSummaryPath { get; set; } - public string PeriodicCommand { get; set; } - public string PeriodicCommandArguments { get; set; } + public string MarkdownSummaryPath { get; set; } = string.Empty; + public string PeriodicCommand { get; set; } = string.Empty; + public string PeriodicCommandArguments { get; set; } = string.Empty; public TimeSpan PeriodicCommandInterval { get; set; } - public string SdkRoot { get; set; } + public string? SdkRoot { get; set; } public TestTarget Target { get; set; } public double TimeoutInMinutes { get; set; } = 15; public bool UseSystemXamarinIOSMac { get; set; } @@ -48,20 +49,20 @@ public class HarnessConfiguration { public XmlResultJargon XmlJargon { get; set; } = XmlResultJargon.NUnitV3; // This is the maccore/tests directory. - static string root_directory; + static string? root_directory; public static string RootDirectory { get { if (root_directory is null) { - var testAssemblyDirectory = Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly ().Location); + var testAssemblyDirectory = Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly ().Location)!; var dir = testAssemblyDirectory; var path = Path.Combine (testAssemblyDirectory, ".git"); while (!Directory.Exists (path) && path.Length > 3) { - dir = Path.GetDirectoryName (dir); + dir = Path.GetDirectoryName (dir)!; path = Path.Combine (dir, ".git"); } if (!Directory.Exists (path)) throw new Exception ("Could not find the xamarin-macios repo."); - path = Path.Combine (Path.GetDirectoryName (path), "tests"); + path = Path.Combine (Path.GetDirectoryName (path)!, "tests"); if (!Directory.Exists (path)) throw new Exception ("Could not find the tests directory."); root_directory = Path.GetFullPath (path); @@ -121,7 +122,7 @@ public static string InjectRootTestsDirectory (string value) } } - public class Harness : IHarness { + public class Harness { readonly TestTarget target; readonly string buildConfiguration = "Debug"; readonly IMlaunchProcessManager processManager; @@ -130,23 +131,23 @@ public class Harness : IHarness { public HarnessAction Action { get; } public int Verbosity { get; } - public IFileBackedLog HarnessLog { get; set; } - public HashSet Labels { get; } + public IFileBackedLog? HarnessLog { get; set; } + public HashSet Labels { get; } = new (); public XmlResultJargon XmlJargon { get; } public IResultParser ResultParser { get; } public ITunnelBore TunnelBore { get; } public AppBundleLocator AppBundleLocator { get; } - string sdkRoot; + string? sdkRoot; string SdkRoot { - get => sdkRoot; + get => sdkRoot!; set { sdkRoot = value; XcodeRoot = FindXcode (sdkRoot); } } - bool TryGetMlaunchDotnetPath (out string value) + bool TryGetMlaunchDotnetPath ([NotNullWhen (true)] out string? value) { value = null; @@ -160,12 +161,12 @@ bool TryGetMlaunchDotnetPath (out string value) } var sdkPlatform = platform.AsString ().ToUpperInvariant (); - var sdkName = GetVariable ($"{sdkPlatform}_NUGET_SDK_NAME"); + var sdkName = GetVariable ($"{sdkPlatform}_NUGET_SDK_NAME") ?? throw new Exception ($"Could not get the SDK name for {sdkPlatform} from the environment variable {sdkPlatform}_NUGET_SDK_NAME"); // there is a diff between getting the path for the current platform when running on CI or off CI. The config files in the CI do not // contain the correct workload version, the reason for this is that the workload is built in a different machine which means that // the Make.config will use the wrong version. The CI set the version in the environment variable {platform}_WORKLOAD_VERSION via a script. - var workloadVersion = GetVariable ($"{sdkPlatform}_WORKLOAD_VERSION"); - var sdkVersion = GetVariable ($"{sdkPlatform}_NUGET_VERSION_NO_METADATA"); + var workloadVersion = GetVariable ($"{sdkPlatform}_WORKLOAD_VERSION", ""); + var sdkVersion = GetVariable ($"{sdkPlatform}_NUGET_VERSION_NO_METADATA") ?? throw new Exception ($"Could not get the SDK version for {sdkPlatform} from the environment variable {sdkPlatform}_NUGET_VERSION_NO_METADATA"); value = Path.Combine (DOTNET_DIR, "packs", sdkName, string.IsNullOrEmpty (workloadVersion) ? sdkVersion : workloadVersion, "tools", "bin", "mlaunch"); return true; } @@ -184,7 +185,8 @@ bool IsVariableSet (string variable) return !string.IsNullOrEmpty (GetVariable (variable)); } - string GetVariable (string variable, string @default = null) + [return: NotNullIfNotNull (nameof (@default))] + string? GetVariable (string variable, string? @default = null) { var result = Environment.GetEnvironmentVariable (variable); if (string.IsNullOrEmpty (result)) @@ -212,7 +214,7 @@ public Version DotNetVersion { // Run - public string XcodeRoot { get; private set; } + public string? XcodeRoot { get; private set; } public string LogDirectory { get; } = Environment.CurrentDirectory; public double Timeout { get; } = 15; // in minutes public double LaunchTimeout { get; } // in minutes @@ -268,17 +270,17 @@ public Harness (IResultParser resultParser, HarnessAction action, HarnessConfigu INCLUDE_IOS = IsVariableSet (nameof (INCLUDE_IOS)); INCLUDE_TVOS = IsVariableSet (nameof (INCLUDE_TVOS)); - JENKINS_RESULTS_DIRECTORY = GetVariable (nameof (JENKINS_RESULTS_DIRECTORY)); + JENKINS_RESULTS_DIRECTORY = GetVariable (nameof (JENKINS_RESULTS_DIRECTORY)) ?? throw new Exception ($"Could not get the Jenkins results directory from the environment variable {nameof (JENKINS_RESULTS_DIRECTORY)}"); INCLUDE_MAC = IsVariableSet (nameof (INCLUDE_MAC)); INCLUDE_MACCATALYST = IsVariableSet (nameof (INCLUDE_MACCATALYST)); - DOTNET_DIR = GetVariable (nameof (DOTNET_DIR)); - DOTNET_TFM = GetVariable (nameof (DOTNET_TFM)); + DOTNET_DIR = GetVariable (nameof (DOTNET_DIR)) ?? throw new Exception ($"Could not get the .NET directory from the environment variable {nameof (DOTNET_DIR)}"); + DOTNET_TFM = GetVariable (nameof (DOTNET_TFM)) ?? throw new Exception ($"Could not get the .NET TFM from the environment variable {nameof (DOTNET_TFM)}"); if (string.IsNullOrEmpty (SdkRoot)) - SdkRoot = GetVariable ("XCODE_DEVELOPER_ROOT", configuration.SdkRoot); + SdkRoot = GetVariable ("XCODE_DEVELOPER_ROOT", configuration.SdkRoot!); processManager = new MlaunchProcessManager (XcodeRoot, MlaunchPath); - AppBundleLocator = new AppBundleLocator (processManager, () => HarnessLog, "/usr/local/share/dotnet/dotnet", GetVariable ("DOTNET")); + AppBundleLocator = new AppBundleLocator (processManager, () => HarnessLog!, "/usr/local/share/dotnet/dotnet", GetVariable ("DOTNET")!); TunnelBore = new TunnelBore (processManager); } @@ -319,7 +321,7 @@ static string FindXcode (string path) return path; } - path = Path.GetDirectoryName (path); + path = Path.GetDirectoryName (path)!; } while (true); } @@ -426,8 +428,8 @@ void PopulateUnitTestProjects () void PopulatePlatformSpecificProjects () { - string [] noConfigurations = null; - var debugAndRelease = new string [] { "Debug", "Release" }; + string []? noConfigurations = null; + string []? debugAndRelease = new string [] { "Debug", "Release" }; var projectInfos = new [] { new { @@ -449,35 +451,35 @@ void PopulatePlatformSpecificProjects () Platforms = TestPlatform.All, ProjectPath = Path.Combine ("linker", "dont link"), IsFSharp = false, - Configurations = debugAndRelease, + Configurations = (string[]?) debugAndRelease, }, new { Label = TestLabel.Linker, Platforms = TestPlatform.All, ProjectPath = Path.Combine ("linker", "link sdk"), IsFSharp = false, - Configurations = debugAndRelease, + Configurations = (string[]?) debugAndRelease, }, new { Label = TestLabel.Linker, Platforms = TestPlatform.All, ProjectPath = Path.Combine ("linker", "link all"), IsFSharp = false, - Configurations = debugAndRelease, + Configurations = (string[]?) debugAndRelease, }, new { Label = TestLabel.Linker, Platforms = TestPlatform.All, ProjectPath = Path.Combine ("linker", "trimmode copy"), IsFSharp = false, - Configurations = debugAndRelease, + Configurations = (string[]?) debugAndRelease, }, new { Label = TestLabel.Linker, Platforms = TestPlatform.All, ProjectPath = Path.Combine ("linker", "trimmode link"), IsFSharp = false, - Configurations = debugAndRelease, + Configurations = (string[]?) debugAndRelease, }, new { Label = TestLabel.Fsharp, @@ -557,7 +559,7 @@ IEnumerable FindConfigFiles (string name) var file = Path.Combine (dir, name); if (File.Exists (file)) yield return file; - dir = Path.GetDirectoryName (dir); + dir = Path.GetDirectoryName (dir)!; } } @@ -677,7 +679,7 @@ public bool UseTcpTunnel { } } - public string VSDropsUri { + public string? VSDropsUri { get { var uri = Environment.GetEnvironmentVariable ("VSDROPS_URI"); return string.IsNullOrEmpty (uri) ? null : uri; @@ -711,7 +713,7 @@ int Jenkins () public void Save (StringWriter doc, string path) { if (!File.Exists (path)) { - Directory.CreateDirectory (Path.GetDirectoryName (path)); + Directory.CreateDirectory (Path.GetDirectoryName (path)!); File.WriteAllText (path, doc.ToString ()); Log (1, "Created {0}", path); } else { @@ -740,7 +742,7 @@ AppRunner CreateAppRunner (TestProject project) new TestReporterFactory (processManager), target, this, - HarnessLog, + HarnessLog!, new Logs (LogDirectory), project.Path, buildConfiguration); diff --git a/tests/xharness/IAppBundleInformationParserExtensions.cs b/tests/xharness/IAppBundleInformationParserExtensions.cs index ac25d71c2157..57b793746ab5 100644 --- a/tests/xharness/IAppBundleInformationParserExtensions.cs +++ b/tests/xharness/IAppBundleInformationParserExtensions.cs @@ -11,7 +11,7 @@ namespace Xharness { public static class IAppBundleInformationParserExtensions { // This is a copy of this method: https://github.com/dotnet/xharness/blob/aa434d0c7e6eb46df1ec11b3c63add37d835c4d0/src/Microsoft.DotNet.XHarness.iOS.Shared/AppBundleInformationParser.cs#L43-L103 // And then augmented to handle that the path to the Info.plist might have $(RootTestsDirectory) in it. - public async static Task ParseFromProject2 (this IAppBundleInformationParser @this, IAppBundleLocator? _appBundleLocator, string projectFilePath, TestTarget target, string buildConfiguration) + public async static Task ParseFromProject2 (this IAppBundleInformationParser @this, AppBundleLocator? _appBundleLocator, string projectFilePath, TestTarget target, string buildConfiguration) { var csproj = new XmlDocument (); csproj.LoadWithoutNetworkAccess (projectFilePath); diff --git a/tests/xharness/IHarness.cs b/tests/xharness/IHarness.cs deleted file mode 100644 index 7a3c0c1ebb4c..000000000000 --- a/tests/xharness/IHarness.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.DotNet.XHarness.Common; -using Microsoft.DotNet.XHarness.Common.Logging; -using Microsoft.DotNet.XHarness.iOS.Shared; -using Microsoft.DotNet.XHarness.iOS.Shared.Listeners; - -namespace Xharness { - - /// - /// Interface that represents the harness class that contains all the needed info to execute the tests. - /// - public interface IHarness { - - #region Properties - HarnessAction Action { get; } - IFileBackedLog HarnessLog { get; set; } - int Verbosity { get; } - HashSet Labels { get; } - XmlResultJargon XmlJargon { get; } - IResultParser ResultParser { get; } - AppBundleLocator AppBundleLocator { get; } - ITunnelBore TunnelBore { get; } - List TestProjects { get; } - bool INCLUDE_IOS { get; } - bool INCLUDE_TVOS { get; } - bool INCLUDE_MAC { get; } - bool INCLUDE_MACCATALYST { get; } - string JENKINS_RESULTS_DIRECTORY { get; } - string DOTNET_DIR { get; set; } - string DOTNET_TFM { get; } - Version DotNetVersion { get; } - string XcodeRoot { get; } - string LogDirectory { get; } - double Timeout { get; } - double LaunchTimeout { get; } // in minutes - bool DryRun { get; } // Most things don't support this. If you need it somewhere, implement it! - string JenkinsConfiguration { get; } - Dictionary EnvironmentVariables { get; } - string MarkdownSummaryPath { get; } - string PeriodicCommand { get; } - string PeriodicCommandArguments { get; } - TimeSpan PeriodicCommandInterval { get; } - bool? IncludeSystemPermissionTests { get; set; } - bool InCI { get; } - bool UseTcpTunnel { get; } - string VSDropsUri { get; } - - #endregion - - #region methods - - bool GetIncludeSystemPermissionTests (TestPlatform platform, bool device); - void Save (StringWriter doc, string path); - void Log (int minLevel, string message, params object [] args); - void Log (string message); - void Log (string message, params object [] args); - string GetDotNetExecutable (string directory); - - #endregion - } -} diff --git a/tests/xharness/Jenkins/Jenkins.cs b/tests/xharness/Jenkins/Jenkins.cs index 9a9f0e19d75c..d6def49f8554 100644 --- a/tests/xharness/Jenkins/Jenkins.cs +++ b/tests/xharness/Jenkins/Jenkins.cs @@ -17,8 +17,8 @@ using Xharness.Jenkins.TestTasks; namespace Xharness.Jenkins { - class Jenkins { - public readonly ISimulatorLoader Simulators; + public class Jenkins { + public readonly SimulatorLoader Simulators; public readonly IHardwareDeviceLoader Devices; readonly IMlaunchProcessManager processManager; public ITunnelBore TunnelBore { get; private set; } @@ -31,22 +31,30 @@ class Jenkins { // report writers, do need to be a class instance because the have state. readonly HtmlReportWriter xamarinStorageHtmlReportWriter; - readonly HtmlReportWriter vsdropsHtmlReportWriter; + readonly HtmlReportWriter? vsdropsHtmlReportWriter; readonly MarkdownReportWriter markdownReportWriter; public bool Populating { get; private set; } = true; - public IHarness Harness { get; } + public Harness Harness { get; } public bool ForceExtensionBuildOnly; public bool CleanSuccessfulTestRuns = true; public bool UninstallTestApp = true; - public IFileBackedLog MainLog; + IFileBackedLog? mainLog; + public IFileBackedLog MainLog { + get { + return mainLog!; + } + set { + mainLog = value; + } + } public ILog SimulatorLoadLog => DeviceLoader.SimulatorLoadLog; public ILog DeviceLoadLog => DeviceLoader.DeviceLoadLog; - string log_directory; + string? log_directory; public string LogDirectory { get { if (string.IsNullOrEmpty (log_directory)) { @@ -58,19 +66,19 @@ public string LogDirectory { } } - ILogs logs; + ILogs? logs; public ILogs Logs { get { return logs ?? (logs = new Logs (LogDirectory)); } } - public List Tasks { get; private set; } = new List (); + public List Tasks { get; private set; } = new List (); - public IErrorKnowledgeBase ErrorKnowledgeBase => new ErrorKnowledgeBase (); + public ErrorKnowledgeBase ErrorKnowledgeBase => new ErrorKnowledgeBase (); public IResourceManager ResourceManager => resourceManager; - public Jenkins (IHarness harness, IMlaunchProcessManager processManager, IResultParser resultParser, ITunnelBore tunnelBore) + public Jenkins (Harness harness, IMlaunchProcessManager processManager, IResultParser resultParser, ITunnelBore tunnelBore) { this.processManager = processManager ?? throw new ArgumentNullException (nameof (processManager)); this.TunnelBore = tunnelBore ?? throw new ArgumentNullException (nameof (tunnelBore)); @@ -105,7 +113,7 @@ public bool IsIncluded (TestProject project) return rv; } - public bool IsBetaXcode => Harness.XcodeRoot.IndexOf ("beta", StringComparison.OrdinalIgnoreCase) >= 0; + public bool IsBetaXcode => Harness.XcodeRoot?.IndexOf ("beta", StringComparison.OrdinalIgnoreCase) >= 0; async Task PopulateTasksAsync () { @@ -255,7 +263,7 @@ public int Run () command: Harness.PeriodicCommand, processManager: processManager, interval: Harness.PeriodicCommandInterval, - logs: logs, + logs: Logs, arguments: string.IsNullOrEmpty (Harness.PeriodicCommandArguments) ? null : Harness.PeriodicCommandArguments); periodicCommand.Execute ().DoNotAwait (); } @@ -305,7 +313,7 @@ public int Run () void CollectCrashReports () { try { - var dir = Path.Combine (Environment.GetEnvironmentVariable ("HOME"), "Library", "Logs", "DiagnosticReports"); + var dir = Path.Combine (Environment.GetEnvironmentVariable ("HOME")!, "Library", "Logs", "DiagnosticReports"); var reports = Directory.GetFiles (dir).Select (v => { (string Path, DateTime LastWriteTimeUtc) rv = (v, File.GetLastWriteTimeUtc (v)); return rv; @@ -392,7 +400,7 @@ public void GenerateReport () throw new NotImplementedException (); } - var allTasks = new List (); + var allTasks = new List (); if (!Populating) { allTasks.AddRange (allExecuteTasks); allTasks.AddRange (allSimulatorTasks); @@ -437,7 +445,7 @@ public void GenerateReport () File.Move (tmpmarkdown, Harness.MarkdownSummaryPath); } - var dependentFileLocation = Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly ().Location); + var dependentFileLocation = Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly ().Location)!; foreach (var file in new string [] { "xharness.js", "xharness.css" }) { File.Copy (Path.Combine (dependentFileLocation, file), Path.Combine (LogDirectory, file), true); } diff --git a/tests/xharness/Jenkins/JenkinsDeviceLoader.cs b/tests/xharness/Jenkins/JenkinsDeviceLoader.cs index 107b8d67c65e..538e0e1f445e 100644 --- a/tests/xharness/Jenkins/JenkinsDeviceLoader.cs +++ b/tests/xharness/Jenkins/JenkinsDeviceLoader.cs @@ -8,7 +8,7 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Utilities; namespace Xharness.Jenkins { - class JenkinsDeviceLoader { + public class JenkinsDeviceLoader { static readonly string devicesName = "Device"; static readonly string simulatorsName = "Simulator"; diff --git a/tests/xharness/Jenkins/MacTaskTestsFactory.cs b/tests/xharness/Jenkins/MacTaskTestsFactory.cs index dfc399b255d6..552f92c70ffc 100644 --- a/tests/xharness/Jenkins/MacTaskTestsFactory.cs +++ b/tests/xharness/Jenkins/MacTaskTestsFactory.cs @@ -12,9 +12,9 @@ namespace Xharness.Jenkins { class MacTestTasksFactory : TaskFactory { - readonly ICrashSnapshotReporterFactory crashReportSnapshotFactory; + readonly CrashSnapshotReporterFactory crashReportSnapshotFactory; - public MacTestTasksFactory (Jenkins jenkins, IMlaunchProcessManager processManager, TestVariationsFactory testVariationsFactory, ICrashSnapshotReporterFactory crashReportSnapshotFactory) + public MacTestTasksFactory (Jenkins jenkins, IMlaunchProcessManager processManager, TestVariationsFactory testVariationsFactory, CrashSnapshotReporterFactory crashReportSnapshotFactory) : base (jenkins, processManager, testVariationsFactory) { this.crashReportSnapshotFactory = crashReportSnapshotFactory; diff --git a/tests/xharness/Jenkins/Reports/HtmlReportWriter.cs b/tests/xharness/Jenkins/Reports/HtmlReportWriter.cs index 494d8e8dbcff..670799a45514 100644 --- a/tests/xharness/Jenkins/Reports/HtmlReportWriter.cs +++ b/tests/xharness/Jenkins/Reports/HtmlReportWriter.cs @@ -29,7 +29,7 @@ class HtmlReportWriter : IReportWriter { string? previous_test_runs; // convenient - IHarness Harness => jenkins.Harness; + Harness Harness => jenkins.Harness; public HtmlReportWriter (Jenkins jenkins, IResourceManager resourceManager, IResultParser resultParser, string? linksPrefix = null, bool embeddedResources = false) { @@ -82,7 +82,7 @@ void IncludeCss (StreamWriter writer) writer.WriteLine (""); } } - public void Write (IList allTasks, StreamWriter writer) + public void Write (IList allTasks, StreamWriter writer) { var id_counter = 0; @@ -343,7 +343,7 @@ public void Write (IList allTasks, StreamWriter writer) state = test.ExecutionResult.ToString (); var log_id = id_counter++; var logs = test.AggregatedLogs.ToList (); - string title; + string? title; if (multipleModes) { title = test.Variation ?? "Default"; } else if (singleTask) { @@ -690,11 +690,11 @@ static string LinkEncode (string path) return System.Web.HttpUtility.UrlEncode (path).Replace ("%2f", "/").Replace ("+", "%20"); } - string RenderTextStates (IEnumerable tests) + string RenderTextStates (IEnumerable tests) { // Create a collection of all non-ignored tests in the group (unless all tests were ignored). var allIgnored = tests.All ((v) => v.ExecutionResult == TestExecutingResult.Ignored); - IEnumerable relevantGroup; + IEnumerable relevantGroup; if (allIgnored) { relevantGroup = tests; } else { diff --git a/tests/xharness/Jenkins/Reports/IReportWriter.cs b/tests/xharness/Jenkins/Reports/IReportWriter.cs index 97fc23b3dd36..6f222c45d8e8 100644 --- a/tests/xharness/Jenkins/Reports/IReportWriter.cs +++ b/tests/xharness/Jenkins/Reports/IReportWriter.cs @@ -8,6 +8,6 @@ namespace Xharness.Jenkins.Reports { /// To be implemented by those classes that write reports regarding the results of the executed tasks. /// interface IReportWriter { - void Write (IList tasks, StreamWriter writer); + void Write (IList tasks, StreamWriter writer); } } diff --git a/tests/xharness/Jenkins/Reports/MarkdownReportWriter.cs b/tests/xharness/Jenkins/Reports/MarkdownReportWriter.cs index c3a9de0562a5..5db4f6c215aa 100644 --- a/tests/xharness/Jenkins/Reports/MarkdownReportWriter.cs +++ b/tests/xharness/Jenkins/Reports/MarkdownReportWriter.cs @@ -13,13 +13,13 @@ namespace Xharness.Jenkins.Reports { /// class MarkdownReportWriter : IReportWriter { - void WriteFailedTestsDetails (IEnumerable failedTests, StreamWriter writer) + void WriteFailedTestsDetails (IEnumerable failedTests, StreamWriter writer) { writer.WriteLine ("## Failed tests"); writer.WriteLine (); foreach (var group in failedTests.GroupBy ((v) => v.TestName)) { - if (group is IEnumerable enumerableGroup) { + if (group is IEnumerable enumerableGroup) { foreach (var test in enumerableGroup) { writer.Write ($" * {group.Key}"); if (!string.IsNullOrEmpty (test.Mode)) @@ -48,7 +48,7 @@ void WriteFailedTestsDetails (IEnumerable failedTests, StreamWriter w } - public void Write (IList allTasks, StreamWriter writer) + public void Write (IList allTasks, StreamWriter writer) { var failedTests = allTasks.Where ((v) => v.Failed); var deviceNotFound = allTasks.Where ((v) => v.DeviceNotFound); diff --git a/tests/xharness/Jenkins/RunSimulatorTasksFactory.cs b/tests/xharness/Jenkins/RunSimulatorTasksFactory.cs index 91f095fec843..87234db22848 100644 --- a/tests/xharness/Jenkins/RunSimulatorTasksFactory.cs +++ b/tests/xharness/Jenkins/RunSimulatorTasksFactory.cs @@ -77,7 +77,7 @@ public async override Task> CreateTasksAsync () simulators: jenkins.Simulators, buildTask: buildTask, processManager: processManager, - candidates: candidates?.Cast () ?? test.Candidates)).ToList (); + candidates: candidates?.Cast () ?? test.Candidates)).ToList (); if (jenkins.IsServerMode) return testVariations; diff --git a/tests/xharness/Jenkins/TestData.cs b/tests/xharness/Jenkins/TestData.cs index 4e240071afbd..234bfdef6535 100644 --- a/tests/xharness/Jenkins/TestData.cs +++ b/tests/xharness/Jenkins/TestData.cs @@ -5,18 +5,18 @@ namespace Xharness.Jenkins { class TestData { - public string Variation; - public KnownIssue KnownFailure; + public string? Variation; + public KnownIssue? KnownFailure; public bool Debug; - public string LinkMode; + public string? LinkMode; public bool? Ignored; public bool EnableSGenConc; public bool UseLlvm; public bool? UseMonoRuntime; - public IEnumerable Candidates; - public string RuntimeIdentifier; - public string Registrar; + public IEnumerable? Candidates; + public string? RuntimeIdentifier; + public string? Registrar; public bool PublishAot; // NativeAOT - public string TestVariation; + public string? TestVariation; } } diff --git a/tests/xharness/Jenkins/TestSelector.cs b/tests/xharness/Jenkins/TestSelector.cs index a3d82d6a7817..08c95ef312e8 100644 --- a/tests/xharness/Jenkins/TestSelector.cs +++ b/tests/xharness/Jenkins/TestSelector.cs @@ -10,7 +10,7 @@ namespace Xharness.Jenkins { - class TestSelection { + public class TestSelection { TestLabel selection = TestLabel.None | TestLabel.Msbuild | @@ -90,7 +90,7 @@ class TestSelector { readonly IVersionControlSystem vcs; ILog? MainLog => jenkins?.MainLog; - IHarness Harness => jenkins.Harness; + Harness Harness => jenkins.Harness; #endregion diff --git a/tests/xharness/Jenkins/TestServer.cs b/tests/xharness/Jenkins/TestServer.cs index 916a06c5c379..9ffc9554ac4b 100644 --- a/tests/xharness/Jenkins/TestServer.cs +++ b/tests/xharness/Jenkins/TestServer.cs @@ -45,7 +45,7 @@ public Task RunAsync (Jenkins jenkins, HtmlReportWriter htmlReportWriter) // Try and find an unused port int attemptsLeft = 50; int port = 51234; // Try this port first, to try to not vary between runs just because. - Random r = new Random ((int) DateTime.Now.Ticks); + var r = new Random ((int) DateTime.Now.Ticks); do { var newPort = port != 0 ? port : r.Next (49152, 65535); // The suggested range for dynamic ports is 49152-65535 (IANA) server = new HttpListener (); @@ -68,10 +68,10 @@ public Task RunAsync (Jenkins jenkins, HtmlReportWriter htmlReportWriter) var context = server.GetContext (); var request = context.Request; var response = context.Response; - var arguments = System.Web.HttpUtility.ParseQueryString (request.Url.Query); + var arguments = System.Web.HttpUtility.ParseQueryString (request.Url?.Query ?? ""); try { var allTasks = jenkins.Tasks.SelectMany ((v) => { - var rv = new List (); + var rv = new List (); var runsim = v as AggregatedRunSimulatorTask; if (runsim is not null) rv.AddRange (runsim.Tasks); @@ -79,9 +79,9 @@ public Task RunAsync (Jenkins jenkins, HtmlReportWriter htmlReportWriter) return rv; }); - IEnumerable find_tasks (StreamWriter writer, string ids) + IEnumerable find_tasks (StreamWriter writer, string ids) { - IEnumerable tasks; + IEnumerable tasks; switch (request.Url.Query) { case "?all": tasks = jenkins.Tasks; @@ -97,7 +97,7 @@ IEnumerable find_tasks (StreamWriter writer, string ids) return Array.Empty (); default: var id_inputs = ids.Substring (1).Split (','); - var rv = new List (id_inputs.Length); + var rv = new List (id_inputs.Length); foreach (var id_input in id_inputs) { if (int.TryParse (id_input, out var id)) { var task = jenkins.Tasks.FirstOrDefault ((t) => t.ID == id); @@ -118,9 +118,9 @@ IEnumerable find_tasks (StreamWriter writer, string ids) return tasks; } - string serveFile = null; + string? serveFile = null; // do not allow requests that are not http or https - if (request.Url.Scheme != Uri.UriSchemeHttp && request.Url.Scheme != Uri.UriSchemeHttps) { + if (request.Url?.Scheme != Uri.UriSchemeHttp && request.Url?.Scheme != Uri.UriSchemeHttps) { response.StatusCode = 400; response.StatusDescription = "Bad Request"; response.OutputStream.Write (System.Text.Encoding.UTF8.GetBytes ("Invalid local path")); @@ -128,7 +128,7 @@ IEnumerable find_tasks (StreamWriter writer, string ids) } var localPath = request.Url.LocalPath; var file = Path.GetFileName (localPath); - var directoryName = Path.GetDirectoryName (localPath); + var directoryName = Path.GetDirectoryName (localPath)!; var jenkinsDirectoryName = $"/{Path.GetFileName (jenkins.LogDirectory)}"; // for the request to be valid the local path has to be one of the following @@ -329,7 +329,7 @@ IEnumerable find_tasks (StreamWriter writer, string ids) } if (serveFile is null) { - serveFile = Path.Combine (Path.GetDirectoryName (jenkins.LogDirectory), localPath.Substring (1)); + serveFile = Path.Combine (Path.GetDirectoryName (jenkins.LogDirectory)!, localPath.Substring (1)); serveFile = Path.GetFullPath (serveFile); if (!serveFile.StartsWith (Path.GetDirectoryName (Path.GetFullPath (jenkins.LogDirectory)) + Path.DirectorySeparatorChar)) { Console.WriteLine ($"400: {localPath}"); diff --git a/tests/xharness/Jenkins/TestTasks/AppleTestTask.cs b/tests/xharness/Jenkins/TestTasks/AppleTestTask.cs index b8e47819e90f..896e9a506d18 100644 --- a/tests/xharness/Jenkins/TestTasks/AppleTestTask.cs +++ b/tests/xharness/Jenkins/TestTasks/AppleTestTask.cs @@ -6,9 +6,9 @@ #nullable enable namespace Xharness.Jenkins.TestTasks { - abstract class AppleTestTask : TestTasks { + public abstract class AppleTestTask : TestTask { public Jenkins Jenkins { get; private set; } - public IHarness Harness { get { return Jenkins.Harness; } } + public Harness Harness { get { return Jenkins.Harness; } } public override string RootDirectory => HarnessConfiguration.RootDirectory; public override IResourceManager ResourceManager => Jenkins.ResourceManager; @@ -28,7 +28,7 @@ public AppleTestTask (Jenkins jenkins) public override void GenerateReport () => Jenkins.GenerateReport (); - protected override void WriteLineToRunnerLog (string message) => Harness.HarnessLog.WriteLine (message); + protected override void WriteLineToRunnerLog (string message) => Harness.HarnessLog?.WriteLine (message); public override void SetEnvironmentVariables (Process process) { diff --git a/tests/xharness/Jenkins/TestTasks/BuildProjectTask.cs b/tests/xharness/Jenkins/TestTasks/BuildProjectTask.cs index ce21abb56c05..34e494bc3b1e 100644 --- a/tests/xharness/Jenkins/TestTasks/BuildProjectTask.cs +++ b/tests/xharness/Jenkins/TestTasks/BuildProjectTask.cs @@ -2,10 +2,10 @@ using Microsoft.DotNet.XHarness.Common.Execution; namespace Xharness.Jenkins.TestTasks { - abstract class BuildProjectTask : BuildToolTask { - BuildProject BuildProject => buildToolTask as BuildProject; + public abstract class BuildProjectTask : BuildToolTask { + BuildProject BuildProject => (BuildProject) buildToolTask; - public string SolutionPath { + public string? SolutionPath { get => BuildProject.SolutionPath; set => BuildProject.SolutionPath = value; } diff --git a/tests/xharness/Jenkins/TestTasks/BuildTool.cs b/tests/xharness/Jenkins/TestTasks/BuildTool.cs index 860e4b96ba72..e393747fc940 100644 --- a/tests/xharness/Jenkins/TestTasks/BuildTool.cs +++ b/tests/xharness/Jenkins/TestTasks/BuildTool.cs @@ -7,11 +7,11 @@ namespace Xharness.Jenkins.TestTasks { public class BuildTool { - public string TestName { get; set; } + public string TestName { get; set; } = ""; public IProcessManager ProcessManager { get; } public TestPlatform Platform { get; set; } - public TestProject TestProject { get; set; } - public IFileBackedLog BuildLog { get; set; } + public TestProject? TestProject { get; set; } + public IFileBackedLog? BuildLog { get; set; } public bool SpecifyPlatform { get; set; } = true; public bool SpecifyConfiguration { get; set; } = true; @@ -27,7 +27,7 @@ public BuildTool (IProcessManager processManager, TestPlatform platform) : this Platform = platform; } - public virtual string Mode { + public virtual string? Mode { get { return Platform.ToString (); } set { throw new NotSupportedException (); } } diff --git a/tests/xharness/Jenkins/TestTasks/BuildToolTask.cs b/tests/xharness/Jenkins/TestTasks/BuildToolTask.cs index a61b60d4a6dc..c0a98763d699 100644 --- a/tests/xharness/Jenkins/TestTasks/BuildToolTask.cs +++ b/tests/xharness/Jenkins/TestTasks/BuildToolTask.cs @@ -5,12 +5,12 @@ using Microsoft.DotNet.XHarness.Common.Logging; namespace Xharness.Jenkins.TestTasks { - abstract class BuildToolTask : AppleTestTask, IBuildToolTask { + public abstract class BuildToolTask : AppleTestTask { protected BuildTool buildToolTask; public IProcessManager ProcessManager { get; } - public IFileBackedLog BuildLog { + public IFileBackedLog? BuildLog { get => buildToolTask.BuildLog; set => buildToolTask.BuildLog = value; } @@ -37,7 +37,7 @@ public List Constants { get => buildToolTask.Constants; } - public override TestProject TestProject { + public override TestProject? TestProject { get => base.TestProject; set { base.TestProject = value; @@ -50,7 +50,7 @@ protected BuildToolTask (Jenkins jenkins, TestProject testProject, IProcessManag base.TestProject = testProject; ProcessManager = processManager ?? throw new ArgumentNullException (nameof (processManager)); InitializeTool (); - buildToolTask.TestProject = testProject; + buildToolTask!.TestProject = testProject; } public override TestPlatform Platform { @@ -61,7 +61,7 @@ public override TestPlatform Platform { } } - public override string Mode { + public override string? Mode { get => buildToolTask.Mode; set => buildToolTask.Mode = value; } diff --git a/tests/xharness/Jenkins/TestTasks/DotNetBuild.cs b/tests/xharness/Jenkins/TestTasks/DotNetBuild.cs index 17d20c21ad30..6b3dcf421a12 100644 --- a/tests/xharness/Jenkins/TestTasks/DotNetBuild.cs +++ b/tests/xharness/Jenkins/TestTasks/DotNetBuild.cs @@ -16,7 +16,7 @@ public DotNetBuild (Func msbuildPath, IErrorKnowledgeBase errorKnowledgeBase) : base (msbuildPath, processManager, resourceManager, eventLogger, envManager, errorKnowledgeBase) { } - public override List GetToolArguments (string projectPlatform, string projectConfiguration, string projectFile, IFileBackedLog buildLog) + public override List GetToolArguments (string? projectPlatform, string? projectConfiguration, string projectFile, IFileBackedLog buildLog) { var args = base.GetToolArguments (projectPlatform, projectConfiguration, projectFile, buildLog); args.Remove ("--"); diff --git a/tests/xharness/Jenkins/TestTasks/DotNetTestTask.cs b/tests/xharness/Jenkins/TestTasks/DotNetTestTask.cs index 73f81acc219c..55f11fabecd6 100644 --- a/tests/xharness/Jenkins/TestTasks/DotNetTestTask.cs +++ b/tests/xharness/Jenkins/TestTasks/DotNetTestTask.cs @@ -50,9 +50,9 @@ public override async Task RunTestAsync () args.Add (filter); } - WorkingDirectory = Path.GetDirectoryName (ProjectFile); + WorkingDirectory = Path.GetDirectoryName (ProjectFile)!; - await ExecuteProcessAsync (Jenkins.Harness.GetDotNetExecutable (Path.GetDirectoryName (ProjectFile)), args); + await ExecuteProcessAsync (Jenkins.Harness.GetDotNetExecutable (Path.GetDirectoryName (ProjectFile)!), args); try { var xmlDoc = new XmlDocument (); diff --git a/tests/xharness/Jenkins/TestTasks/IBuildToolTask.cs b/tests/xharness/Jenkins/TestTasks/IBuildToolTask.cs deleted file mode 100644 index 698884332e74..000000000000 --- a/tests/xharness/Jenkins/TestTasks/IBuildToolTask.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.DotNet.XHarness.Common.Execution; -using Microsoft.DotNet.XHarness.Common.Logging; - -namespace Xharness.Jenkins.TestTasks { - - /// - /// Interface to be implemented by those tasks that represent a build execution. - /// - public interface IBuildToolTask : ITestTask { - IFileBackedLog BuildLog { get; } - bool SpecifyPlatform { get; set; } - bool SpecifyConfiguration { get; set; } - - IProcessManager ProcessManager { get; } - TestProject TestProject { get; set; } - - Task CleanAsync (); - } -} diff --git a/tests/xharness/Jenkins/TestTasks/IRunDeviceTask.cs b/tests/xharness/Jenkins/TestTasks/IRunDeviceTask.cs deleted file mode 100644 index 22d891f389e3..000000000000 --- a/tests/xharness/Jenkins/TestTasks/IRunDeviceTask.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; -using Microsoft.DotNet.XHarness.iOS.Shared.Listeners; - -namespace Xharness.Jenkins.TestTasks { - public interface IRunDeviceTask : IRunXITask { - - ITunnelBore TunnelBore { get; } - } -} diff --git a/tests/xharness/Jenkins/TestTasks/IRunSimulatorTask.cs b/tests/xharness/Jenkins/TestTasks/IRunSimulatorTask.cs deleted file mode 100644 index 8da7fdd87997..000000000000 --- a/tests/xharness/Jenkins/TestTasks/IRunSimulatorTask.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; - -namespace Xharness.Jenkins.TestTasks { - public interface IRunSimulatorTask : IRunXITask { - - Task AcquireResourceAsync (); - } -} diff --git a/tests/xharness/Jenkins/TestTasks/IRunTestTask.cs b/tests/xharness/Jenkins/TestTasks/IRunTestTask.cs deleted file mode 100644 index 73f6163bbb77..000000000000 --- a/tests/xharness/Jenkins/TestTasks/IRunTestTask.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.DotNet.XHarness.iOS.Shared.Execution; - -namespace Xharness.Jenkins.TestTasks { - public interface IRunTestTask : ITestTask { - IHarness Harness { get; } - double TimeoutMultiplier { get; } - IMlaunchProcessManager ProcessManager { get; } - IBuildToolTask BuildTask { get; } - Task RunTestAsync (); - Task VerifyBuildAsync (); - } -} diff --git a/tests/xharness/Jenkins/TestTasks/IRunXITask.cs b/tests/xharness/Jenkins/TestTasks/IRunXITask.cs deleted file mode 100644 index f2aab4b305d9..000000000000 --- a/tests/xharness/Jenkins/TestTasks/IRunXITask.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; -using Microsoft.DotNet.XHarness.iOS.Shared; -using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; - -namespace Xharness.Jenkins.TestTasks { - public interface IRunXITask : IRunTestTask where TDevice : class, IDevice { - - AppRunner Runner { get; set; } - AppRunner AdditionalRunner { get; set; } - TestTarget AppRunnerTarget { get; set; } - IEnumerable Candidates { get; } - TDevice Device { get; set; } - } -} diff --git a/tests/xharness/Jenkins/TestTasks/ITestTask.cs b/tests/xharness/Jenkins/TestTasks/ITestTask.cs deleted file mode 100644 index 77f8d7e9ab6e..000000000000 --- a/tests/xharness/Jenkins/TestTasks/ITestTask.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading.Tasks; -using Microsoft.DotNet.XHarness.Common.Logging; -using Microsoft.DotNet.XHarness.iOS.Shared; -using Microsoft.DotNet.XHarness.iOS.Shared.Logging; - -namespace Xharness.Jenkins.TestTasks { - public interface ITestTask { - - #region Status properties - - bool NotStarted { get; } - bool Building { get; } - bool BuildSucceeded { get; } - bool BuildFailure { get; } - bool Waiting { get; } - bool InProgress { get; } - bool Running { get; } - bool Finished { get; } - bool HarnessException { get; } - bool Built { get; } - - bool Succeeded { get; } - bool Failed { get; } - bool TimedOut { get; } - bool Crashed { get; } - bool LaunchFailure { get; } - bool DeviceNotFound { get; } - - public TimeSpan WaitingDuration { get; } - - #endregion - - bool HasCustomTestName { get; } - bool BuildOnly { get; set; } - bool Ignored { get; set; } - - KnownIssue KnownFailure { get; set; } - string ProjectConfiguration { get; set; } - string ProjectPlatform { get; set; } - string ProjectFile { get; } - string Mode { get; set; } - string Variation { get; set; } - string TestName { get; } - string FailureMessage { get; set; } - string LogDirectory { get; } - - public int ID { get; } - - - TimeSpan Duration { get; } - TestPlatform Platform { get; set; } - Task InitialTask { get; set; } - TestExecutingResult ExecutionResult { get; set; } - IEnumerable AggregatedLogs { get; } - ILogs Logs { get; } - Stopwatch DurationStopWatch { get; } - string ProgressMessage { get; } - string RootDirectory { get; } - - - string GuessFailureReason (IReadableLog log); - Task RunAsync (); - Task VerifyRunAsync (); - void Reset (); - Task NotifyBlockingWaitAsync (Task task); - } -} diff --git a/tests/xharness/Jenkins/TestTasks/ITestTaskExtensions.cs b/tests/xharness/Jenkins/TestTasks/ITestTaskExtensions.cs index 51df4e73d483..1992fdc66afa 100644 --- a/tests/xharness/Jenkins/TestTasks/ITestTaskExtensions.cs +++ b/tests/xharness/Jenkins/TestTasks/ITestTaskExtensions.cs @@ -4,7 +4,7 @@ namespace Xharness.Jenkins.TestTasks { public static class ITestTaskExtensions { - public static string GetTestColor (this IEnumerable tests) + public static string GetTestColor (this IEnumerable tests) { if (!tests.Any ()) return "black"; @@ -36,7 +36,7 @@ public static string GetTestColor (this IEnumerable tests) return "black"; } - public static string GetTestColor (this ITestTask test) + public static string GetTestColor (this TestTask test) { if (test.NotStarted) { return "black"; diff --git a/tests/xharness/Jenkins/TestTasks/MSBuild.cs b/tests/xharness/Jenkins/TestTasks/MSBuild.cs index b38ff9043a16..9c91806fc2a4 100644 --- a/tests/xharness/Jenkins/TestTasks/MSBuild.cs +++ b/tests/xharness/Jenkins/TestTasks/MSBuild.cs @@ -17,7 +17,7 @@ public class MSBuild : BuildProject { readonly IErrorKnowledgeBase errorKnowledgeBase; readonly Func msbuildPath; - public virtual List GetToolArguments (string projectPlatform, string projectConfiguration, string projectFile, IFileBackedLog buildLog) + public virtual List GetToolArguments (string? projectPlatform, string? projectConfiguration, string projectFile, IFileBackedLog buildLog) { var binlogPath = buildLog.FullPath.Replace (".txt", ".binlog"); @@ -49,7 +49,7 @@ public MSBuild (Func msbuildPath, this.errorKnowledgeBase = errorKnowledgeBase ?? throw new ArgumentNullException (nameof (errorKnowledgeBase)); } - public async Task<(TestExecutingResult ExecutionResult, KnownIssue KnownFailure)> ExecuteAsync ( + public async Task<(TestExecutingResult ExecutionResult, KnownIssue? KnownFailure)> ExecuteAsync ( string projectPlatform, string projectConfiguration, string projectFile, @@ -59,7 +59,7 @@ public MSBuild (Func msbuildPath, ILog mainLog) { BuildLog = buildLog; - (TestExecutingResult ExecutionResult, KnownIssue KnownFailure) result = (TestExecutingResult.NotStarted, (KnownIssue) null); + (TestExecutingResult ExecutionResult, KnownIssue? KnownFailure) result = default; using (var xbuild = new Process ()) { xbuild.StartInfo.FileName = msbuildPath (); @@ -87,7 +87,7 @@ public MSBuild (Func msbuildPath, return result; } - async Task CleanProjectAsync (string project_file, string project_platform, string project_configuration, ILog log, ILog mainLog) + async Task CleanProjectAsync (string project_file, string? project_platform, string? project_configuration, ILog log, ILog mainLog) { // Don't require the desktop resource here, this shouldn't be that resource sensitive using (var xbuild = new Process ()) { diff --git a/tests/xharness/Jenkins/TestTasks/MSBuildTask.cs b/tests/xharness/Jenkins/TestTasks/MSBuildTask.cs index a4c3008f1186..eb1edff9fcc4 100644 --- a/tests/xharness/Jenkins/TestTasks/MSBuildTask.cs +++ b/tests/xharness/Jenkins/TestTasks/MSBuildTask.cs @@ -6,10 +6,10 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Logging; namespace Xharness.Jenkins.TestTasks { - class MSBuildTask : BuildProjectTask { + public class MSBuildTask : BuildProjectTask { protected virtual string ToolName { get { - return Jenkins.Harness.GetDotNetExecutable (Path.GetDirectoryName (ProjectFile)); + return Jenkins.Harness.GetDotNetExecutable (Path.GetDirectoryName (ProjectFile)!); } } @@ -26,9 +26,9 @@ public override void SetEnvironmentVariables (Process process) } protected virtual List ToolArguments => - MSBuild.GetToolArguments (ProjectPlatform, ProjectConfiguration, ProjectFile, BuildLog); + MSBuild.GetToolArguments (ProjectPlatform, ProjectConfiguration, ProjectFile, BuildLog!); - MSBuild MSBuild => buildToolTask as MSBuild; + MSBuild MSBuild => (MSBuild) buildToolTask; public MSBuildTask (Jenkins jenkins, TestProject testProject, IProcessManager processManager) : base (jenkins, testProject, processManager) { } @@ -49,8 +49,8 @@ protected override async Task ExecuteAsync () using var resource = await NotifyAndAcquireDesktopResourceAsync (); BuildLog = Logs.Create ($"build-{Platform}-{Timestamp}.txt", LogType.BuildLog.ToString ()); (ExecutionResult, KnownFailure) = await MSBuild.ExecuteAsync ( - projectPlatform: ProjectPlatform, - projectConfiguration: ProjectConfiguration, + projectPlatform: ProjectPlatform!, + projectConfiguration: ProjectConfiguration!, projectFile: ProjectFile, resource: resource, dryRun: Jenkins.Harness.DryRun, @@ -62,13 +62,13 @@ protected override async Task ExecuteAsync () public override Task CleanAsync () => MSBuild.CleanAsync ( - projectPlatform: ProjectPlatform, - projectConfiguration: ProjectConfiguration, + projectPlatform: ProjectPlatform!, + projectConfiguration: ProjectConfiguration!, projectFile: ProjectFile, cleanLog: Logs.Create ($"clean-{Platform}-{Timestamp}.txt", "Clean log"), mainLog: Jenkins.MainLog); - public static void SetDotNetEnvironmentVariables (Dictionary environment) + public static void SetDotNetEnvironmentVariables (Dictionary environment) { environment ["MSBUILD_EXE_PATH"] = null; environment ["MSBuildExtensionsPathFallbackPathsOverride"] = null; diff --git a/tests/xharness/Jenkins/TestTasks/MacExecuteTask.cs b/tests/xharness/Jenkins/TestTasks/MacExecuteTask.cs index be8c515719ef..6b43a0205eba 100644 --- a/tests/xharness/Jenkins/TestTasks/MacExecuteTask.cs +++ b/tests/xharness/Jenkins/TestTasks/MacExecuteTask.cs @@ -14,12 +14,12 @@ namespace Xharness.Jenkins.TestTasks { class MacExecuteTask : MacTask { - protected ICrashSnapshotReporterFactory CrashReportSnapshotFactory { get; } + protected CrashSnapshotReporterFactory CrashReportSnapshotFactory { get; } - public string Path; + public string? Path; public bool IsUnitTest; - public MacExecuteTask (Jenkins jenkins, BuildToolTask build_task, IMlaunchProcessManager processManager, ICrashSnapshotReporterFactory crashReportSnapshotFactory) + public MacExecuteTask (Jenkins jenkins, BuildToolTask build_task, IMlaunchProcessManager processManager, CrashSnapshotReporterFactory crashReportSnapshotFactory) : base (jenkins, build_task, processManager) { this.CrashReportSnapshotFactory = crashReportSnapshotFactory ?? throw new ArgumentNullException (nameof (crashReportSnapshotFactory)); @@ -45,20 +45,20 @@ public override async Task RunTestAsync () name = System.IO.Path.GetFileName (System.IO.Path.GetDirectoryName (projectDir)); var suffix = string.Empty; if (ProjectFile.EndsWith (".slnx", StringComparison.Ordinal)) { - Path = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (ProjectFile), "bin", BuildTask.ProjectPlatform, BuildTask.ProjectConfiguration + suffix, name + ".app", "Contents", "MacOS", name); + Path = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (ProjectFile)!, "bin", BuildTask.ProjectPlatform!, BuildTask.ProjectConfiguration + suffix, name + ".app", "Contents", "MacOS", name!); } else { var project = new XmlDocument (); project.LoadWithoutNetworkAccess (ProjectFile); - var outputPath = await Harness.AppBundleLocator.LocateAppBundle (project, ProjectFile, TestTarget.None, BuildTask.ProjectConfiguration); + var outputPath = await Harness.AppBundleLocator.LocateAppBundle (project, ProjectFile, TestTarget.None, BuildTask.ProjectConfiguration!); var assemblyName = project.GetAssemblyName (); - Path = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (ProjectFile), outputPath, assemblyName + ".app", "Contents", "MacOS", assemblyName); + Path = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (ProjectFile)!, outputPath!, assemblyName + ".app", "Contents", "MacOS", assemblyName); } using (var resource = await NotifyAndAcquireDesktopResourceAsync ()) { using (var proc = new Process ()) { proc.StartInfo.FileName = Path; var arguments = new List (); - IFileBackedLog xmlLog = null; + IFileBackedLog? xmlLog = null; var useXmlOutput = Harness.InCI || true; if (IsUnitTest) { var extension = useXmlOutput ? "xml" : "log"; @@ -88,14 +88,14 @@ public override async Task RunTestAsync () proc.StartInfo.Arguments = StringUtils.FormatArguments (arguments); Jenkins.MainLog.WriteLine ("Executing {0} ({1})", TestName, Mode); var log = Logs.Create ($"execute-{Platform}-{Timestamp}.txt", LogType.ExecutionLog.ToString ()); - ICrashSnapshotReporter snapshot = null; + ICrashSnapshotReporter? snapshot = null; if (!Jenkins.Harness.DryRun) { ExecutionResult = TestExecutingResult.Running; snapshot = CrashReportSnapshotFactory.Create (log, Logs, isDevice: false, deviceName: null); await snapshot.StartCaptureAsync (); - ProcessExecutionResult result = null; + ProcessExecutionResult? result = null; try { var timeout = TimeSpan.FromMinutes (20); @@ -119,8 +119,8 @@ public override async Task RunTestAsync () if (IsUnitTest) { var reporterFactory = new TestReporterFactory (ProcessManager); - var listener = new Microsoft.DotNet.XHarness.iOS.Shared.Listeners.SimpleFileListener (xmlLog.FullPath, log, xmlLog, useXmlOutput); - var reporter = reporterFactory.Create (Harness.HarnessLog, log, Logs, snapshot, listener, Harness.ResultParser, new AppBundleInformation ("N/A", "N/A", "N/A", "N/A", true, null), RunMode.MacOS, Harness.XmlJargon, "no device here", TimeSpan.Zero); + var listener = new Microsoft.DotNet.XHarness.iOS.Shared.Listeners.SimpleFileListener (xmlLog!.FullPath, log, xmlLog, useXmlOutput); + var reporter = reporterFactory.Create (Harness.HarnessLog!, log, Logs, snapshot!, listener, Harness.ResultParser, new AppBundleInformation ("N/A", "N/A", "N/A", "N/A", true, null), RunMode.MacOS, Harness.XmlJargon, "no device here", TimeSpan.Zero); var rv = await reporter.ParseResult (); if (ExecutionResult == TestExecutingResult.Succeeded) { diff --git a/tests/xharness/Jenkins/TestTasks/MacTask.cs b/tests/xharness/Jenkins/TestTasks/MacTask.cs index 510fa15564d1..b426712da750 100644 --- a/tests/xharness/Jenkins/TestTasks/MacTask.cs +++ b/tests/xharness/Jenkins/TestTasks/MacTask.cs @@ -8,7 +8,7 @@ public MacTask (Jenkins jenkins, BuildToolTask build_task, IMlaunchProcessManage { } - public override string Mode { + public override string? Mode { get { switch (Platform) { case TestPlatform.Mac: diff --git a/tests/xharness/Jenkins/TestTasks/Resource.cs b/tests/xharness/Jenkins/TestTasks/Resource.cs index 289d8d5c8db5..9b95123d9030 100644 --- a/tests/xharness/Jenkins/TestTasks/Resource.cs +++ b/tests/xharness/Jenkins/TestTasks/Resource.cs @@ -21,7 +21,7 @@ public class Resource { public int QueuedUsers => queue.Count + exclusive_queue.Count; public int MaxConcurrentUsers { get; set; } = 1; - public Resource (string name, int max_concurrent_users = 1, string description = null) + public Resource (string name, int max_concurrent_users = 1, string? description = null) { this.Name = name; this.MaxConcurrentUsers = max_concurrent_users; @@ -62,13 +62,13 @@ void Release () lock (queue) { Users--; exclusive = false; - if (queue.TryDequeue (out TaskCompletionSource tcs)) { + if (queue.TryDequeue (out var tcs)) { Users++; - tcs.SetResult ((IAcquiredResource) tcs.Task.AsyncState); + tcs.SetResult ((IAcquiredResource) tcs.Task.AsyncState!); } else if (Users == 0 && exclusive_queue.TryDequeue (out tcs)) { Users++; exclusive = true; - tcs.SetResult ((IAcquiredResource) tcs.Task.AsyncState); + tcs.SetResult ((IAcquiredResource) tcs.Task.AsyncState!); } } } diff --git a/tests/xharness/Jenkins/TestTasks/RunDevice.cs b/tests/xharness/Jenkins/TestTasks/RunDevice.cs index fcbf1ed59b38..0fb0d644ce53 100644 --- a/tests/xharness/Jenkins/TestTasks/RunDevice.cs +++ b/tests/xharness/Jenkins/TestTasks/RunDevice.cs @@ -11,7 +11,7 @@ namespace Xharness.Jenkins.TestTasks { public class RunDevice { - readonly IRunDeviceTask testTask; + readonly RunDeviceTask testTask; readonly IHardwareDeviceLoader devices; readonly IResultParser resultParser = new XmlResultParser (); readonly IResourceManager resourceManager; @@ -26,9 +26,9 @@ public class RunDevice { readonly XmlResultJargon xmlResultJargon; readonly IErrorKnowledgeBase errorKnowledgeBase; - public AppInstallMonitorLog InstallLog { get; private set; } + public AppInstallMonitorLog? InstallLog { get; private set; } - public RunDevice (IRunDeviceTask testTask, + public RunDevice (RunDeviceTask testTask, IHardwareDeviceLoader devices, IResourceManager resourceManager, ILog mainLog, @@ -77,7 +77,7 @@ public async Task RunTestAsync () testTask.Device = testTask.Candidates.First ((d) => d.UDID == device_resource.Resource.Name); mainLog.WriteLine ("Acquired device '{0}' for '{1}'", testTask.Device.Name, testTask.ProjectFile); - ITunnelBore tunnelBore = null; + ITunnelBore? tunnelBore = null; if (useTcpTunnel && testTask.Device.DevicePlatform != DevicePlatform.iOS && testTask.Device.DevicePlatform != DevicePlatform.tvOS) { mainLog.WriteLine ("Ignoring request to use a tunnel because it is not supported by the specified platform"); @@ -163,7 +163,7 @@ public async Task RunTestAsync () } finally { // Uninstall again, so that we don't leave junk behind and fill up the device. if (uninstallTestApp) { - testTask.Runner.MainLog = uninstall_log; + testTask.Runner!.MainLog = uninstall_log; var uninstall_result = await testTask.Runner.UninstallAsync (); if (!uninstall_result.Succeeded) mainLog.WriteLine ($"Post-run uninstall failed, exit code: {uninstall_result.ExitCode} (this won't affect the test result)"); diff --git a/tests/xharness/Jenkins/TestTasks/RunDeviceTask.cs b/tests/xharness/Jenkins/TestTasks/RunDeviceTask.cs index 19788fbefd1c..c019be39cffe 100644 --- a/tests/xharness/Jenkins/TestTasks/RunDeviceTask.cs +++ b/tests/xharness/Jenkins/TestTasks/RunDeviceTask.cs @@ -8,11 +8,11 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Listeners; namespace Xharness.Jenkins.TestTasks { - class RunDeviceTask : RunXITask, IRunDeviceTask { + public class RunDeviceTask : RunXITask { public ITunnelBore TunnelBore { get; private set; } RunDevice runDevice; - public override string ProgressMessage { + public override string? ProgressMessage { get { var log = runDevice.InstallLog; if (log is null) diff --git a/tests/xharness/Jenkins/TestTasks/RunSimulator.cs b/tests/xharness/Jenkins/TestTasks/RunSimulator.cs index ca5eb393c47f..e94c372e0534 100644 --- a/tests/xharness/Jenkins/TestTasks/RunSimulator.cs +++ b/tests/xharness/Jenkins/TestTasks/RunSimulator.cs @@ -15,8 +15,8 @@ public class RunSimulator { readonly ILog mainLog; readonly ILog simulatorLoadLog; - readonly ISimulatorLoader simulators; - readonly IRunSimulatorTask testTask; + readonly SimulatorLoader simulators; + readonly RunSimulatorTask testTask; readonly IErrorKnowledgeBase errorKnowledgeBase; public IEnumerable Simulators { @@ -29,9 +29,9 @@ public IEnumerable Simulators { } } - public RunSimulator (IRunSimulatorTask testTask, - ISimulatorLoader simulators, - IErrorKnowledgeBase errorKnowledgeBase, + public RunSimulator (RunSimulatorTask testTask, + SimulatorLoader simulators, + ErrorKnowledgeBase errorKnowledgeBase, ILog mainLog, ILog simulatorLoadLog) { @@ -95,7 +95,7 @@ public async Task SelectSimulatorAsync () new TestReporterFactory (testTask.ProcessManager), testTask.AppRunnerTarget, testTask.Harness, - mainLog: testTask.Logs.Create ($"run-{testTask.Device.UDID}-{Harness.Helpers.Timestamp}.log", "Run log"), + mainLog: testTask.Logs.Create ($"run-{testTask.Device!.UDID}-{Harness.Helpers.Timestamp}.log", "Run log"), logs: testTask.Logs, projectFilePath: testTask.ProjectFile, ensureCleanSimulatorState: clean_state, @@ -120,7 +120,7 @@ public async Task RunTestAsync () using (var resource = await testTask.NotifyBlockingWaitAsync (testTask.AcquireResourceAsync ())) { if (testTask.Runner is null) await SelectSimulatorAsync (); - await testTask.Runner.RunAsync (); + await testTask.Runner!.RunAsync (); } testTask.ExecutionResult = testTask.Runner.Result; diff --git a/tests/xharness/Jenkins/TestTasks/RunSimulatorTask.cs b/tests/xharness/Jenkins/TestTasks/RunSimulatorTask.cs index 2b7353c04113..ff2ab887243f 100644 --- a/tests/xharness/Jenkins/TestTasks/RunSimulatorTask.cs +++ b/tests/xharness/Jenkins/TestTasks/RunSimulatorTask.cs @@ -4,14 +4,14 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; namespace Xharness.Jenkins.TestTasks { - class RunSimulatorTask : RunXITask, IRunSimulatorTask { + public class RunSimulatorTask : RunXITask { readonly RunSimulator runSimulator; - public IAcquiredResource AcquiredResource; + public IAcquiredResource? AcquiredResource; public IEnumerable Simulators => runSimulator.Simulators; - public RunSimulatorTask (Jenkins jenkins, ISimulatorLoader simulators, MSBuildTask buildTask, IMlaunchProcessManager processManager, IEnumerable candidates = null) - : base (jenkins, buildTask, processManager, candidates) => runSimulator = new RunSimulator ( + public RunSimulatorTask (Jenkins jenkins, SimulatorLoader simulators, MSBuildTask buildTask, IMlaunchProcessManager processManager, IEnumerable? candidates = null) + : base (jenkins, buildTask, processManager, candidates ?? []) => runSimulator = new RunSimulator ( testTask: this, simulators: simulators, errorKnowledgeBase: Jenkins.ErrorKnowledgeBase, @@ -41,11 +41,11 @@ protected override string XIMode { } class NondisposedResource : IAcquiredResource { - public IAcquiredResource Wrapped; + public IAcquiredResource? Wrapped; public Resource Resource { get { - return Wrapped.Resource; + return Wrapped!.Resource; } } diff --git a/tests/xharness/Jenkins/TestTasks/RunTest.cs b/tests/xharness/Jenkins/TestTasks/RunTest.cs index de7ed8f96490..46af2d0be5fd 100644 --- a/tests/xharness/Jenkins/TestTasks/RunTest.cs +++ b/tests/xharness/Jenkins/TestTasks/RunTest.cs @@ -14,10 +14,10 @@ namespace Xharness.Jenkins.TestTasks { public class RunTest { public IMlaunchProcessManager ProcessManager { get; private set; } - public IBuildToolTask BuildTask { get; private set; } + public BuildToolTask BuildTask { get; private set; } IResultParser ResultParser { get; } = new XmlResultParser (); - readonly IRunTestTask testTask; + readonly RunTestTask testTask; readonly IEnvManager envManager; readonly ILog mainLog; readonly bool generateXmlFailures; @@ -26,10 +26,10 @@ public class RunTest { public TimeSpan Timeout { get; set; } = TimeSpan.FromMinutes (10); public double TimeoutMultiplier { get; set; } = 1; - public string WorkingDirectory; + public string? WorkingDirectory; - public RunTest (IRunTestTask testTask, - IBuildToolTask buildTask, + public RunTest (RunTestTask testTask, + BuildToolTask buildTask, IMlaunchProcessManager processManager, IEnvManager envManager, ILog mainLog, diff --git a/tests/xharness/Jenkins/TestTasks/RunTestTask.cs b/tests/xharness/Jenkins/TestTasks/RunTestTask.cs index 0f02dc4d4bce..5d8500feaf25 100644 --- a/tests/xharness/Jenkins/TestTasks/RunTestTask.cs +++ b/tests/xharness/Jenkins/TestTasks/RunTestTask.cs @@ -8,17 +8,17 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Logging; namespace Xharness.Jenkins.TestTasks { - internal abstract class RunTestTask : AppleTestTask, IRunTestTask { + public abstract class RunTestTask : AppleTestTask { protected RunTest runTest; public IMlaunchProcessManager ProcessManager => runTest.ProcessManager; - public IBuildToolTask BuildTask => runTest.BuildTask; + public BuildToolTask BuildTask => runTest.BuildTask; public double TimeoutMultiplier { get => runTest.TimeoutMultiplier; set => runTest.TimeoutMultiplier = value; } - public string WorkingDirectory { + public string? WorkingDirectory { get => runTest.WorkingDirectory; set => runTest.WorkingDirectory = value; } @@ -28,7 +28,7 @@ public TimeSpan Timeout { set => runTest.Timeout = value; } - public RunTestTask (Jenkins jenkins, IBuildToolTask build_task, IMlaunchProcessManager processManager) : base (jenkins) + public RunTestTask (Jenkins jenkins, BuildToolTask build_task, IMlaunchProcessManager processManager) : base (jenkins) { runTest = new RunTest ( testTask: this, @@ -98,7 +98,7 @@ protected Task ExecuteProcessAsync (string filename, List arguments) return ExecuteProcessAsync (null, filename, arguments); } - protected Task ExecuteProcessAsync (ILog log, string filename, List arguments) + protected Task ExecuteProcessAsync (ILog? log, string filename, List arguments) { if (log is null) log = Logs.Create ($"execute-{Timestamp}.txt", LogType.ExecutionLog.ToString ()); diff --git a/tests/xharness/Jenkins/TestTasks/RunXITask.cs b/tests/xharness/Jenkins/TestTasks/RunXITask.cs index 24e1f513d10f..463e24b06291 100644 --- a/tests/xharness/Jenkins/TestTasks/RunXITask.cs +++ b/tests/xharness/Jenkins/TestTasks/RunXITask.cs @@ -9,19 +9,17 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; namespace Xharness.Jenkins.TestTasks { - abstract class RunXITask : RunTestTask where TDevice : class, IDevice { + public abstract class RunXITask : RunTestTask where TDevice : class, IDevice { public TestTarget AppRunnerTarget { get; set; } - public AppRunner Runner { get; set; } - public AppRunner AdditionalRunner { get; set; } + public AppRunner? Runner { get; set; } + public AppRunner? AdditionalRunner { get; set; } public IEnumerable Candidates { get; } - public TDevice Device { get; set; } + public TDevice? Device { get; set; } - public TDevice CompanionDevice { get; set; } - - public string BundleIdentifier => Runner.AppInformation.BundleIdentifier; + public string BundleIdentifier => Runner?.AppInformation.BundleIdentifier ?? string.Empty; public RunXITask (Jenkins jenkins, BuildToolTask build_task, IMlaunchProcessManager processManager, IEnumerable candidates) : base (jenkins, build_task, processManager) @@ -40,7 +38,7 @@ public override IEnumerable AggregatedLogs { } } - public override string Mode { + public override string? Mode { get { switch (Platform) { @@ -65,7 +63,7 @@ public override async Task VerifyRunAsync () var asyncEnumerable = enumerable as IAsyncEnumerable; if (asyncEnumerable is not null) await asyncEnumerable.ReadyTask; - if (!enumerable.Any ()) { + if (enumerable is null || !enumerable.Any ()) { ExecutionResult = TestExecutingResult.DeviceNotFound; FailureMessage = "No applicable devices found."; } diff --git a/tests/xharness/Jenkins/TestTasks/TestTask.cs b/tests/xharness/Jenkins/TestTasks/TestTask.cs index 014c0045b43b..0528e50e8a3a 100644 --- a/tests/xharness/Jenkins/TestTasks/TestTask.cs +++ b/tests/xharness/Jenkins/TestTasks/TestTask.cs @@ -13,26 +13,26 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Utilities; namespace Xharness.Jenkins.TestTasks { - public abstract class TestTasks : IEnvManager, IEventLogger, ITestTask { + public abstract class TestTask : IEnvManager, IEventLogger { static int counter; - static DriveInfo rootDrive; + static DriveInfo? rootDrive; protected readonly Stopwatch waitingDuration = new (); #region Private vars - ILog testLog; + ILog? testLog; bool? supportsParallelExecution; - string testName; - Task executeTask; + string? testName; + Task? executeTask; #endregion #region Public vars - public Dictionary Environment = new (); - public Task InitialTask { get; set; } // a task that's executed before this task's ExecuteAsync method. - public Task CompletedTask; // a task that's executed after this task's ExecuteAsync method. + public Dictionary Environment = new (); + public Task? InitialTask { get; set; } // a task that's executed before this task's ExecuteAsync method. + public Task? CompletedTask; // a task that's executed after this task's ExecuteAsync method. public List Resources = new (); #endregion @@ -41,12 +41,12 @@ public abstract class TestTasks : IEnvManager, IEventLogger, ITestTask { public int ID { get; private set; } public bool BuildOnly { get; set; } - public KnownIssue KnownFailure { get; set; } - public string ProjectConfiguration { get; set; } - public string ProjectPlatform { get; set; } + public KnownIssue? KnownFailure { get; set; } + public string? ProjectConfiguration { get; set; } + public string? ProjectPlatform { get; set; } protected static string Timestamp => Harness.Helpers.Timestamp; - public string ProjectFile => TestProject?.Path; + public string ProjectFile => TestProject?.Path ?? ""; public bool HasCustomTestName => testName is not null; public bool NotStarted => (ExecutionResult & TestExecutingResult.StateMask) == TestExecutingResult.NotStarted; @@ -80,19 +80,19 @@ public bool Ignored { public Stopwatch DurationStopWatch { get; } = new (); public TimeSpan Duration => DurationStopWatch.Elapsed; - string failureMessage; - public string FailureMessage { + string? failureMessage; + public string? FailureMessage { get { return failureMessage; } set { failureMessage = value; - MainLog.WriteLine (failureMessage); + MainLog.WriteLine (failureMessage ?? ""); } } public ILog MainLog => testLog ??= Logs.Create ($"main-{Timestamp}.log", "Main log"); - ILogs logs; + ILogs? logs; public ILogs Logs => logs ??= new Logs (LogDirectory); #endregion @@ -112,11 +112,11 @@ public ILog MainLog #region Virtual - public virtual TestProject TestProject { get; set; } + public virtual TestProject? TestProject { get; set; } public virtual TestPlatform Platform { get; set; } - public virtual string ProgressMessage { get; } - public virtual string Mode { get; set; } - public virtual string Variation { get; set; } + public virtual string? ProgressMessage { get; } + public virtual string? Mode { get; set; } + public virtual string? Variation { get; set; } public virtual bool SupportsParallelExecution { get => supportsParallelExecution ?? true; @@ -174,7 +174,7 @@ public virtual void Reset () #endregion - public TestTasks () + public TestTask () { ID = Interlocked.Increment (ref counter); } @@ -265,7 +265,7 @@ public override string ToString () protected void AddCILogFiles (StreamReader stream) { - string line; + string? line; while ((line = stream.ReadLine ()) is not null) { if (!line.StartsWith ("@MonkeyWrench: ", StringComparison.Ordinal)) continue; @@ -287,11 +287,11 @@ protected void AddCILogFiles (StreamReader stream) } } - public string GuessFailureReason (IReadableLog log) + public string? GuessFailureReason (IReadableLog log) { try { using (var reader = log.GetReader ()) { - string line; + string? line; var error_msg = new System.Text.RegularExpressions.Regex ("([A-Z][A-Z][0-9][0-9][0-9][0-9]:.*)"); while ((line = reader.ReadLine ()) is not null) { var match = error_msg.Match (line); @@ -310,7 +310,9 @@ public string GuessFailureReason (IReadableLog log) // It will also pause the duration. public async Task NotifyBlockingWaitAsync (Task task) { - var rv = new BlockingWait (); + var rv = new BlockingWait () { + OnDispose = DurationStopWatch.Stop, + }; // Stop the timer while we're waiting for a resource DurationStopWatch.Stop (); @@ -320,20 +322,19 @@ public async Task NotifyBlockingWaitAsync (Task CreateTestVariations (IEnumerable tests, Func, T> creator) where T : RunTestTask; - } - - class TestVariationsFactory : ITestVariationsFactory { + class TestVariationsFactory { readonly Jenkins jenkins; readonly IProcessManager processManager; @@ -30,7 +26,7 @@ IEnumerable GetTestData (RunTestTask test) // This function returns additional test configurations (in addition to the default one) for the specific test var supports_interpreter = test.Platform != TestPlatform.Mac; - var ignore = test.TestProject.Ignore; + var ignore = test.TestProject!.Ignore; var mac_supports_arm64 = Harness.CanRunArm64; var arm64_runtime_identifier = string.Empty; var x64_runtime_identifier = string.Empty; @@ -73,7 +69,7 @@ IEnumerable GetTestData (RunTestTask test) switch (test.ProjectPlatform) { case "iPhone": - if (test.ProjectConfiguration.Contains ("Debug")) + if (test.ProjectConfiguration?.Contains ("Debug") == true) yield return new TestData { Variation = "Release", Debug = false }; switch (test.TestName) { @@ -160,18 +156,18 @@ IEnumerable GetTestData (RunTestTask test) } } - public IEnumerable CreateTestVariations (IEnumerable tests, Func, T> creator) where T : RunTestTask + public IEnumerable CreateTestVariations (IEnumerable tests, Func?, T> creator) where T : RunTestTask { foreach (var task in tests) { if (string.IsNullOrEmpty (task.Variation)) - task.Variation = task.ProjectConfiguration.Contains ("Debug") ? "Debug" : "Release"; + task.Variation = task.ProjectConfiguration?.Contains ("Debug") == true ? "Debug" : "Release"; } var rv = new List (tests); foreach (var task in tests.ToArray ()) { foreach (var test_data in GetTestData (task)) { var variation = test_data.Variation; - var configuration = test_data.Debug ? task.ProjectConfiguration : task.ProjectConfiguration.Replace ("Debug", "Release"); + var configuration = test_data.Debug ? task.ProjectConfiguration : task.ProjectConfiguration?.Replace ("Debug", "Release"); var debug = test_data.Debug; var link_mode = test_data.LinkMode; var ignored = test_data.Ignored; @@ -187,9 +183,9 @@ public IEnumerable CreateTestVariations (IEnumerable tests, Func { - await task.BuildTask.InitialTask; // this is the project cloning above + await task.BuildTask.InitialTask!; // this is the project cloning above await clone.CreateCopyAsync (jenkins.MainLog, processManager, task, HarnessConfiguration.RootDirectory); var isMac = task.Platform.IsMac (); @@ -230,7 +226,7 @@ public IEnumerable CreateTestVariations (IEnumerable tests, Func showHelp () }, + { "h|?|help", "Displays the help", (v) => showHelp!.Invoke () }, { "v|verbose", "Show verbose output", (v) => configuration.Verbosity++ }, { "use-system:", "Use the system version of Xamarin.iOS/Xamarin.Mac or the locally build version. Default: the locally build version.", (v) => configuration.UseSystemXamarinIOSMac = v == "1" || v == "true" || string.IsNullOrEmpty (v) }, { "rootdir=", "The root directory for the tests.", (v) => HarnessConfiguration.RootDirectory = v }, diff --git a/tests/xharness/TestPlatformExtensions.cs b/tests/xharness/TestPlatformExtensions.cs index 6deb5d3042a0..187db3b85ad6 100644 --- a/tests/xharness/TestPlatformExtensions.cs +++ b/tests/xharness/TestPlatformExtensions.cs @@ -27,7 +27,7 @@ public static bool IsMac (this TestPlatform platform) } // This must match our $(_PlatformName) variable in our MSBuild logic. - public static string ToPlatformName (this TestPlatform platform) + public static string? ToPlatformName (this TestPlatform platform) { switch (platform) { case TestPlatform.iOS: diff --git a/tests/xharness/TestProject.cs b/tests/xharness/TestProject.cs index fb40da8a461d..3aef099deeef 100644 --- a/tests/xharness/TestProject.cs +++ b/tests/xharness/TestProject.cs @@ -22,7 +22,7 @@ public class TestProject { public TestPlatform TestPlatform; public TestLabel Label; public string Path; - public string? Name; + public string Name = ""; public bool IsExecutableProject; public string []? Configurations; public string? FailureMessage; @@ -80,13 +80,13 @@ protected virtual TestProject CompleteClone (TestProject rv) return rv; } - public Task CreateCopyAsync (ILog log, IProcessManager processManager, ITestTask test, string rootDirectory) + public Task CreateCopyAsync (ILog log, IProcessManager processManager, TestTask test, string rootDirectory) { var pr = new Dictionary (); return CreateCopyAsync (log, processManager, test, rootDirectory, pr); } - async Task CreateCopyAsync (ILog log, IProcessManager processManager, ITestTask test, string rootDirectory, Dictionary allProjectReferences) + async Task CreateCopyAsync (ILog log, IProcessManager processManager, TestTask test, string rootDirectory, Dictionary allProjectReferences) { var directory = Cache.CreateTemporaryDirectory (test.TestName ?? System.IO.Path.GetFileNameWithoutExtension (Path)); Directory.CreateDirectory (directory); @@ -220,7 +220,7 @@ void InlineSharedImports (XmlDocument doc, string original_path, Dictionary GetPidFromRunLog () if (!listener.ConnectedTask.IsCompletedSuccessfully || !listener.ConnectedTask.Result) launchFailure = true; } else { - string line; + string? line; while ((line = await reader.ReadLineAsync ()) is not null) { if (line.StartsWith ("Application launched. PID = ", StringComparison.Ordinal)) { var pidstr = line.Substring ("Application launched. PID = ".Length); @@ -136,7 +136,7 @@ async Task GetPidFromMainLog () { int pid = -1; using var logReader = mainLog.GetReader (); - string line; + string? line; while ((line = await logReader.ReadLineAsync ()) is not null) { const string str = "was launched with pid '"; var idx = line.IndexOf (str, StringComparison.Ordinal); @@ -152,7 +152,7 @@ async Task GetPidFromMainLog () return pid; } - void GetCrashReason (int pid, IReadableLog crashLog, out string crashReason) + void GetCrashReason (int pid, IReadableLog crashLog, out string? crashReason) { crashReason = null; using var crashReader = crashLog.GetReader (); @@ -161,7 +161,7 @@ void GetCrashReason (int pid, IReadableLog crashLog, out string crashReason) var reader = JsonReaderWriterFactory.CreateJsonReader (Encoding.UTF8.GetBytes (text), new XmlDictionaryReaderQuotas ()); var doc = new XmlDocument (); doc.Load (reader); - foreach (XmlNode node in doc.SelectNodes ($"/root/processes/item[pid = '" + pid + "']")) { + foreach (XmlNode node in doc.SelectNodes ($"/root/processes/item[pid = '" + pid + "']")!) { Console.WriteLine (node?.InnerXml); Console.WriteLine (node?.SelectSingleNode ("reason")?.InnerText); crashReason = node?.SelectSingleNode ("reason")?.InnerText; @@ -171,7 +171,7 @@ void GetCrashReason (int pid, IReadableLog crashLog, out string crashReason) async Task TcpConnectionFailed () { using var reader = new StreamReader (mainLog.FullPath); - string line; + string? line; while ((line = await reader.ReadLineAsync ()) is not null) { if (line.Contains ("Couldn't establish a TCP connection with any of the hostnames")) return true; @@ -257,12 +257,12 @@ public async Task CollectDeviceResult (ProcessExecutionResult runResult) await CollectResult (runResult); } - async Task<(string ResultLine, bool Failed)> GetResultLine (string logPath) + async Task<(string? ResultLine, bool Failed)> GetResultLine (string logPath) { - string resultLine = null; + string? resultLine = null; bool failed = false; using var reader = new StreamReader (logPath); - string line; + string? line; while ((line = await reader.ReadLineAsync ()) is not null) { if (line.Contains ("Tests run:")) { Console.WriteLine (line); @@ -276,9 +276,9 @@ public async Task CollectDeviceResult (ProcessExecutionResult runResult) return (ResultLine: resultLine, Failed: failed); } - async Task<(string resultLine, bool failed, bool crashed)> ParseResultFile (AppBundleInformation appInfo, string testLogPath, bool timedOut) + async Task<(string? resultLine, bool failed, bool crashed)> ParseResultFile (AppBundleInformation appInfo, string testLogPath, bool timedOut) { - (string resultLine, bool failed, bool crashed) parseResult = (null, false, false); + (string? resultLine, bool failed, bool crashed) parseResult = (null, false, false); if (!File.Exists (testLogPath)) { parseResult.crashed = true; return parseResult; @@ -286,7 +286,7 @@ public async Task CollectDeviceResult (ProcessExecutionResult runResult) var path = Path.ChangeExtension (testLogPath, "xml"); if (path == testLogPath) - path = Path.Combine (Path.GetDirectoryName (path), Path.GetFileNameWithoutExtension (path) + "-clean.xml"); + path = Path.Combine (Path.GetDirectoryName (path)!, Path.GetFileNameWithoutExtension (path) + "-clean.xml"); resultParser.CleanXml (testLogPath, path); @@ -310,7 +310,7 @@ public async Task CollectDeviceResult (ProcessExecutionResult runResult) var humanReadableLog = logs.CreateFile (Path.GetFileNameWithoutExtension (testLogPath) + ".log", LogType.NUnitResult); (parseResult.resultLine, parseResult.failed) = resultParser.ParseResults (path, xmlType, humanReadableLog); } else { - (parseResult.resultLine, parseResult.failed) = resultParser.ParseResults (path, xmlType, (StreamWriter) null); + (parseResult.resultLine, parseResult.failed) = resultParser.ParseResults (path, xmlType, (StreamWriter?) null); } logs.AddFile (path, LogType.XmlLog.ToString ()); @@ -320,7 +320,7 @@ public async Task CollectDeviceResult (ProcessExecutionResult runResult) mainLog.WriteLine ("File data is:"); mainLog.WriteLine (new string ('#', 10)); using (var stream = new StreamReader (path)) { - string line; + string? line; while ((line = await stream.ReadLineAsync ()) is not null) mainLog.WriteLine (line); } @@ -368,7 +368,7 @@ public async Task CollectDeviceResult (ProcessExecutionResult runResult) } } - async Task GenerateXmlFailures (string failure, bool crashed, string crashReason) + async Task GenerateXmlFailures (string failure, bool crashed, string? crashReason) { if (!ResultsUseXml) return; @@ -426,9 +426,9 @@ async Task GenerateXmlFailures (string failure, bool crashed, string crashReason } } - public async Task<(TestExecutingResult ExecutingResult, string ResultMessage)> ParseResult () + public async Task<(TestExecutingResult ExecutingResult, string? ResultMessage)> ParseResult () { - (TestExecutingResult ExecutingResult, string ResultMessage) result = (TestExecutingResult.Finished, null); + (TestExecutingResult ExecutingResult, string? ResultMessage) result = (TestExecutingResult.Finished, null); var crashed = false; if (File.Exists (listener.TestLog.FullPath)) { WrenchLog.WriteLine ("AddFile: {0}", listener.TestLog.FullPath); @@ -481,7 +481,7 @@ async Task GenerateXmlFailures (string failure, bool crashed, string crashReason if (!Success.Value) { int pid = -1; - string crashReason = null; + string? crashReason = null; foreach (var crashLog in crashLogs) { try { logs.Add (crashLog); diff --git a/tests/xharness/TestReporterFactory.cs b/tests/xharness/TestReporterFactory.cs index eb70d9156a2b..77adb724b219 100644 --- a/tests/xharness/TestReporterFactory.cs +++ b/tests/xharness/TestReporterFactory.cs @@ -32,10 +32,10 @@ public ITestReporter Create ( AppBundleInformation appInformation, RunMode runMode, XmlResultJargon xmlJargon, - string device, + string? device, TimeSpan timeout, - string additionalLogsDirectory = null, - ExceptionLogger exceptionLogger = null, + string? additionalLogsDirectory = null, + ExceptionLogger? exceptionLogger = null, bool generateHtml = false) { return new TestReporter ( diff --git a/tests/xharness/Xharness.Tests/Jenkins/ErrorKnowledgeBaseTests.cs b/tests/xharness/Xharness.Tests/Jenkins/ErrorKnowledgeBaseTests.cs deleted file mode 100644 index 8b337c4b5b85..000000000000 --- a/tests/xharness/Xharness.Tests/Jenkins/ErrorKnowledgeBaseTests.cs +++ /dev/null @@ -1,72 +0,0 @@ -#nullable enable -using System.IO; -using Microsoft.DotNet.XHarness.iOS.Shared.Logging; -using NUnit.Framework; -using Xharness.Jenkins; - -namespace Xharness.Tests.Jenkins { - public class ErrorKnowledgeBaseTests { - - ErrorKnowledgeBase? errorKnowledgeBase; - string? testFile; - - [SetUp] - public void SetUp () - { - errorKnowledgeBase = new ErrorKnowledgeBase (); - testFile = Path.GetTempFileName (); - } - - [TearDown] - public void TearDown () - { - errorKnowledgeBase = null; - } - - [Test] - public void IsMonoMulti3IssuePresentTest () - { - using var log = new LogFile ("test", testFile); - log.WriteLine ("Some noise"); - log.WriteLine ("error MT5210: Native linking failed, undefined symbol: ___multi3"); - log.WriteLine ("Some noise"); - log.Flush (); - Assert.IsTrue (errorKnowledgeBase!.IsKnownBuildIssue (log, out var failureMessage)); - Assert.IsNotNull (failureMessage); - } - - [Test] - public void IsMonoMulti3IssueMissingTest () - { - using var log = new LogFile ("test", testFile); - log.WriteLine ("Some noise"); - log.WriteLine ("Some noise"); - log.Flush (); - Assert.IsFalse (errorKnowledgeBase!.IsKnownBuildIssue (log, out var failureMessage)); - Assert.IsNull (failureMessage); - } - - [Test] - public void IsHE0038ErrorPresentTest () - { - using var log = new LogFile ("test", testFile); - log.WriteLine ("Some noise"); - log.WriteLine ("error HE0038: Failed to launch the app"); - log.WriteLine ("Some noise"); - log.Flush (); - Assert.IsTrue (errorKnowledgeBase!.IsKnownTestIssue (log, out var failureMessage)); - Assert.IsNotNull (failureMessage); - } - - [Test] - public void IsHE0038ErrorMissingTest () - { - using var log = new LogFile ("test", testFile); - log.WriteLine ("Some noise"); - log.WriteLine ("Some noise"); - log.Flush (); - Assert.IsFalse (errorKnowledgeBase!.IsKnownTestIssue (log, out var failureMessage)); - Assert.IsNull (failureMessage); - } - } -} diff --git a/tests/xharness/Xharness.Tests/Jenkins/ITestTaskExtensionsTests.cs b/tests/xharness/Xharness.Tests/Jenkins/ITestTaskExtensionsTests.cs deleted file mode 100644 index 80f38751a729..000000000000 --- a/tests/xharness/Xharness.Tests/Jenkins/ITestTaskExtensionsTests.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using Microsoft.DotNet.XHarness.iOS.Shared; - -using Moq; -using NUnit.Framework; - -using Xharness.Jenkins.TestTasks; - -namespace Xharness.Tests.Jenkins { - - [TestFixture] - public class ITestTaskExtensionsTests { - - public class TestCasesData { - public static IEnumerable GetColorTestCases { - get { - var task = new Mock (); - task.Setup (t => t.NotStarted).Returns (true); - yield return new TestCaseData (task.Object).Returns ("black"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (true); - task.Setup (t => t.Building).Returns (true); - yield return new TestCaseData (task.Object).Returns ("darkblue"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (true); - task.Setup (t => t.Building).Returns (false); - task.Setup (t => t.Running).Returns (true); - yield return new TestCaseData (task.Object).Returns ("lightblue"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (true); - task.Setup (t => t.Building).Returns (false); - task.Setup (t => t.Running).Returns (false); - yield return new TestCaseData (task.Object).Returns ("blue"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.Crashed).Returns (true); - yield return new TestCaseData (task.Object).Returns ("maroon"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.LaunchFailure).Returns (true); - yield return new TestCaseData (task.Object).Returns ("coral"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.HarnessException).Returns (true); - yield return new TestCaseData (task.Object).Returns ("orange"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.TimedOut).Returns (true); - yield return new TestCaseData (task.Object).Returns ("purple"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.BuildFailure).Returns (true); - yield return new TestCaseData (task.Object).Returns ("darkred"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.Failed).Returns (true); - yield return new TestCaseData (task.Object).Returns ("red"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.BuildSucceeded).Returns (true); - yield return new TestCaseData (task.Object).Returns ("lightgreen"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.Succeeded).Returns (true); - yield return new TestCaseData (task.Object).Returns ("green"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.Ignored).Returns (true); - yield return new TestCaseData (task.Object).Returns ("gray"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.Waiting).Returns (true); - yield return new TestCaseData (task.Object).Returns ("darkgray"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - task.Setup (t => t.DeviceNotFound).Returns (true); - yield return new TestCaseData (task.Object).Returns ("orangered"); - - task = new Mock (); - task.Setup (t => t.InProgress).Returns (false); - yield return new TestCaseData (task.Object).Returns ("pink"); - } - } - - public static IEnumerable GetColorCollectionTestCases { - get { - - Mock firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - Mock secondTask = new Mock (); - secondTask.Setup (t => t.Crashed).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Crashed); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("maroon"); - - firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - secondTask = new Mock (); - secondTask.Setup (t => t.LaunchFailure).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.LaunchFailure); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("coral"); - - firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - secondTask = new Mock (); - secondTask.Setup (t => t.TimedOut).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.TimedOut); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("purple"); - - firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - secondTask = new Mock (); - secondTask.Setup (t => t.BuildFailure).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.BuildFailure); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("darkred"); - - firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - secondTask = new Mock (); - secondTask.Setup (t => t.Failed).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Failed); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("red"); - - firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - secondTask = new Mock (); - secondTask.Setup (t => t.NotStarted).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.NotStarted); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("black"); - - firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - secondTask = new Mock (); - secondTask.Setup (t => t.Ignored).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Ignored); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("gray"); - - firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - secondTask = new Mock (); - secondTask.Setup (t => t.DeviceNotFound).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.DeviceNotFound); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("orangered"); - - firstTask = new Mock (); - firstTask.Setup (t => t.BuildSucceeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.BuildSucceeded); - secondTask = new Mock (); - secondTask.Setup (t => t.BuildSucceeded).Returns (true); - secondTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.BuildSucceeded); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("lightgreen"); - - firstTask = new Mock (); - firstTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - secondTask = new Mock (); - secondTask.Setup (t => t.Succeeded).Returns (true); - firstTask.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Succeeded); - yield return new TestCaseData (new List { firstTask.Object, secondTask.Object }).Returns ("green"); - - } - } - } - - [Test, TestCaseSource (typeof (TestCasesData), "GetColorTestCases")] - public string GetTestColorTest (ITestTask task) => task.GetTestColor (); - - [Test, TestCaseSource (typeof (TestCasesData), "GetColorCollectionTestCases")] - public string GetTestColorCollectionTest (IEnumerable tasks) => tasks.GetTestColor (); - } -} diff --git a/tests/xharness/Xharness.Tests/Jenkins/JenkinsDeviceLoadterTests.cs b/tests/xharness/Xharness.Tests/Jenkins/JenkinsDeviceLoadterTests.cs deleted file mode 100644 index f6cd6d2c5ebd..000000000000 --- a/tests/xharness/Xharness.Tests/Jenkins/JenkinsDeviceLoadterTests.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using System.Collections; -using System.Threading.Tasks; -using Microsoft.DotNet.XHarness.Common.Execution; -using Microsoft.DotNet.XHarness.Common.Logging; -using Microsoft.DotNet.XHarness.iOS.Shared.Execution; -using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; -using Microsoft.DotNet.XHarness.iOS.Shared.Logging; -using Moq; -using NUnit.Framework; -using Xharness.Jenkins; - -namespace Xharness.Tests.Jenkins { - - [TestFixture] - public class JenkinsDeviceLoadterTests { - - public class TestCasesData { - public static IEnumerable GetDeviceTestCases { - get { - // set the mock expectations the expected results - var simulators = new Mock (); - var aDevice = new Mock (); - - // no devices found - var devices = new Mock (); - devices.Setup (d => d.Connected32BitIOS).Returns (Array.Empty ()); - devices.Setup (d => d.Connected64BitIOS).Returns (Array.Empty ()); - devices.Setup (d => d.ConnectedTV).Returns (Array.Empty ()); - - yield return new TestCaseData (simulators.Object, devices.Object, $"Device Listing (ok - no devices found)."); - - // iOS 32b - devices = new Mock (); - devices.Setup (d => d.Connected32BitIOS).Returns (new IHardwareDevice [] { aDevice.Object }); - devices.Setup (d => d.Connected64BitIOS).Returns (Array.Empty ()); - devices.Setup (d => d.ConnectedTV).Returns (Array.Empty ()); - - yield return new TestCaseData (simulators.Object, devices.Object, $"Device Listing (ok). Devices types are: iOS 32 bit"); - - devices = new Mock (); - devices.Setup (d => d.Connected32BitIOS).Returns (new IHardwareDevice [] { aDevice.Object }); - devices.Setup (d => d.Connected64BitIOS).Returns (new IHardwareDevice [] { aDevice.Object }); - devices.Setup (d => d.ConnectedTV).Returns (Array.Empty ()); - - yield return new TestCaseData (simulators.Object, devices.Object, $"Device Listing (ok). Devices types are: iOS 32 bit, iOS 64 bit"); - - devices = new Mock (); - devices.Setup (d => d.Connected32BitIOS).Returns (new IHardwareDevice [] { aDevice.Object }); - devices.Setup (d => d.Connected64BitIOS).Returns (new IHardwareDevice [] { aDevice.Object }); - devices.Setup (d => d.ConnectedTV).Returns (new IHardwareDevice [] { aDevice.Object }); - yield return new TestCaseData (simulators.Object, devices.Object, $"Device Listing (ok). Devices types are: iOS 32 bit, iOS 64 bit, tvOS"); - - devices = new Mock (); - devices.Setup (d => d.Connected32BitIOS).Returns (new IHardwareDevice [] { aDevice.Object }); - devices.Setup (d => d.Connected64BitIOS).Returns (new IHardwareDevice [] { aDevice.Object }); - devices.Setup (d => d.ConnectedTV).Returns (new IHardwareDevice [] { aDevice.Object }); - yield return new TestCaseData (simulators.Object, devices.Object, $"Device Listing (ok). Devices types are: iOS 32 bit, iOS 64 bit, tvOS"); - } - } - - public static IEnumerable GetSimulatorTestCases { - get { - var devices = new Mock (); - var simulators = new Mock (); - var processManager = new Mock (); - var db = new Mock (); - - simulators.Setup (s => s.AvailableDevices).Returns (Array.Empty ()); - yield return new TestCaseData (simulators.Object, devices.Object, "Simulator Listing (ok - no simulators found)."); - - simulators = new Mock (); - simulators.Setup (s => s.AvailableDevices).Returns (new SimulatorDevice [] { new SimulatorDevice (processManager.Object, db.Object) }); - yield return new TestCaseData (simulators.Object, devices.Object, $"Simulator Listing (ok - Found 1 simulators)."); - } - } - } - - Mock logs; - Mock log; - - [SetUp] - public void SetUp () - { - logs = new Mock (); - log = new Mock (); - - logs.Setup (l => l.Create ( - It.IsAny (), - It.Is (s => s.Equals ("Simulator Listing", StringComparison.OrdinalIgnoreCase)), - null)).Returns (log.Object); - - logs.Setup (l => l.Create ( - It.IsAny (), - It.Is (s => s.Equals ("Device Listing", StringComparison.OrdinalIgnoreCase)), - null)).Returns (log.Object); - - log.SetupSet (l => l.Description = It.IsAny ()).Verifiable (); - } - - [TearDown] - public void TearDown () - { - logs = null; - log = null; - } - - - [Test, TestCaseSource (typeof (TestCasesData), "GetDeviceTestCases")] - public async Task FoundDevicesTest (ISimulatorLoader simulators, IHardwareDeviceLoader devices, string expectedDescription) - { - var loader = new JenkinsDeviceLoader (simulators, devices, logs.Object); - - await loader.LoadDevicesAsync (); - // validate that the log description will be set as expected - log.VerifySet (l => l.Description = It.Is (s => s.Equals (expectedDescription, StringComparison.OrdinalIgnoreCase))); - } - - [Test, TestCaseSource (typeof (TestCasesData), "GetSimulatorTestCases")] - public async Task FoundSimulatorsTest (ISimulatorLoader simulators, IHardwareDeviceLoader devices, string expectedDescription) - { - var loader = new JenkinsDeviceLoader (simulators, devices, logs.Object); - - await loader.LoadSimulatorsAsync (); - // validate that the log description will be set as expected - log.VerifySet (l => l.Description = It.Is (s => s.Equals (expectedDescription, StringComparison.OrdinalIgnoreCase))); - } - - } -} diff --git a/tests/xharness/Xharness.Tests/Jenkins/MarkdownReportWriterTests.cs b/tests/xharness/Xharness.Tests/Jenkins/MarkdownReportWriterTests.cs deleted file mode 100644 index 53ce059ec74c..000000000000 --- a/tests/xharness/Xharness.Tests/Jenkins/MarkdownReportWriterTests.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using Microsoft.DotNet.XHarness.iOS.Shared; -using Moq; -using NUnit.Framework; -using Xharness.Jenkins.Reports; -using Xharness.Jenkins.TestTasks; - -namespace Xharness.Tests.Jenkins { - [TestFixture] - public class MarkdownReportWriterTests { - - string path; - MarkdownReportWriter reportWriter; - - [SetUp] - public void SetUp () - { - path = Path.GetTempFileName (); - File.Delete (path); - reportWriter = new MarkdownReportWriter (); - } - - [TearDown] - public void TearDown () - { - File.Delete (path); - } - - [Test] - public void AllSuccessfulTest () - { - int count = 10; - List tasks = new List (); - for (var i = 0; i < count; i++) { - var success = new Mock (); - success.Setup (t => t.Finished).Returns (true); - success.Setup (t => t.Succeeded).Returns (true); - success.Setup (t => t.TestName).Returns ($"Success with id {i}"); - tasks.Add (success.Object); - } - - for (var i = 0; i < count; i++) { - var ignored = new Mock (); - ignored.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Ignored); - ignored.Setup (t => t.Finished).Returns (true); - tasks.Add (ignored.Object); - } - - using (var writer = new StreamWriter (path)) { - reportWriter.Write (tasks, writer); - } - - using (var reader = new StreamReader (path)) { - var report = reader.ReadToEnd (); - Assert.NotNull (report); - Assert.AreEqual ($"# :tada: All {count} tests passed :tada:\n\n", report); - } - } - - [Test] - public void MixResultsFailAndSuccessTest () - { - int count = 10; - List tasks = new List (); - for (var i = 0; i < count / 2; i++) { - var success = new Mock (); - success.Setup (t => t.Finished).Returns (true); - success.Setup (t => t.Succeeded).Returns (true); - success.Setup (t => t.TestName).Returns ($"Success with id {i}"); - tasks.Add (success.Object); - } - - for (var i = 0; i < count / 2; i++) { - var failure = new Mock (); - failure.Setup (t => t.Finished).Returns (true); - failure.Setup (t => t.Succeeded).Returns (false); - failure.Setup (t => t.Failed).Returns (true); - failure.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Failed); - failure.Setup (t => t.TestName).Returns ($"Failure with id {i}"); - tasks.Add (failure.Object); - } - - for (var i = 0; i < count; i++) { - var ignored = new Mock (); - ignored.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Ignored); - ignored.Setup (t => t.Finished).Returns (true); - tasks.Add (ignored.Object); - } - - using (var writer = new StreamWriter (path)) { - reportWriter.Write (tasks, writer); - } - - string summaryLine = null; - int failedTestsLineCount = 0; - - using (var reader = new StreamReader (path)) { - string line = null; - while ((line = reader.ReadLine ()) is not null) { - if (line.StartsWith ("{count / 2} tests failed, {count / 2} tests passed.", summaryLine, "summary value"); - Assert.AreEqual (count / 2, failedTestsLineCount, "Error count"); - } - - [Test] - public void MissingDeviceTest () - { - int count = 10; - List tasks = new List (); - for (var i = 0; i < count; i++) { - var success = new Mock (); - success.Setup (t => t.DeviceNotFound).Returns (true); - success.Setup (t => t.Finished).Returns (true); - success.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.DeviceNotFound); - success.Setup (t => t.TestName).Returns ($"Failed with id {i}"); - tasks.Add (success.Object); - } - - using (var writer = new StreamWriter (path)) { - reportWriter.Write (tasks, writer); - } - - using (var reader = new StreamReader (path)) { - var report = reader.ReadToEnd (); - Assert.NotNull (report); - Assert.AreEqual ($"# Test results\n\n{count} tests' device not found, 0 tests passed.\n\n", report); - } - } - - [Test] - public void NotTestsTest () - { - int count = 10; - List tasks = new List (); - for (var i = 0; i < count; i++) { - var ignored = new Mock (); - ignored.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Ignored); - ignored.Setup (t => t.Finished).Returns (true); - tasks.Add (ignored.Object); - } - - using (var writer = new StreamWriter (path)) { - reportWriter.Write (tasks, writer); - } - - using (var reader = new StreamReader (path)) { - var report = reader.ReadToEnd (); - Assert.NotNull (report); - Assert.AreEqual ("# No tests selected.\n\n", report); - } - } - - [Test] - public void KnownIssueTest () - { - int count = 10; - List tasks = new List (); - - for (var i = 0; i < count; i++) { - var failure = new Mock (); - var knownIssue = new KnownIssue (humanMessage: "Testing known issues", issueLink: "http://github.com"); - failure.Setup (t => t.Finished).Returns (true); - failure.Setup (t => t.Succeeded).Returns (false); - failure.Setup (t => t.Failed).Returns (true); - failure.Setup (t => t.ExecutionResult).Returns (TestExecutingResult.Failed); - failure.Setup (t => t.TestName).Returns ($"Failure with id {i}"); - failure.Setup (t => t.KnownFailure).Returns (knownIssue); - tasks.Add (failure.Object); - } - - - using (var writer = new StreamWriter (path)) { - reportWriter.Write (tasks, writer); - } - - int failureCount = 0; - using (var reader = new StreamReader (path)) { - string line = null; - while ((line = reader.ReadLine ()) is not null) { - if (line.Contains ("Failure")) { - Assert.AreEqual ($" * Failure with id {failureCount}: Failed Known issue: [Testing known issues](http://github.com)", line, line); - failureCount++; - } - } - } - } - } -} diff --git a/tests/xharness/Xharness.Tests/Jenkins/PeriodicCommandTests.cs b/tests/xharness/Xharness.Tests/Jenkins/PeriodicCommandTests.cs deleted file mode 100644 index 0e8fcb3610af..000000000000 --- a/tests/xharness/Xharness.Tests/Jenkins/PeriodicCommandTests.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.DotNet.XHarness.Common.Execution; -using Microsoft.DotNet.XHarness.Common.Logging; -using Microsoft.DotNet.XHarness.iOS.Shared.Execution; -using Microsoft.DotNet.XHarness.iOS.Shared.Logging; -using Moq; -using NUnit.Framework; -using Xharness.Jenkins; - -namespace Xharness.Tests.Jenkins { - - [TestFixture] - public class PeriodicCommandTests { - - Mock processManager; - Mock logs; - Mock log; - TimeSpan interval; - string command; - string arguments; - - [SetUp] - public void SetUp () - { - processManager = new Mock (MockBehavior.Strict); - logs = new Mock (); - log = new Mock (); - - // common setup for the mocks - logs.Setup (l => l.Create (It.Is (s => true), It.Is (s => true), null)).Returns (log.Object); - interval = TimeSpan.FromMilliseconds (100); - command = "test"; - arguments = "periodic"; - } - - // we do not test the options without the cancellation task because we want to be nice people when running - // the tests and do not leave a thread doing nothing - [Test] - public async Task TestExecuteNoArgs () - { - var periodicCommand = new PeriodicCommand (command, processManager.Object, interval, logs.Object); - var executionTcs = new TaskCompletionSource (); - var threadCs = new CancellationTokenSource (); - - processManager.Setup (pm => pm.RunAsync ( - It.Is (p => p.StartInfo.FileName == command && p.StartInfo.Arguments == string.Empty), - It.IsAny (), - interval, - null, - It.IsAny (), - null)).Callback, CancellationToken?, bool?> ( - (p, l, i, env, t, d) => { - executionTcs.TrySetResult (true); - }).ReturnsAsync (new ProcessExecutionResult { ExitCode = 0, TimedOut = false }).Verifiable (); - - var task = periodicCommand.Execute (threadCs.Token); - await executionTcs.Task; // wait for the callback in the mock, which is in another thread to set the source - processManager.VerifyAll (); - processManager.VerifyNoOtherCalls (); - threadCs.Cancel (); // clean - } - - [Test] - public async Task TestExecuteArgs () - { - // all similar logic to the above one, but with arguments - var periodicCommand = new PeriodicCommand (command, processManager.Object, interval, logs.Object, arguments: arguments); - var executionTcs = new TaskCompletionSource (); - var threadCs = new CancellationTokenSource (); - - processManager.Setup (pm => pm.RunAsync ( - It.Is (p => p.StartInfo.FileName == command && p.StartInfo.Arguments == arguments), - It.IsAny (), - interval, - null, - It.IsAny (), - null)).Callback, CancellationToken?, bool?> ( - (p, l, i, env, t, d) => { - executionTcs.TrySetResult (true); - }).ReturnsAsync (new ProcessExecutionResult { ExitCode = 0, TimedOut = false }).Verifiable (); - - var task = periodicCommand.Execute (threadCs.Token); - await executionTcs.Task; // wait for the callback in the mock, which is in another thread to set the source - processManager.VerifyAll (); - processManager.VerifyNoOtherCalls (); - threadCs.Cancel (); // clean - } - - } -} diff --git a/tests/xharness/Xharness.Tests/Jenkins/ResourceManagerTests.cs b/tests/xharness/Xharness.Tests/Jenkins/ResourceManagerTests.cs deleted file mode 100644 index bdd8eb0bb6e7..000000000000 --- a/tests/xharness/Xharness.Tests/Jenkins/ResourceManagerTests.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System.Collections.Generic; -using System.Resources; -using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; -using Xharness.Jenkins; -using Moq; -using NUnit.Framework; -using System.Linq; - -namespace Xharness.Tests.Jenkins { - [TestFixture] - public class ResourceManagerTests { - - Mock device1; - Mock device2; - Xharness.Jenkins.ResourceManager resourceManager; - - [SetUp] - public void SetUp () - { - device1 = new Mock (); - device2 = new Mock (); - resourceManager = new Xharness.Jenkins.ResourceManager (); - } - - [Test] - public void GetDeviceResourceMissingTest () - { - var devices = new List { device1.Object, device2.Object }; - // set the device expectations - device1.Setup (d => d.UDID).Returns ("device1"); - device1.Setup (d => d.Name).Returns ("device1"); - - device2.Setup (d => d.UDID).Returns ("device2"); - device2.Setup (d => d.Name).Returns ("device2"); - - var resources = resourceManager.GetDeviceResources (devices); - - // assert that both are present - Assert.NotNull (resources, "resources"); - Assert.AreEqual (2, resources.Count ()); - Assert.AreEqual (1, resources.Where (r => r.Name == "device1").Count (), "device1"); - Assert.AreEqual (1, resources.Where (r => r.Name == "device2").Count (), "device2"); - } - - [Test] - public void GetDeviceResourcePresent () - { - // call it twice to make sure we get the same results - var devices = new List { device1.Object, device2.Object }; - // set the device expectations - device1.Setup (d => d.UDID).Returns ("device1"); - device1.Setup (d => d.Name).Returns ("device1"); - - device2.Setup (d => d.UDID).Returns ("device2"); - device2.Setup (d => d.Name).Returns ("device2"); - - var resources = resourceManager.GetDeviceResources (devices); - - // assert that both are present - Assert.NotNull (resources, "resources"); - Assert.AreEqual (2, resources.Count ()); - Assert.AreEqual (1, resources.Where (r => r.Name == "device1").Count (), "first device1"); - Assert.AreEqual (1, resources.Where (r => r.Name == "device2").Count (), "first device2"); - - var resources2 = resourceManager.GetDeviceResources (devices); - - // assert that both are present - Assert.NotNull (resources2, "resources2"); - Assert.AreEqual (2, resources2.Count ()); - Assert.AreEqual (1, resources2.Where (r => r.Name == "device1").Count (), "second device1"); - Assert.AreEqual (1, resources2.Where (r => r.Name == "device2").Count (), "decond device2"); - } - - [Test] - public void GetDeviceResourcesAddMissingTest () - { - var devices = new List { device1.Object }; - // set the device expectations - device1.Setup (d => d.UDID).Returns ("device1"); - device1.Setup (d => d.Name).Returns ("device1"); - - device2.Setup (d => d.UDID).Returns ("device2"); - device2.Setup (d => d.Name).Returns ("device2"); - - var resources = resourceManager.GetDeviceResources (devices); - - // assert that both are present - Assert.NotNull (resources, "resources"); - Assert.AreEqual (1, resources.Count ()); - Assert.AreEqual (1, resources.Where (r => r.Name == "device1").Count (), "first device1"); - Assert.AreEqual (0, resources.Where (r => r.Name == "device2").Count (), "first device2"); - - var devices2 = new List { device1.Object, device2.Object }; - var resources2 = resourceManager.GetDeviceResources (devices2); - - // assert that both are present - Assert.NotNull (resources2, "resources2"); - Assert.AreEqual (2, resources2.Count ()); - Assert.AreEqual (1, resources2.Where (r => r.Name == "device1").Count (), "second device1"); - Assert.AreEqual (1, resources2.Where (r => r.Name == "device2").Count (), "decond device2"); - } - - [Test] - public void GetAllTest () - { - var devices = new List { device1.Object, device2.Object }; - // set the device expectations - device1.Setup (d => d.UDID).Returns ("device1"); - device1.Setup (d => d.Name).Returns ("device1"); - - device2.Setup (d => d.UDID).Returns ("device2"); - device2.Setup (d => d.Name).Returns ("device2"); - - var deviceResources = resourceManager.GetDeviceResources (devices); - - // now get all of the present resources and assert we have the desktop and nuget - var allResources = resourceManager.GetAll (); - - Assert.AreEqual (deviceResources.Count () + 2, allResources.Count (), "count"); - Assert.AreEqual (1, allResources.Where (r => r.Name == "device1").Count ()); - Assert.AreEqual (1, allResources.Where (r => r.Name == "device2").Count ()); - Assert.AreEqual (1, allResources.Where (r => r.Name == "Desktop").Count ()); - Assert.AreEqual (1, allResources.Where (r => r.Name == "Nuget").Count ()); - } - } -} diff --git a/tests/xharness/Xharness.Tests/Jenkins/TestSelectionTests.cs b/tests/xharness/Xharness.Tests/Jenkins/TestSelectionTests.cs deleted file mode 100644 index f7f61230451a..000000000000 --- a/tests/xharness/Xharness.Tests/Jenkins/TestSelectionTests.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using NUnit.Framework; -using Xharness.Jenkins; - -#nullable enable - -namespace Xharness.Tests.Jenkins { - - [TestFixture] - public class TestSelectionTests { - - TestSelection selection = new TestSelection (); - - [SetUp] - public void Setup () - { - selection = new TestSelection (); - } - - [Test] - public void DefaultSelectionTest () - { - // Assert tests - Assert.IsTrue (selection.SelectedTests.HasFlag (TestLabel.Msbuild), "msbuild"); - Assert.IsTrue (selection.IsEnabled (TestLabel.Msbuild), "IsEnabled (msbuild)"); - - Assert.IsTrue (selection.SelectedTests.HasFlag (TestLabel.Monotouch), "monotouch"); - Assert.IsTrue (selection.IsEnabled (TestLabel.Monotouch), "IsEnabled (monotouch)"); - - Assert.IsTrue (selection.SelectedTests.HasFlag (TestLabel.DotnetTest), "dotnet"); - Assert.IsTrue (selection.IsEnabled (TestLabel.DotnetTest), "IsEnabled (dotnet)"); - - // Assert platforms - Assert.IsTrue (selection.SelectedPlatforms.HasFlag (PlatformLabel.tvOS), "tvos"); - Assert.IsTrue (selection.IsEnabled (PlatformLabel.tvOS), "IsEnabled (tvOS)"); - - Assert.IsTrue (selection.SelectedPlatforms.HasFlag (PlatformLabel.iOS), "iOS"); - Assert.IsTrue (selection.IsEnabled (PlatformLabel.iOS), "IsEnabled (iOS)"); - - Assert.IsTrue (selection.SelectedPlatforms.HasFlag (PlatformLabel.iOSSimulator), "iOSSimulator"); - Assert.IsTrue (selection.IsEnabled (PlatformLabel.iOSSimulator), "IsEnabled (iOSSimulator)"); - - Assert.IsTrue (selection.SelectedPlatforms.HasFlag (PlatformLabel.MacCatalyst), "maccatalyst"); - Assert.IsTrue (selection.IsEnabled (PlatformLabel.MacCatalyst), "IsEnabled (maccatalyst)"); - } - - [Test] - public void DisableAllTests () - { - selection.SetEnabled (TestLabel.All, false); - // loop over all tests labels and except None and All, assert they are not enabled - foreach (var obj in Enum.GetValues (typeof (TestLabel))) { - if (obj is TestLabel label) { - switch (label) { - case TestLabel.All: - case TestLabel.None: - continue; - default: - Assert.IsFalse (selection.IsEnabled (label), label.ToString ()); - break; - } - } - } - } - - [Test] - public void EnableAllTests () - { - selection.SetEnabled (TestLabel.All, true); - // loop over all tests labels and except None and All, assert they are not enabled - foreach (var obj in Enum.GetValues (typeof (TestLabel))) { - if (obj is TestLabel label) { - switch (label) { - case TestLabel.All: - case TestLabel.None: - continue; - default: - Assert.IsTrue (selection.IsEnabled (label), label.ToString ()); - break; - } - } - } - } - - [Test] - public void EnableSingleTest () - { - // disable all, then enable a single tests - selection.SetEnabled (TestLabel.All, false); - foreach (var obj in Enum.GetValues (typeof (TestLabel))) { - if (obj is TestLabel label) { - switch (label) { - case TestLabel.All: - case TestLabel.None: - continue; - default: - Assert.IsFalse (selection.IsEnabled (label), label.ToString ()); - break; - } - } - } - } - - [Test] - public void EnableSeveralTests () - { - selection.SetEnabled (TestLabel.All, false); - selection.SetEnabled (TestLabel.Monotouch, true); - foreach (var obj in Enum.GetValues ()) { - if (obj is TestLabel label) { - switch (label) { - case TestLabel.All: - case TestLabel.None: - continue; - case TestLabel.Monotouch: - Assert.IsTrue (selection.IsEnabled (label), label.ToString ()); - break; - default: - Assert.IsFalse (selection.IsEnabled (label), label.ToString ()); - break; - } - } - } - } - } -} diff --git a/tests/xharness/Xharness.Tests/Jenkins/TestSelectorTests.cs b/tests/xharness/Xharness.Tests/Jenkins/TestSelectorTests.cs deleted file mode 100644 index e3a51e31f933..000000000000 --- a/tests/xharness/Xharness.Tests/Jenkins/TestSelectorTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using System.Linq.Expressions; -using Moq; -using NUnit.Framework; -using Xharness.Jenkins; - -namespace Xharness.Tests.Jenkins { - public class TestSelectorTests { - TestSelector selector; - Mock versionControlSystem; - - [SetUp] - public void SetUp () - { - versionControlSystem = new Mock (); - selector = new TestSelector (null, versionControlSystem.Object); - } - - [TearDown] - public void TearDown () - { - selector = null; - } - - [TestCase ("run-all-tests", TestLabel.All, PlatformLabel.All)] - [TestCase ("skip-all-tests", TestLabel.None, PlatformLabel.None)] - [TestCase ("skip-all-tests, run-monotouch-tests", TestLabel.Monotouch, PlatformLabel.None)] - [TestCase ("skip-all-tests, run-monotouch-tests, run-ios-tests", TestLabel.Monotouch, PlatformLabel.iOS)] - [TestCase ("run-monotouch-tests, run-bgen-tests, run-all-tests", TestLabel.All, PlatformLabel.All)] - public void SelectTestByLabelsTest (string cmdLabels, TestLabel expectedResult, PlatformLabel expectedPlatform) - { - var labels = new HashSet (); - labels.UnionWith (cmdLabels.Split (',')); - var selection = new TestSelection (); - selector.SelectTestsByLabel (labels, selection); - Assert.AreEqual (expectedResult, selection.SelectedTests, "Test selection failed."); - Assert.AreEqual (expectedPlatform, selection.SelectedPlatforms, "Platform selection failed."); - } - } -} diff --git a/tests/xharness/Xharness.Tests/Samples/NUnitV2Sample.xml b/tests/xharness/Xharness.Tests/Samples/NUnitV2Sample.xml deleted file mode 100644 index 70c61a15c04e..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/NUnitV2Sample.xml +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/xharness/Xharness.Tests/Samples/NUnitV3Sample.xml b/tests/xharness/Xharness.Tests/Samples/NUnitV3Sample.xml deleted file mode 100644 index f78fceb28368..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/NUnitV3Sample.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/xharness/Xharness.Tests/Samples/NUnitV3SampleFailure.xml b/tests/xharness/Xharness.Tests/Samples/NUnitV3SampleFailure.xml deleted file mode 100644 index bf83ae78c02a..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/NUnitV3SampleFailure.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/xharness/Xharness.Tests/Samples/NUnitV3SampleSuccess.xml b/tests/xharness/Xharness.Tests/Samples/NUnitV3SampleSuccess.xml deleted file mode 100644 index 79714282cbf3..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/NUnitV3SampleSuccess.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/xharness/Xharness.Tests/Samples/TestProject/Info.plist b/tests/xharness/Xharness.Tests/Samples/TestProject/Info.plist deleted file mode 100644 index b06447712c80..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/TestProject/Info.plist +++ /dev/null @@ -1,41 +0,0 @@ - - - - - CFBundleName - com.xamarin.bcltests.SystemXunit - CFBundleIdentifier - com.xamarin.bcltests.SystemXunit - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1.0 - LSRequiresIPhoneOS - - MinimumOSVersion - 7.0 - UIDeviceFamily - - 1 - 2 - - UIRequiredDeviceCapabilities - - arm64 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - XSAppIconAssets - Assets.xcassets/AppIcon.appiconset - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - - diff --git a/tests/xharness/Xharness.Tests/Samples/TestProject/SystemXunit.csproj b/tests/xharness/Xharness.Tests/Samples/TestProject/SystemXunit.csproj deleted file mode 100644 index e66c2cb29ba1..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/TestProject/SystemXunit.csproj +++ /dev/null @@ -1,192 +0,0 @@ - - - - - Debug - iPhoneSimulator - {3A835432-B054-32FD-07CB-F9A8FFCFB44D} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - com.xamarin.bcltests.SystemXunit - com.xamarin.bcltests.SystemXunit - 67,168,169,219,414,612,618,649,672 - Xamarin.iOS - Resources - latest - - - True - full - False - bin - DEBUG;NET_1_1;NET_2_0;NET_3_0;NET_3_5;NET_4_0;NET_4_5;NET_2_1;MOBILE;MONOTOUCH;FULL_AOT_RUNTIME;DISABLE_CAS_USE;$(DefineConstants) - prompt - 4 - True - None - True - x86_64 - cjk,mideast,other,rare,west - - - True - full - False - bin - DEBUG;NET_1_1;NET_2_0;NET_3_0;NET_3_5;NET_4_0;NET_4_5;NET_2_1;MOBILE;MONOTOUCH;FULL_AOT_RUNTIME;DISABLE_CAS_USE;$(DefineConstants) - prompt - 4 - iPhone Developer - True - True - ARM64 - cjk,mideast,other,rare,west - - - - - - - - - - - - - - - - - - - - monotouch\nunitlite.dll - - - monotouch\tests\Xunit.NetCore.Extensions.dll - - - monotouch\tests\xunit.execution.dotnet.dll - - - - - monotouch\tests\monotouch_System_xunit-test.dll - - - - - Assets.xcassets\AppIcon.appiconset\Contents.json - - - Assets.xcassets\Contents.json - - - - - - - - Info.plist - - - Entitlements.plist - - - - - TestRunner.NUnit\NUnitTestRunner.cs - - - TestRunner.NUnit\ClassOrNamespaceFilter.cs - - - TestRunner.NUnit\TestMethodFilter.cs - - - TestRunner.Core\Extensions.Bool.cs - - - TestRunner.Core\LogWriter.cs - - - TestRunner.Core\MinimumLogLevel.cs - - - TestRunner.Core\TcpTextWriter.cs - - - TestRunner.Core\TestAssemblyInfo.cs - - - TestRunner.Core\TestCompletionStatus.cs - - - TestRunner.Core\TestExecutionState.cs - - - TestRunner.Core\TestFailureInfo.cs - - - TestRunner.Core\TestRunner.cs - - - TestRunner.Core\TestRunSelector.cs - - - TestRunner.Core\TestRunSelectorType.cs - - - TestRunner.xUnit\XUnitFilter.cs - - - TestRunner.xUnit\XUnitFilterType.cs - - - TestRunner.xUnit\XUnitTestRunner.cs - - - ApplicationOptions.cs - - - IgnoreFileParser.cs - - - AppDelegate.cs - - - Main.cs - - - ViewController.cs - - - ViewController.designer.cs - ViewController.cs - - - RegisterType.cs - - - - - TestRunner.xUnit\NUnitXml.xslt - - - TestRunner.xUnit\NUnit3Xml.xslt - - - common-monotouch_System_xunit-test.dll.ignore - PreserveNewest - - - nunit-excludes.txt - PreserveNewest - - - xunit-excludes.txt - PreserveNewest - - - - diff --git a/tests/xharness/Xharness.Tests/Samples/TouchUnitSample.xml b/tests/xharness/Xharness.Tests/Samples/TouchUnitSample.xml deleted file mode 100644 index 213c4c372d76..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/TouchUnitSample.xml +++ /dev/null @@ -1,8842 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/xharness/Xharness.Tests/Samples/devices.xml b/tests/xharness/Xharness.Tests/Samples/devices.xml deleted file mode 100644 index 8a4240022408..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/devices.xml +++ /dev/null @@ -1,277 +0,0 @@ - - - /Applications/Xcode113.app/Contents/Developer - - - - - - - - - - - - - 5696DC36EE3249859D465DA37E6EA912 - - - - Wifi - - False - - True - - Office - - - - - - - - - - - - - Activated - 5650776064 - 100 - b0:19:c6:94:f2:26 - 17D50 - 32789 - arm64 - Development - iPhone - 1 - 1 - 5696DC36EE3249859D465DA37E6EA912 - Standard - - D211AP - Usb - 359401080217877 - True - True - True - MQ8L2 - iPhone - True - 1 - iPhone10,5 - 13.3.1 - C39V7FLJJCM2 - 58561933312 - D9DCBED1EC414ECE9A2353364C2AC454 - 1434502442682426 - True - b0:19:c6:94:f2:25 - - - - - - - - - - - iPhone - - - E383EA784E604083B5B602853A364759 - - - - Usb - - False - - True - - iPhone - - - - - - - 6D6C141F40CC4A4DB7967FCCE974ECE3 - - - - - - - - - - - - - - iPhone - - - D384F1159D5748C2A590420D64FA8CBE - - - - Usb - - False - - True - - XQAiPhone5Sa - - - - - - - 245481CA878E4AC0825DFBFDBCFD16BB - - - - - - - - - - - - - - iPod - - - 5D61F84BC2804AA698C2DFC1B7FDD200 - - - - Usb - - False - - True - - XQAiPodTouch5f - - - - - - - 1CBD36A8F42441A78D57443EFE0BD666 - - - - - - Activated - 43999293440 - 100 - 88:64:40:5c:ee:c5 - 17A577 - 32816 - arm64e - Development - iPhone - 1 - 1 - 8A450AA31EA94191AD6B02455F377CC1 - Standard - False - N104AP - Usb - 353981100627011 - True - True - True - MWL72 - Manuel’s iPhone - True - 1 - iPhone12,1 - 13.0 - DNPZ893NN72J - 54814302208 - 58F21118E4D34FD69EAB7860BB9B38A0 - 2852055891869742 - True - 88:64:40:67:a1:06 - - - - - - - - - - - Watch - - - 9608C09A197C4A6EB41B454D91976654 - - - - 3 - - False - - True - - Manuel’s Apple Watch - - - - - - - BC87FE47DA2A421CA791AD667E7E57E8 - - - - bd3fd054136767445ff47819f65b74867a48e591 - - - Activated - 22636388352 - 90 - a4:d1:d2:74:24:89 - 13G36 - 35136 - armv7f - - iPad - white - unknown - E854B2C3E7C8451BAF8053EC4DAAEE49 - Standard - - K93AP - Usb - - True - True - True - MC980 - Manuel de la Pena Saenz’s iPad - False - 1 - iPad2,1 - 9.3.5 - DN6FV2LSDKPJ - 29631791104 - 51F3354D448D4814825D07DC5658C19B - 4130031754541 - False - a4:d1:d2:74:24:88 - - \ No newline at end of file diff --git a/tests/xharness/Xharness.Tests/Samples/run-log.txt b/tests/xharness/Xharness.Tests/Samples/run-log.txt deleted file mode 100644 index 4de9a92f07d3..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/run-log.txt +++ /dev/null @@ -1,47 +0,0 @@ -14:48:45.0272010 Test log server listening on: 0.0.0.0:49987 -14:48:45.0308310 System log for the 'iPhone X (iOS 13.3) - created by xharness' simulator is: /Users/mandel/Library/Logs/CoreSimulator/96EBF3D8-393E-4166-B1AF-4A3BDEAC5021/system.log -14:48:45.0314300 *** Executing com.xamarin.bcltests.mscorlib Part 1/Classic in the simulator *** -14:48:45.0328640 Starting test run -14:48:45.0332180 /Users/mandel/dotnet/macios/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch --sdkroot /Applications/Xcode113.app -v -argument=-connection-mode -argument=none -argument=-app-arg:-autostart -setenv=NUNIT_AUTOSTART=true -argument=-app-arg:-autoexit -setenv=NUNIT_AUTOEXIT=true -argument=-app-arg:-enablenetwork -setenv=NUNIT_ENABLE_NETWORK=true -argument=-app-arg:-hostname:127.0.0.1 -setenv=NUNIT_HOSTNAME=127.0.0.1 -argument=-app-arg:-transport:Tcp -setenv=NUNIT_TRANSPORT=TCP -argument=-app-arg:-hostport:49987 -setenv=NUNIT_HOSTPORT=49987 --launchsim "/Users/mandel/dotnet/macios/master/xamarin-macios/tests/xharness/tmp-test-dir/mscorlib Part 1/bin/mscorlib Part 1/iPhoneSimulator/Debug-unified/com.xamarin.bcltests.mscorlib Part 1.app" --stdout=/dev/ttys000 --stderr=/dev/ttys000 --device=:v2:udid=96EBF3D8-393E-4166-B1AF-4A3BDEAC5021 -14:48:45.2834160 Using Xcode 11.3 found in /Applications/Xcode113.app -14:48:45.2865790 Xamarin.Hosting: Xamarin.Hosting -14:48:45.2867370 Xamarin.Hosting: Version: cec1cba137 (master) -14:48:45.2867590 Xamarin.Hosting: Xcode: /Applications/Xcode113.app -14:48:45.2886960 Xamarin.Hosting: Xcode Version: 11.3 -14:48:45.2892130 Xamarin.Hosting: Verbosity: 11 -14:48:45.2987220 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation -14:48:45.3024060 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTiPhoneSimulatorRemoteClient.framework/DVTiPhoneSimulatorRemoteClient -14:48:45.3024840 Xamarin.Hosting: Loaded /Library/Developer/PrivateFrameworks/CoreSimulator.framework/CoreSimulator -14:48:45.3026130 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/DTDeviceKitBase -14:48:45.3154170 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTKit.framework/DVTKit -14:48:45.3159370 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DTDeviceKit.framework/DTDeviceKit -14:48:45.3160450 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DTXConnectionServices.framework/DTXConnectionServices -14:48:45.3167760 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTSourceControl.framework/DVTSourceControl -14:48:45.3168970 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTServices.framework/DVTServices -14:48:45.3170070 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTPortal.framework/DVTPortal -14:48:45.3236970 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTDocumentation.framework/DVTDocumentation -14:48:45.3244800 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTAnalyticsClient.framework/DVTAnalyticsClient -14:48:45.3254630 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/DVTAnalytics.framework/DVTAnalytics -14:48:45.3273940 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/SourceKit.framework/SourceKit -14:48:45.3451120 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/Frameworks/IDEFoundation.framework/IDEFoundation -14:48:45.3459620 Xamarin.Hosting: Loaded /Applications/Xcode113.app/Contents/SharedFrameworks/IDEProducts.framework/IDEProducts -14:48:45.4904370 Xamarin.Hosting: Simulator watchdogs are already disabled for 'iOS 13.3 (17C45) - iPhone X'. -14:48:45.5001330 Xamarin.Hosting: Launching simulator application 'com.apple.iphonesimulator' -14:48:45.8284390 Xamarin.Hosting: Ready notification 'com.apple.iphonesimulator.ready' received from the simulator. -14:48:45.8317100 Xamarin.Hosting: Booting iPhone X (iOS 13.3) - created by xharness... -14:48:46.4418970 Xamarin.Hosting: Booted iPhone X (iOS 13.3) - created by xharness successfully. -14:48:46.4461820 Copying in /Users/mandel/dotnet/macios/master/xamarin-macios/tests/xharness/tmp-test-dir/mscorlib Part 1/bin/mscorlib Part 1/iPhoneSimulator/Debug-unified/com.xamarin.bcltests.mscorlib Part 1.app/.monotouch-64 -14:48:48.1443990 Xamarin.Hosting: No need to boot (already booted): iPhone X (iOS 13.3) - created by xharness -14:48:48.1459630 Xamarin.Hosting: Installing /Users/mandel/dotnet/macios/master/xamarin-macios/tests/xharness/tmp-test-dir/mscorlib Part 1/bin/mscorlib Part 1/iPhoneSimulator/Debug-unified/com.xamarin.bcltests.mscorlib Part 1.app with Bundle Identifier com.xamarin.bcltests.mscorlib Part 1 on 'iOS 13.3 (17C45) - iPhone X'... -14:49:25.8788620 Xamarin.Hosting: Installed 'com.xamarin.bcltests.mscorlib Part 1' from /Users/mandel/dotnet/macios/master/xamarin-macios/tests/xharness/tmp-test-dir/mscorlib Part 1/bin/mscorlib Part 1/iPhoneSimulator/Debug-unified/com.xamarin.bcltests.mscorlib Part 1.app -14:49:26.6020030 Xamarin.Hosting: Could not find any potentially troublesome weak load commands. -14:49:26.7037460 Xamarin.Hosting: The bundle id com.xamarin.bcltests.mscorlib Part 1 was successfully installed. -14:49:26.7087350 Xamarin.Hosting: Launching com.xamarin.bcltests.mscorlib Part 1 on 'iOS 13.3 (17C45) - iPhone X' -14:49:26.7808590 Xamarin.Hosting: Launched com.xamarin.bcltests.mscorlib Part 1 with pid 94797 -14:49:26.7861460 Xamarin.Hosting: Device 'iOS 13.3 (17C45) - iPhone X' booted. -14:49:31.0250650 Connection from 127.0.0.1:53085 saving logs to /Users/mandel/dotnet/macios/master/xamarin-macios/jenkins-results/tests/20200320_144720/mscorlib Part 1/122/test-classic-20200320_144845.log -14:49:31.0257860 Test run started -14:50:01.4773140 Tests have finished executing -14:50:01.7897340 Xamarin.Hosting: Simulated process has exited. -14:50:02.0809610 Test run completed -14:50:02.1691940 Test run succeeded \ No newline at end of file diff --git a/tests/xharness/Xharness.Tests/Samples/simulators.xml b/tests/xharness/Xharness.Tests/Samples/simulators.xml deleted file mode 100644 index 700467691560..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/simulators.xml +++ /dev/null @@ -1,925 +0,0 @@ - - - /Applications/Xcode113.app/Contents/Developer - - - - iOS 10.3 - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - 656129 - - - iOS 12.2 - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - 786944 - - - iOS 13.3 - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - 852736 - - - tvOS 10.2 - com.apple.CoreSimulator.SimRuntime.tvOS-10-2 - 655872 - - - tvOS 12.2 - com.apple.CoreSimulator.SimRuntime.tvOS-12-2 - 786944 - - - tvOS 13.3 - com.apple.CoreSimulator.SimRuntime.tvOS-13-3 - 852736 - - - watchOS 3.2 - com.apple.CoreSimulator.SimRuntime.watchOS-3-2 - 197120 - - - watchOS 5.2 - com.apple.CoreSimulator.SimRuntime.watchOS-5-2 - 328192 - - - watchOS 6.1 - com.apple.CoreSimulator.SimRuntime.watchOS-6-1 - 393473 - - - - - iPhone 4s - com.apple.CoreSimulator.SimDeviceType.iPhone-4s - IPhone - 327680 - 655359 - false - - - iPhone 5 - com.apple.CoreSimulator.SimDeviceType.iPhone-5 - IPhone - 393216 - 720895 - false - - - iPhone 5s - com.apple.CoreSimulator.SimDeviceType.iPhone-5s - IPhone - 458752 - 851967 - true - - - iPhone 6 Plus - com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus - IPhone - 524288 - 851967 - true - - - iPhone 6 - com.apple.CoreSimulator.SimDeviceType.iPhone-6 - IPhone - 524288 - 851967 - true - - - iPhone 6s - com.apple.CoreSimulator.SimDeviceType.iPhone-6s - IPhone - 589824 - 4294967295 - true - - - iPhone 6s Plus - com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus - IPhone - 589824 - 4294967295 - true - - - iPhone SE - com.apple.CoreSimulator.SimDeviceType.iPhone-SE - IPhone - 590592 - 4294967295 - true - - - iPhone 7 - com.apple.CoreSimulator.SimDeviceType.iPhone-7 - IPhone - 655360 - 4294967295 - true - - - iPhone 7 Plus - com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus - IPhone - 655360 - 4294967295 - true - - - iPhone 8 - com.apple.CoreSimulator.SimDeviceType.iPhone-8 - IPhone - 720896 - 4294967295 - true - - - iPhone 8 Plus - com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus - IPhone - 720896 - 4294967295 - true - - - iPhone X - com.apple.CoreSimulator.SimDeviceType.iPhone-X - IPhone - 720896 - 4294967295 - true - - - iPhone Xs - com.apple.CoreSimulator.SimDeviceType.iPhone-XS - IPhone - 786432 - 4294967295 - true - - - iPhone Xs Max - com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max - IPhone - 786432 - 4294967295 - true - - - iPhone Xʀ - com.apple.CoreSimulator.SimDeviceType.iPhone-XR - IPhone - 786432 - 4294967295 - true - - - iPhone 11 - com.apple.CoreSimulator.SimDeviceType.iPhone-11 - IPhone - 851968 - 4294967295 - true - - - iPhone 11 Pro - com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro - IPhone - 851968 - 4294967295 - true - - - iPhone 11 Pro Max - com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro-Max - IPhone - 851968 - 4294967295 - true - - - iPad 2 - com.apple.CoreSimulator.SimDeviceType.iPad-2 - IPad - 262912 - 655359 - false - - - iPad Retina - com.apple.CoreSimulator.SimDeviceType.iPad-Retina - IPad - 327936 - 655359 - false - - - iPad Air - com.apple.CoreSimulator.SimDeviceType.iPad-Air - IPad - 458752 - 851967 - true - - - iPad mini 2 - com.apple.CoreSimulator.SimDeviceType.iPad-mini-2 - IPad - 458752 - 851967 - true - - - iPad mini 3 - com.apple.CoreSimulator.SimDeviceType.iPad-mini-3 - IPad - 524544 - 851967 - true - - - iPad mini 4 - com.apple.CoreSimulator.SimDeviceType.iPad-mini-4 - IPad - 589824 - 4294967295 - true - - - iPad Air 2 - com.apple.CoreSimulator.SimDeviceType.iPad-Air-2 - IPad - 524288 - 4294967295 - true - - - iPad Pro (9.7-inch) - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch- - IPad - 655360 - 4294967295 - true - - - iPad Pro (12.9-inch) - com.apple.CoreSimulator.SimDeviceType.iPad-Pro - IPad - 590080 - 4294967295 - true - - - iPad (5th generation) - com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation- - IPad - 656128 - 4294967295 - true - - - iPad Pro (12.9-inch) (2nd generation) - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation- - IPad - 656128 - 4294967295 - true - - - iPad Pro (10.5-inch) - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch- - IPad - 656128 - 4294967295 - true - - - iPad (6th generation) - com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation- - IPad - 721664 - 4294967295 - true - - - iPad (7th generation) - com.apple.CoreSimulator.SimDeviceType.iPad--7th-generation- - IPad - 851968 - 4294967295 - true - - - iPad Pro (11-inch) - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch- - IPad - 786432 - 4294967295 - true - - - iPad Pro (12.9-inch) (3rd generation) - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation- - IPad - 786432 - 4294967295 - true - - - iPad mini (5th generation) - com.apple.CoreSimulator.SimDeviceType.iPad-mini--5th-generation- - IPad - 786944 - 4294967295 - true - - - iPad Air (3rd generation) - com.apple.CoreSimulator.SimDeviceType.iPad-Air--3rd-generation- - IPad - 786944 - 4294967295 - true - - - Apple TV - com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p - TV - 589824 - 4294967295 - true - - - Apple TV 4K - com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K - TV - 720896 - 4294967295 - true - - - Apple TV 4K (at 1080p) - com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p - TV - 720896 - 4294967295 - true - - - Apple Watch - 38mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm - Watch - 131072 - 327679 - false - - - Apple Watch - 42mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm - Watch - 131072 - 327679 - false - - - Apple Watch Series 2 - 38mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm - Watch - 196608 - 4294967295 - false - - - Apple Watch Series 2 - 42mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm - Watch - 196608 - 4294967295 - false - - - Apple Watch Series 3 - 38mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm - Watch - 262144 - 4294967295 - false - - - Apple Watch Series 3 - 42mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm - Watch - 262144 - 4294967295 - false - - - Apple Watch Series 4 - 40mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-40mm - Watch - 327680 - 4294967295 - false - - - Apple Watch Series 4 - 44mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-44mm - Watch - 327680 - 4294967295 - false - - - Apple Watch Series 5 - 40mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-40mm - Watch - 393216 - 4294967295 - false - - - Apple Watch Series 5 - 44mm - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-44mm - Watch - 393216 - 4294967295 - false - - - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-5 - /Users/mandel/Library/Developer/CoreSimulator/Devices/B0CF5BA5-318E-4FC8-8FC1-FB82D9F2FB42 - /Users/mandel/Library/Logs/CoreSimulator/B0CF5BA5-318E-4FC8-8FC1-FB82D9F2FB42 - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-5s - /Users/mandel/Library/Developer/CoreSimulator/Devices/78A86F96-8333-42DE-81F3-1D8CFEC1FB17 - /Users/mandel/Library/Logs/CoreSimulator/78A86F96-8333-42DE-81F3-1D8CFEC1FB17 - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus - /Users/mandel/Library/Developer/CoreSimulator/Devices/A921DF18-F3A1-4EDC-90DA-20E85D94685C - /Users/mandel/Library/Logs/CoreSimulator/A921DF18-F3A1-4EDC-90DA-20E85D94685C - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-6 - /Users/mandel/Library/Developer/CoreSimulator/Devices/62992D4C-C669-4C51-AAD4-1877891EC26B - /Users/mandel/Library/Logs/CoreSimulator/62992D4C-C669-4C51-AAD4-1877891EC26B - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-6s - /Users/mandel/Library/Developer/CoreSimulator/Devices/5C41C297-EDF4-4D97-804C-4186843CAC71 - /Users/mandel/Library/Logs/CoreSimulator/5C41C297-EDF4-4D97-804C-4186843CAC71 - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus - /Users/mandel/Library/Developer/CoreSimulator/Devices/619E6E2A-1B6E-42AC-93A5-2EE548689274 - /Users/mandel/Library/Logs/CoreSimulator/619E6E2A-1B6E-42AC-93A5-2EE548689274 - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-SE - /Users/mandel/Library/Developer/CoreSimulator/Devices/B239B550-AB0B-416C-987B-9AD8A856D429 - /Users/mandel/Library/Logs/CoreSimulator/B239B550-AB0B-416C-987B-9AD8A856D429 - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-7 - /Users/mandel/Library/Developer/CoreSimulator/Devices/216D7E4C-679F-4E57-9680-805930EA9D1E - /Users/mandel/Library/Logs/CoreSimulator/216D7E4C-679F-4E57-9680-805930EA9D1E - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus - /Users/mandel/Library/Developer/CoreSimulator/Devices/71AFDC06-B30E-4B2D-BF63-0EDDA0A62063 - /Users/mandel/Library/Logs/CoreSimulator/71AFDC06-B30E-4B2D-BF63-0EDDA0A62063 - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Air - /Users/mandel/Library/Developer/CoreSimulator/Devices/8C322CFC-A086-454E-BCA6-2BFC86E60B5E - /Users/mandel/Library/Logs/CoreSimulator/8C322CFC-A086-454E-BCA6-2BFC86E60B5E - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Air-2 - /Users/mandel/Library/Developer/CoreSimulator/Devices/FD05BCC6-2FE6-4F06-B954-5C835D10F14A - /Users/mandel/Library/Logs/CoreSimulator/FD05BCC6-2FE6-4F06-B954-5C835D10F14A - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch- - /Users/mandel/Library/Developer/CoreSimulator/Devices/0D858881-E7D8-47CE-A972-CB93727A1184 - /Users/mandel/Library/Logs/CoreSimulator/0D858881-E7D8-47CE-A972-CB93727A1184 - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro - /Users/mandel/Library/Developer/CoreSimulator/Devices/C5DF41A6-4AB2-4427-B4C3-504D59D1D6A2 - /Users/mandel/Library/Logs/CoreSimulator/C5DF41A6-4AB2-4427-B4C3-504D59D1D6A2 - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/19086AC5-F933-43BD-AEA6-1C1D0737E3DB - /Users/mandel/Library/Logs/CoreSimulator/19086AC5-F933-43BD-AEA6-1C1D0737E3DB - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/1688E430-E910-46EC-980C-A281C8BA8AAE - /Users/mandel/Library/Logs/CoreSimulator/1688E430-E910-46EC-980C-A281C8BA8AAE - - - com.apple.CoreSimulator.SimRuntime.iOS-10-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch- - /Users/mandel/Library/Developer/CoreSimulator/Devices/356B263C-8516-4F3B-BBF1-CA23FA5478E6 - /Users/mandel/Library/Logs/CoreSimulator/356B263C-8516-4F3B-BBF1-CA23FA5478E6 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-5s - /Users/mandel/Library/Developer/CoreSimulator/Devices/711BA51B-6261-4394-84A6-BE9F8B5D3B80 - /Users/mandel/Library/Logs/CoreSimulator/711BA51B-6261-4394-84A6-BE9F8B5D3B80 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus - /Users/mandel/Library/Developer/CoreSimulator/Devices/1D4E284E-E1F7-48BE-9975-E90C47A39B7C - /Users/mandel/Library/Logs/CoreSimulator/1D4E284E-E1F7-48BE-9975-E90C47A39B7C - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-6 - /Users/mandel/Library/Developer/CoreSimulator/Devices/0FE1F639-BE0D-42A8-BAE9-09D8656051D4 - /Users/mandel/Library/Logs/CoreSimulator/0FE1F639-BE0D-42A8-BAE9-09D8656051D4 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-6s - /Users/mandel/Library/Developer/CoreSimulator/Devices/08ED135B-B33B-439E-B188-2F84C1B478FC - /Users/mandel/Library/Logs/CoreSimulator/08ED135B-B33B-439E-B188-2F84C1B478FC - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus - /Users/mandel/Library/Developer/CoreSimulator/Devices/96A46A7E-0F6E-4627-A309-9306111A1B33 - /Users/mandel/Library/Logs/CoreSimulator/96A46A7E-0F6E-4627-A309-9306111A1B33 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-SE - /Users/mandel/Library/Developer/CoreSimulator/Devices/04DF2D48-4442-46EE-B3BE-695E403136C5 - /Users/mandel/Library/Logs/CoreSimulator/04DF2D48-4442-46EE-B3BE-695E403136C5 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-7 - /Users/mandel/Library/Developer/CoreSimulator/Devices/79AB7EDF-3FCB-4D2C-A390-7BB5936736B4 - /Users/mandel/Library/Logs/CoreSimulator/79AB7EDF-3FCB-4D2C-A390-7BB5936736B4 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus - /Users/mandel/Library/Developer/CoreSimulator/Devices/204656B8-0240-43FE-BF99-3B0F284FFB3C - /Users/mandel/Library/Logs/CoreSimulator/204656B8-0240-43FE-BF99-3B0F284FFB3C - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-8 - /Users/mandel/Library/Developer/CoreSimulator/Devices/FFFC5F6C-49EE-4796-8881-3416AE5F4708 - /Users/mandel/Library/Logs/CoreSimulator/FFFC5F6C-49EE-4796-8881-3416AE5F4708 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus - /Users/mandel/Library/Developer/CoreSimulator/Devices/AD320A80-FF13-4D28-8346-7962005732B0 - /Users/mandel/Library/Logs/CoreSimulator/AD320A80-FF13-4D28-8346-7962005732B0 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-X - /Users/mandel/Library/Developer/CoreSimulator/Devices/2FD14929-A33B-4690-86CD-42716A4DF2ED - /Users/mandel/Library/Logs/CoreSimulator/2FD14929-A33B-4690-86CD-42716A4DF2ED - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-XS - /Users/mandel/Library/Developer/CoreSimulator/Devices/E9914E48-7A63-493D-B7AA-D7AD90F0E312 - /Users/mandel/Library/Logs/CoreSimulator/E9914E48-7A63-493D-B7AA-D7AD90F0E312 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max - /Users/mandel/Library/Developer/CoreSimulator/Devices/FA0C5B13-CC3F-4044-8E7E-48100375A340 - /Users/mandel/Library/Logs/CoreSimulator/FA0C5B13-CC3F-4044-8E7E-48100375A340 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPhone-XR - /Users/mandel/Library/Developer/CoreSimulator/Devices/BB062731-8AA4-4A3A-A2A6-D032FC41F3B9 - /Users/mandel/Library/Logs/CoreSimulator/BB062731-8AA4-4A3A-A2A6-D032FC41F3B9 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Air - /Users/mandel/Library/Developer/CoreSimulator/Devices/9E8F8D70-7180-495B-853C-D51871E9F102 - /Users/mandel/Library/Logs/CoreSimulator/9E8F8D70-7180-495B-853C-D51871E9F102 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Air-2 - /Users/mandel/Library/Developer/CoreSimulator/Devices/4505497B-509A-4246-987D-119064149BF6 - /Users/mandel/Library/Logs/CoreSimulator/4505497B-509A-4246-987D-119064149BF6 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch- - /Users/mandel/Library/Developer/CoreSimulator/Devices/09D14A0A-4683-4E42-98A2-AB53310F197A - /Users/mandel/Library/Logs/CoreSimulator/09D14A0A-4683-4E42-98A2-AB53310F197A - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro - /Users/mandel/Library/Developer/CoreSimulator/Devices/1544537F-FDC8-40C9-AC08-A09FC4DD24B6 - /Users/mandel/Library/Logs/CoreSimulator/1544537F-FDC8-40C9-AC08-A09FC4DD24B6 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/A83C8C66-A7CF-46FD-8E4B-3A87FD2FF5A4 - /Users/mandel/Library/Logs/CoreSimulator/A83C8C66-A7CF-46FD-8E4B-3A87FD2FF5A4 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/257CA31A-CC5A-4C5C-B072-0D3A3D0A9451 - /Users/mandel/Library/Logs/CoreSimulator/257CA31A-CC5A-4C5C-B072-0D3A3D0A9451 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch- - /Users/mandel/Library/Developer/CoreSimulator/Devices/C006BEA4-CEDF-46E2-959C-96B8C9E6B6BA - /Users/mandel/Library/Logs/CoreSimulator/C006BEA4-CEDF-46E2-959C-96B8C9E6B6BA - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/43F3F691-8B57-47D6-898B-B2AAFCA53BFA - /Users/mandel/Library/Logs/CoreSimulator/43F3F691-8B57-47D6-898B-B2AAFCA53BFA - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch- - /Users/mandel/Library/Developer/CoreSimulator/Devices/3DF2CFFC-C279-485D-8379-CC50C2297EDD - /Users/mandel/Library/Logs/CoreSimulator/3DF2CFFC-C279-485D-8379-CC50C2297EDD - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/4F2E05BB-4945-445E-99E7-D81D4F83E248 - /Users/mandel/Library/Logs/CoreSimulator/4F2E05BB-4945-445E-99E7-D81D4F83E248 - - - com.apple.CoreSimulator.SimRuntime.iOS-12-2 - com.apple.CoreSimulator.SimDeviceType.iPad-Air--3rd-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/02177DD5-3EE1-4A8D-8277-BE95F4ACB1A5 - /Users/mandel/Library/Logs/CoreSimulator/02177DD5-3EE1-4A8D-8277-BE95F4ACB1A5 - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-8 - /Users/mandel/Library/Developer/CoreSimulator/Devices/CFD33BF1-FC9A-4674-BB49-80CFA47450A5 - /Users/mandel/Library/Logs/CoreSimulator/CFD33BF1-FC9A-4674-BB49-80CFA47450A5 - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus - /Users/mandel/Library/Developer/CoreSimulator/Devices/9D61D008-5A27-4B98-801A-0709897EA981 - /Users/mandel/Library/Logs/CoreSimulator/9D61D008-5A27-4B98-801A-0709897EA981 - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-X - /Users/mandel/Library/Developer/CoreSimulator/Devices/18F485DC-7F0A-440F-BEF9-5BE5954B0FB1 - /Users/mandel/Library/Logs/CoreSimulator/18F485DC-7F0A-440F-BEF9-5BE5954B0FB1 - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-11 - /Users/mandel/Library/Developer/CoreSimulator/Devices/ABC2A44A-789D-4C8B-88A7-0CD7C6BF316C - /Users/mandel/Library/Logs/CoreSimulator/ABC2A44A-789D-4C8B-88A7-0CD7C6BF316C - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro - /Users/mandel/Library/Developer/CoreSimulator/Devices/1840A231-2033-42A6-AEB4-B223235A2707 - /Users/mandel/Library/Logs/CoreSimulator/1840A231-2033-42A6-AEB4-B223235A2707 - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro-Max - /Users/mandel/Library/Developer/CoreSimulator/Devices/FB4347FF-11B6-4487-BECC-0B556BAD3E89 - /Users/mandel/Library/Logs/CoreSimulator/FB4347FF-11B6-4487-BECC-0B556BAD3E89 - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch- - /Users/mandel/Library/Developer/CoreSimulator/Devices/972FB6FB-6BC5-4FD8-B8FB-BC4B08DAC817 - /Users/mandel/Library/Logs/CoreSimulator/972FB6FB-6BC5-4FD8-B8FB-BC4B08DAC817 - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPad--7th-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/C519CBBA-AAAD-4777-B599-8A30085AABCB - /Users/mandel/Library/Logs/CoreSimulator/C519CBBA-AAAD-4777-B599-8A30085AABCB - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch- - /Users/mandel/Library/Developer/CoreSimulator/Devices/F7FCC57E-97CA-410F-B759-DFB395F0062C - /Users/mandel/Library/Logs/CoreSimulator/F7FCC57E-97CA-410F-B759-DFB395F0062C - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/80096DEA-A0BC-4755-8AB4-F941B6DD7438 - /Users/mandel/Library/Logs/CoreSimulator/80096DEA-A0BC-4755-8AB4-F941B6DD7438 - - - com.apple.CoreSimulator.SimRuntime.iOS-13-3 - com.apple.CoreSimulator.SimDeviceType.iPad-Air--3rd-generation- - /Users/mandel/Library/Developer/CoreSimulator/Devices/8094F147-86A1-4196-BFB9-040BAC65B9BF - /Users/mandel/Library/Logs/CoreSimulator/8094F147-86A1-4196-BFB9-040BAC65B9BF - - - com.apple.CoreSimulator.SimRuntime.tvOS-10-2 - com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p - /Users/mandel/Library/Developer/CoreSimulator/Devices/FC0AD7D8-40E1-4BEC-BC84-ECE1796E3B10 - /Users/mandel/Library/Logs/CoreSimulator/FC0AD7D8-40E1-4BEC-BC84-ECE1796E3B10 - - - com.apple.CoreSimulator.SimRuntime.tvOS-12-2 - com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p - /Users/mandel/Library/Developer/CoreSimulator/Devices/62179381-3483-41F2-ABD2-7C69E46B2C3C - /Users/mandel/Library/Logs/CoreSimulator/62179381-3483-41F2-ABD2-7C69E46B2C3C - - - com.apple.CoreSimulator.SimRuntime.tvOS-12-2 - com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K - /Users/mandel/Library/Developer/CoreSimulator/Devices/C10D4992-1C46-474D-871B-B89D0817CFB4 - /Users/mandel/Library/Logs/CoreSimulator/C10D4992-1C46-474D-871B-B89D0817CFB4 - - - com.apple.CoreSimulator.SimRuntime.tvOS-12-2 - com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p - /Users/mandel/Library/Developer/CoreSimulator/Devices/73EAFA5D-04C7-4194-8D51-6E32C913C3B6 - /Users/mandel/Library/Logs/CoreSimulator/73EAFA5D-04C7-4194-8D51-6E32C913C3B6 - - - com.apple.CoreSimulator.SimRuntime.tvOS-13-3 - com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p - /Users/mandel/Library/Developer/CoreSimulator/Devices/3A12BAFF-0DAA-4052-AB0D-743AB85CE030 - /Users/mandel/Library/Logs/CoreSimulator/3A12BAFF-0DAA-4052-AB0D-743AB85CE030 - - - com.apple.CoreSimulator.SimRuntime.tvOS-13-3 - com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K - /Users/mandel/Library/Developer/CoreSimulator/Devices/FD2A3BE2-3E95-473E-99D2-DF0733F1CEED - /Users/mandel/Library/Logs/CoreSimulator/FD2A3BE2-3E95-473E-99D2-DF0733F1CEED - - - com.apple.CoreSimulator.SimRuntime.tvOS-13-3 - com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p - /Users/mandel/Library/Developer/CoreSimulator/Devices/2599FF00-17DD-43F7-BFC4-90693C145398 - /Users/mandel/Library/Logs/CoreSimulator/2599FF00-17DD-43F7-BFC4-90693C145398 - - - com.apple.CoreSimulator.SimRuntime.watchOS-3-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/F00FA51A-D353-4DD0-9631-FBAE0CE79D0F - /Users/mandel/Library/Logs/CoreSimulator/F00FA51A-D353-4DD0-9631-FBAE0CE79D0F - - - com.apple.CoreSimulator.SimRuntime.watchOS-3-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/7E4D7EC2-45C3-41A5-A7CD-78BE9610E02B - /Users/mandel/Library/Logs/CoreSimulator/7E4D7EC2-45C3-41A5-A7CD-78BE9610E02B - - - com.apple.CoreSimulator.SimRuntime.watchOS-3-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/7209E5D6-9F1B-4067-96D7-342D403CD805 - /Users/mandel/Library/Logs/CoreSimulator/7209E5D6-9F1B-4067-96D7-342D403CD805 - - - com.apple.CoreSimulator.SimRuntime.watchOS-3-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/7BDF181F-3D32-4ECB-B2D6-0D73353DD0AB - /Users/mandel/Library/Logs/CoreSimulator/7BDF181F-3D32-4ECB-B2D6-0D73353DD0AB - - - com.apple.CoreSimulator.SimRuntime.watchOS-5-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/99F89C62-A028-4752-96D3-5E57CDAEDA22 - /Users/mandel/Library/Logs/CoreSimulator/99F89C62-A028-4752-96D3-5E57CDAEDA22 - - - com.apple.CoreSimulator.SimRuntime.watchOS-5-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/8DF7353A-CE2C-45E2-944D-FF12FBFBF24B - /Users/mandel/Library/Logs/CoreSimulator/8DF7353A-CE2C-45E2-944D-FF12FBFBF24B - - - com.apple.CoreSimulator.SimRuntime.watchOS-5-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/3F577C08-9F99-4B9F-8EFC-CFF64B24DB51 - /Users/mandel/Library/Logs/CoreSimulator/3F577C08-9F99-4B9F-8EFC-CFF64B24DB51 - - - com.apple.CoreSimulator.SimRuntime.watchOS-5-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/E26C48DB-9780-4342-84E2-783F4FF86286 - /Users/mandel/Library/Logs/CoreSimulator/E26C48DB-9780-4342-84E2-783F4FF86286 - - - com.apple.CoreSimulator.SimRuntime.watchOS-5-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-40mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/121B2CE2-B036-4BB4-B54A-A03F5431091B - /Users/mandel/Library/Logs/CoreSimulator/121B2CE2-B036-4BB4-B54A-A03F5431091B - - - com.apple.CoreSimulator.SimRuntime.watchOS-5-2 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-44mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/7764F572-0B81-4353-9D19-AA5E358425C2 - /Users/mandel/Library/Logs/CoreSimulator/7764F572-0B81-4353-9D19-AA5E358425C2 - - - com.apple.CoreSimulator.SimRuntime.watchOS-6-1 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/BB2F9CF0-A928-4909-867A-525A937D7390 - /Users/mandel/Library/Logs/CoreSimulator/BB2F9CF0-A928-4909-867A-525A937D7390 - - - com.apple.CoreSimulator.SimRuntime.watchOS-6-1 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/D9FC8E35-8CD2-4E3F-A660-24CAF1304479 - /Users/mandel/Library/Logs/CoreSimulator/D9FC8E35-8CD2-4E3F-A660-24CAF1304479 - - - com.apple.CoreSimulator.SimRuntime.watchOS-6-1 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-40mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/8EC34527-72DB-4A4D-B268-79C838189492 - /Users/mandel/Library/Logs/CoreSimulator/8EC34527-72DB-4A4D-B268-79C838189492 - - - com.apple.CoreSimulator.SimRuntime.watchOS-6-1 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-44mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/CC509130-B1EC-4400-B2AB-730B602F7E03 - /Users/mandel/Library/Logs/CoreSimulator/CC509130-B1EC-4400-B2AB-730B602F7E03 - - - com.apple.CoreSimulator.SimRuntime.watchOS-6-1 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-40mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/9B798995-5A29-45E1-BF89-6D29BB2864D3 - /Users/mandel/Library/Logs/CoreSimulator/9B798995-5A29-45E1-BF89-6D29BB2864D3 - - - com.apple.CoreSimulator.SimRuntime.watchOS-6-1 - com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-44mm - /Users/mandel/Library/Developer/CoreSimulator/Devices/77F07B96-D2E4-4F04-B958-B68E2FBCC2ED - /Users/mandel/Library/Logs/CoreSimulator/77F07B96-D2E4-4F04-B958-B68E2FBCC2ED - - - - - 62992D4C-C669-4C51-AAD4-1877891EC26B - F00FA51A-D353-4DD0-9631-FBAE0CE79D0F - - - 18F485DC-7F0A-440F-BEF9-5BE5954B0FB1 - BB2F9CF0-A928-4909-867A-525A937D7390 - - - 1840A231-2033-42A6-AEB4-B223235A2707 - 9B798995-5A29-45E1-BF89-6D29BB2864D3 - - - FB4347FF-11B6-4487-BECC-0B556BAD3E89 - 77F07B96-D2E4-4F04-B958-B68E2FBCC2ED - - - - \ No newline at end of file diff --git a/tests/xharness/Xharness.Tests/Samples/xUnitSample.xml b/tests/xharness/Xharness.Tests/Samples/xUnitSample.xml deleted file mode 100644 index b8603de904a5..000000000000 --- a/tests/xharness/Xharness.Tests/Samples/xUnitSample.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/xharness/Xharness.Tests/TestImporter/Templates/Tests/PListExtensionsTests.cs b/tests/xharness/Xharness.Tests/TestImporter/Templates/Tests/PListExtensionsTests.cs deleted file mode 100644 index 760cd57557e3..000000000000 --- a/tests/xharness/Xharness.Tests/TestImporter/Templates/Tests/PListExtensionsTests.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; -using System.Xml; -using Microsoft.DotNet.XHarness.iOS.Shared.Utilities; -using NUnit.Framework; - -namespace Xharness.Tests.TestImporter.Templates.Tests { - - public class PListExtensionsTests { - private XmlDocument plist; - - [SetUp] - public void SetUp () - { - plist = CreateResultSample (); - } - - /// - /// Creates a sample pList to be used with the tests and returns the temp file in which it was stored. - /// - /// The path where the sample plist can be found. - XmlDocument CreateResultSample () - { - var name = GetType ().Assembly.GetManifestResourceNames () - .FirstOrDefault (a => a.EndsWith ("Info.plist", StringComparison.Ordinal)); - var tempPath = Path.GetTempFileName (); - var byteOrderMarkUtf8 = Encoding.UTF8.GetString (Encoding.UTF8.GetPreamble ()); // I hate BOM - using var sampleStream = new StreamReader (GetType ().Assembly.GetManifestResourceStream (name)); - - // create the document with the plist and return it - var doc = new XmlDocument (); - var settings = new XmlReaderSettings () { - XmlResolver = null, - DtdProcessing = DtdProcessing.Parse, - }; - using var reader = XmlReader.Create (sampleStream, settings); - doc.Load (reader); - return doc; - } - - [Test] - public void SetMinimumOSVersion () - { - var version = "MyMinVersion"; - plist.SetMinimumOSVersion (version); - Assert.AreEqual (version, plist.GetMinimumOSVersion ()); - } - - [Test] - public void SetNullMinimumOSVersion () => Assert.Throws (() => plist.SetMinimumOSVersion (null)); - - [Test] - public void SetMinimummacOSVersion () - { - var version = "MyMaccMinVersion"; - plist.SetMinimummacOSVersion (version); - Assert.AreEqual (version, plist.GetMinimummacOSVersion ()); - } - - [Test] - public void SetNullMinimummacOSVersion () => Assert.Throws (() => plist.SetMinimummacOSVersion (null)); - - [Test] - public void SetCFBundleDisplayName () - { - var displayName = "MySuperApp"; - plist.SetCFBundleDisplayName (displayName); - Assert.AreEqual (displayName, plist.GetCFBundleDisplayName ()); - } - - [Test] - public void SetNullCFBundleDisplayName () => Assert.Throws (() => plist.SetCFBundleDisplayName (null)); - - [Test] - public void SetCFBundleIdentifier () - { - var bundleIdentifier = "my.company.super.app"; - plist.SetCFBundleIdentifier (bundleIdentifier); - Assert.AreEqual (bundleIdentifier, plist.GetCFBundleIdentifier ()); - } - - [Test] - public void SetNullCFBundleIdentifier () => Assert.Throws (() => plist.SetCFBundleIdentifier (null)); - - [Test] - public void SetCFBundleName () - { - var bundleName = "MySuper.app"; - plist.SetCFBundleName (bundleName); - Assert.AreEqual (bundleName, plist.GetCFBundleName ()); - } - - [Test] - public void SetNullCFBundleName () => Assert.Throws (() => plist.SetCFBundleName (null)); - } -} diff --git a/tests/xharness/Xharness.Tests/TestImporter/Tests/ProjectDefinitionTests.cs b/tests/xharness/Xharness.Tests/TestImporter/Tests/ProjectDefinitionTests.cs deleted file mode 100644 index e9428d82afe3..000000000000 --- a/tests/xharness/Xharness.Tests/TestImporter/Tests/ProjectDefinitionTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using Moq; -using NUnit.Framework; -using Xharness.TestImporter; - -namespace Xharness.Tests.TestImporter.Tests { - public class ProjectDefinitionTests { - - Mock assemblyLocator; - Mock factory; - - [SetUp] - public void SetUp () - { - assemblyLocator = new Mock (); - factory = new Mock (); - } - - [TearDown] - public void TearDown () - { - assemblyLocator = null; - } - - [Test] - public void GetTypeForAssembliesNullMonoPath () - { - var projectDefinition = new ProjectDefinition ("MyProject", assemblyLocator.Object, factory.Object, new List ()); - Assert.Throws (() => projectDefinition.GetTypeForAssemblies (null, Platform.iOS)); - } - } -} diff --git a/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/AssemblyLocatorTest.cs b/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/AssemblyLocatorTest.cs deleted file mode 100644 index 98933167fb6d..000000000000 --- a/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/AssemblyLocatorTest.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.IO; -using NUnit.Framework; -using Xharness.TestImporter; -using Xharness.TestImporter.Xamarin; - -namespace Xharness.Tests.TestImporter.Xamarin.Tests { - - // very simple class, but we want to make sure that iOS, tvOS get the iosDownload and the mac - // versions get the mac download - [TestFixture] - public class AssemblyLocatorTest { - - const string iOSPath = "/path/to/ios/download"; - const string macOSPath = "/path/to/mac/download"; - AssemblyLocator assemblyLocator = new AssemblyLocator { - iOSMonoSDKPath = iOSPath, - MacMonoSDKPath = macOSPath, - }; - - [TestCase (Platform.iOS, iOSPath)] - [TestCase (Platform.TvOS, iOSPath)] - public void GetAssembliesRootLocationTest (Platform platform, string expected) - => Assert.AreEqual (expected, assemblyLocator.GetAssembliesRootLocation (platform)); - } -} diff --git a/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/TestAssemblyDefinitionTest.cs b/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/TestAssemblyDefinitionTest.cs deleted file mode 100644 index 536261224452..000000000000 --- a/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/TestAssemblyDefinitionTest.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using Moq; -using NUnit.Framework; -using Xharness.TestImporter; -using Xharness.TestImporter.Xamarin; - -namespace Xharness.Tests.TestImporter.Tests { - public class TestAssemblyDefinitionTest { - - Mock assemblyLocator; - - [SetUp] - public void SetUp () - { - assemblyLocator = new Mock (); - } - - [TearDown] - public void TearDown () - { - assemblyLocator = null; - } - - [Test] - public void GetPathNullMonoRoot () - { - var testAssemblyDefinition = new TestAssemblyDefinition ("monotouch_System.Json.Microsoft_test.dll", assemblyLocator.Object); - Assert.Throws (() => testAssemblyDefinition.GetPath (Platform.iOS)); - } - - [Test] - public void IsNotXUnit () - { - var testAssemblyDefinition = new TestAssemblyDefinition ("monotouch_System.Json.Microsoft_test.dll", assemblyLocator.Object); - Assert.False (testAssemblyDefinition.IsXUnit); - } - - [Test] - public void IsXUnit () - { - var testAssemblyDefinition = new TestAssemblyDefinition ("monotouch_System.Json.Microsoft_xunit-test.dll", assemblyLocator.Object); - Assert.True (testAssemblyDefinition.IsXUnit); - } - - } -} diff --git a/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/XamariniOSTemplateTest.cs b/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/XamariniOSTemplateTest.cs deleted file mode 100644 index c58af8e9e845..000000000000 --- a/tests/xharness/Xharness.Tests/TestImporter/Xamarin/Tests/XamariniOSTemplateTest.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.IO; -using System.Text; -using Moq; -using NUnit.Framework; -using Xharness.TestImporter; -using Xharness.TestImporter.Templates; -using Xharness.TestImporter.Templates.Managed; - -namespace Xharness.Tests.TestImporter.Xamarin.Tests { - - [TestFixture] - public class XamariniOSTemplateTest { - - string outputdir; - Mock assemlyLocator; - Mock projectFilter; - XamariniOSTemplate template; - - [SetUp] - public void SetUp () - { - outputdir = Path.GetTempFileName (); - File.Delete (outputdir); - Directory.CreateDirectory (outputdir); - assemlyLocator = new Mock (); - projectFilter = new Mock (); - template = new XamariniOSTemplate { - AssemblyLocator = assemlyLocator.Object, - ProjectFilter = projectFilter.Object, - OutputDirectoryPath = outputdir, - }; - } - - [TearDown] - public void TearDown () - { - if (Directory.Exists (outputdir)) - Directory.Delete (outputdir, true); - outputdir = null; - assemlyLocator = null; - projectFilter = null; - template = null; - } - [TestCase ("iOSProject", Platform.iOS, "iOSProject.csproj")] - [TestCase ("TvOSProject", Platform.TvOS, "TvOSProject-tvos.csproj")] - public void GetProjectPathTest (string projectName, Platform platform, string expectedName) - { - // ignore the fact that all params are the same, we do not care - var path = template.GetProjectPath (projectName, platform); - Assert.AreEqual (Path.Combine (template.OutputDirectoryPath, "generated", platform.ToString (), projectName, expectedName), path); - } - - [TestCase ("/usr/path", Platform.iOS, "Info.plist")] - [TestCase ("/usr/second/path", Platform.TvOS, "Info-tvos.plist")] - public void GetPListPathTest (string rootDir, Platform platform, string expectedName) - { - var path = XamariniOSTemplate.GetPListPath (rootDir, platform); - Assert.AreEqual (Path.Combine (rootDir, expectedName), path); - } - - [TestCase ("System.Xml.dll")] - [TestCase ("MyAssembly.dll")] - public void GetReferenceNodeNullHintTest (string assembly) - { - var expected = $""; - Assert.AreEqual (expected, XamariniOSTemplate.GetReferenceNode (assembly)); - } - - [TestCase ("System.Xml.dll", "my/path/to/the/dll")] - [TestCase ("MyAssembly.dll", "thepath")] - public void GetReferenceNodeTest (string assembly, string hint) - { - var fixedHint = hint.Replace ("/", "\\"); - var sb = new StringBuilder (); - sb.AppendLine ($""); - sb.AppendLine ($"{fixedHint}"); - sb.AppendLine (""); - var expected = sb.ToString (); - Assert.AreEqual (expected, XamariniOSTemplate.GetReferenceNode (assembly, hint)); - } - - [TestCase ("my/path/to/the/dll")] - [TestCase ("my/other/path/to/the/dll")] - public void GetRegisterTypeNodeTest (string registerPath) - { - var fixedPath = registerPath.Replace ("/", "\\"); - var sb = new StringBuilder (); - sb.AppendLine ($""); - sb.AppendLine ($"{Path.GetFileName (registerPath)}"); - sb.AppendLine (""); - var expected = sb.ToString (); - Assert.AreEqual (expected, XamariniOSTemplate.GetRegisterTypeNode (registerPath)); - } - - [TestCase ("/path/to/resource/my-ignore-file.ignore")] - [TestCase ("/path/to/mono/my-trait-file.txt")] - public void GetContentNodeTest (string contentFile) - { - var fixedPath = contentFile.Replace ("/", "\\"); - var sb = new StringBuilder (); - sb.AppendLine ($""); - sb.AppendLine ($"{Path.GetFileName (contentFile)}"); - sb.AppendLine ("PreserveNewest"); - sb.AppendLine (""); - var expected = sb.ToString (); - Assert.AreEqual (expected, XamariniOSTemplate.GetContentNode (contentFile)); - } - } -} diff --git a/tests/xharness/Xharness.Tests/Tests/AppRunnerTests.cs b/tests/xharness/Xharness.Tests/Tests/AppRunnerTests.cs deleted file mode 100644 index 0554c9791900..000000000000 --- a/tests/xharness/Xharness.Tests/Tests/AppRunnerTests.cs +++ /dev/null @@ -1,803 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.DotNet.XHarness.Common.CLI; -using Microsoft.DotNet.XHarness.Common.Execution; -using Microsoft.DotNet.XHarness.Common.Logging; -using Microsoft.DotNet.XHarness.Common.Utilities; -using Microsoft.DotNet.XHarness.iOS.Shared; -using Microsoft.DotNet.XHarness.iOS.Shared.Execution; -using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; -using Microsoft.DotNet.XHarness.iOS.Shared.Listeners; -using Microsoft.DotNet.XHarness.iOS.Shared.Logging; -using Moq; -using NUnit.Framework; - -namespace Xharness.Tests { - [TestFixture] - public class AppRunnerTests { - - const string appName = "com.xamarin.bcltests.SystemXunit"; - const string xcodePath = "/path/to/xcode"; - const string mlaunchPath = "/path/to/mlaunch"; - const int listenerPort = 1020; - - static readonly string outputPath = Path.GetDirectoryName (Assembly.GetAssembly (typeof (AppRunnerTests)).Location); - static readonly string sampleProjectPath = Path.Combine (outputPath, "Samples", "TestProject"); - static readonly string appPath = Path.Combine (sampleProjectPath, "bin", appName + ".app"); - static readonly string projectFilePath = Path.Combine (sampleProjectPath, "SystemXunit.csproj"); - - static readonly IHardwareDevice [] mockDevices = new IHardwareDevice [] { - new Device( - buildVersion: "17A577", - deviceClass: DeviceClass.iPhone, - deviceIdentifier: "8A450AA31EA94191AD6B02455F377CC1", - interfaceType: "Usb", - isUsableForDebugging: true, - name: "Test iPhone", - productType: "iPhone12,1", - productVersion: "13.0" - ), - new Device( - buildVersion: "13G36", - deviceClass: DeviceClass.iPad, - deviceIdentifier: "E854B2C3E7C8451BAF8053EC4DAAEE49", - interfaceType: "Usb", - isUsableForDebugging: true, - name: "Test iPad", - productType: "iPad2,1", - productVersion: "9.3.5" - ) - }; - - Mock processManager; - Mock simulators; - Mock devices; - Mock simpleListener; - Mock snapshotReporter; - Mock logs; - Mock mainLog; - - ISimulatorLoaderFactory simulatorsFactory; - IDeviceLoaderFactory devicesFactory; - ISimpleListenerFactory listenerFactory; - ICrashSnapshotReporterFactory snapshotReporterFactory; - IAppBundleInformationParser appBundleInformationParser; - - [SetUp] - public void SetUp () - { - logs = new Mock (); - logs.SetupGet (x => x.Directory).Returns (Path.Combine (outputPath, "logs")); - - processManager = new Mock (); - simulators = new Mock (); - devices = new Mock (); - simpleListener = new Mock (); - snapshotReporter = new Mock (); - - var mock1 = new Mock (); - mock1.Setup (m => m.CreateLoader ()).Returns (simulators.Object); - simulatorsFactory = mock1.Object; - - var mock2 = new Mock (); - mock2.Setup (m => m.CreateLoader ()).Returns (devices.Object); - devicesFactory = mock2.Object; - - var mock3 = new Mock (); - mock3 - .Setup (m => m.Create (It.IsAny (), It.IsAny (), It.IsAny (), It.IsAny (), It.IsAny (), It.IsAny ())) - .Returns ((ListenerTransport.Tcp, simpleListener.Object, "listener-temp-file")); - listenerFactory = mock3.Object; - simpleListener.Setup (x => x.InitializeAndGetPort ()).Returns (listenerPort); - - var mock4 = new Mock (); - mock4.Setup (m => m.Create (It.IsAny (), It.IsAny (), It.IsAny (), It.IsAny ())).Returns (snapshotReporter.Object); - snapshotReporterFactory = mock4.Object; - - var mock5 = new Mock (); - mock5 - .Setup (x => x.ParseFromProject (It.IsAny (), It.IsAny (), It.IsAny ())) - .ReturnsAsync (new AppBundleInformation (appName, appName, appPath, appPath, true, null)); - - appBundleInformationParser = mock5.Object; - - mainLog = new Mock (); - - Directory.CreateDirectory (appPath); - } - - [TearDown] - public void TearDown () - { - Directory.Delete (appPath, true); - } - - [Test] - public void InitializeTest () - { - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - snapshotReporterFactory, - Mock.Of (), - Mock.Of (), - Mock.Of (), - TestTarget.Simulator_iOS64, - Mock.Of (), - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug"); - appRunner.InitializeAsync ().Wait (); - - Assert.AreEqual (appName, appRunner.AppInformation.AppName); - Assert.AreEqual (appPath, appRunner.AppInformation.AppPath); - Assert.AreEqual (appPath, appRunner.AppInformation.LaunchAppPath); - Assert.AreEqual (appName, appRunner.AppInformation.BundleIdentifier); - } - - [Test] - public void InstallToSimulatorTest () - { - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - snapshotReporterFactory, - Mock.Of (), - Mock.Of (), - Mock.Of (), - TestTarget.Simulator_iOS64, - Mock.Of (), - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug"); - appRunner.InitializeAsync ().Wait (); - - var exception = Assert.ThrowsAsync ( - async () => await appRunner.InstallAsync (new CancellationToken ()), - "Install should not be allowed on a simulator"); - } - - [Test] - public void UninstallToSimulatorTest () - { - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - snapshotReporterFactory, - Mock.Of (), - Mock.Of (), - Mock.Of (), - TestTarget.Simulator_iOS64, - Mock.Of (), - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug"); - appRunner.InitializeAsync ().Wait (); - - var exception = Assert.ThrowsAsync ( - async () => await appRunner.UninstallAsync (), - "Uninstall should not be allowed on a simulator"); - } - - [Test] - public void InstallWhenNoDevicesTest () - { - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - snapshotReporterFactory, - Mock.Of (), - Mock.Of (), - Mock.Of (), - TestTarget.Device_iOS, - Mock.Of (), - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug"); - appRunner.InitializeAsync ().Wait (); - - devices.Setup (x => x.ConnectedDevices).Returns (new IHardwareDevice [0]); - - Assert.ThrowsAsync ( - async () => await appRunner.InstallAsync (new CancellationToken ()), - "Install requires connected devices"); - } - - [Test] - public async Task InstallOnDeviceTest () - { - var harness = Mock.Of (x => x.Verbosity == 2); - - var processResult = new ProcessExecutionResult () { ExitCode = 1, TimedOut = false }; - processManager.SetReturnsDefault (Task.FromResult (processResult)); - - devices.Setup (d => d.FindDevice (It.IsAny (), It.IsAny (), false, false, CancellationToken.None)).ReturnsAsync (mockDevices [0]); - - // Act - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - snapshotReporterFactory, - Mock.Of (), - Mock.Of (), - Mock.Of (), - TestTarget.Device_iOS, - harness, - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug"); - appRunner.InitializeAsync ().Wait (); - - CancellationToken cancellationToken = new CancellationToken (); - var result = await appRunner.InstallAsync (cancellationToken); - - // Verify - Assert.AreEqual (1, result.ExitCode); - - var expectedArgs = $"-v -v -v --installdev {StringUtils.FormatArguments (appPath)} --devname \"{mockDevices [0].Name}\""; - - processManager.Verify (x => x.ExecuteCommandAsync ( - It.Is (args => args.AsCommandLine () == expectedArgs), - mainLog.Object, - TimeSpan.FromHours (1), - null, - 5, - cancellationToken)); - } - - [Test] - public async Task UninstallFromDeviceTest () - { - var harness = Mock.Of (x => x.Verbosity == 1); - - var processResult = new ProcessExecutionResult () { ExitCode = 3, TimedOut = false }; - processManager.SetReturnsDefault (Task.FromResult (processResult)); - - devices.Setup (d => d.FindDevice (It.IsAny (), It.IsAny (), false, false, CancellationToken.None)).ReturnsAsync (mockDevices [1]); - - // Act - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - snapshotReporterFactory, - Mock.Of (), - Mock.Of (), - Mock.Of (), - TestTarget.Device_iOS, - harness, - mainLog.Object, - logs.Object, - projectFilePath: Path.Combine (sampleProjectPath, "SystemXunit.csproj"), - buildConfiguration: "Debug"); - appRunner.InitializeAsync ().Wait (); - - var result = await appRunner.UninstallAsync (); - - // Verify - Assert.AreEqual (3, result.ExitCode); - - var expectedArgs = $"-v -v --uninstalldevbundleid {StringUtils.FormatArguments (appName)} --devname \"Test iPad\""; - - processManager.Verify (x => x.ExecuteCommandAsync ( - It.Is (args => args.AsCommandLine () == expectedArgs), - mainLog.Object, - TimeSpan.FromMinutes (1), - null, - 5, - null)); - } - - [Test] - public async Task RunOnSimulatorWithNoAvailableSimulatorTest () - { - devices.Setup (x => x.ConnectedDevices).Returns (mockDevices.Reverse ()); - - // Crash reporter - var crashReporterFactory = new Mock (); - crashReporterFactory - .Setup (x => x.Create (mainLog.Object, It.IsAny (), false, null)) - .Returns (snapshotReporter.Object); - - // Mock finding simulators - simulators - .Setup (x => x.LoadDevices (It.IsAny (), false, false, false, true, CancellationToken.None)) - .Returns (Task.FromResult (true)); - - string simulatorLogPath = Path.Combine (Path.GetTempPath (), "simulator-logs"); - - simulators - .Setup (x => x.FindSimulators (TestTarget.Simulator_tvOS, mainLog.Object, true, false, CancellationToken.None)) - .ReturnsAsync ((null, null)); - - var listenerLogFile = new Mock (); - - logs - .Setup (x => x.Create (It.IsAny (), "TestLog", It.IsAny ())) - .Returns (listenerLogFile.Object); - - simpleListener.SetupGet (x => x.ConnectedTask).Returns (Task.FromResult (true)); - - var captureLog = new Mock (); - captureLog.SetupGet (x => x.FullPath).Returns (simulatorLogPath); - - var captureLogFactory = new Mock (); - captureLogFactory - .Setup (x => x.Create ( - Path.Combine (logs.Object.Directory, "tvos.log"), - "/path/to/simulator.log", - true, - It.IsAny ())) - .Returns (captureLog.Object); - var testReporterFactory = new Mock (); - var testReporter = new Mock (); - testReporterFactory.SetReturnsDefault (testReporter.Object); - testReporter.Setup (r => r.ParseResult ()).Returns (() => { - return Task.FromResult<(TestExecutingResult, string)> ((TestExecutingResult.Succeeded, null)); - }); - testReporter.Setup (r => r.Success).Returns (true); - - // Act - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - crashReporterFactory.Object, - captureLogFactory.Object, - Mock.Of (), - testReporterFactory.Object, - TestTarget.Simulator_tvOS, - GetMockedHarness (), - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug", - timeoutMultiplier: 2); - appRunner.InitializeAsync ().Wait (); - - var result = await appRunner.RunAsync (); - - // Verify - Assert.AreEqual (1, result); - - mainLog.Verify (x => x.WriteLine ("Test run completed"), Times.Never); - - simpleListener.Verify (x => x.InitializeAndGetPort (), Times.AtLeastOnce); - simpleListener.Verify (x => x.StartAsync (), Times.AtLeastOnce); - - simulators.VerifyAll (); - } - - [Test] - public async Task RunOnSimulatorSuccessfullyTest () - { - var harness = GetMockedHarness (); - - devices.Setup (x => x.ConnectedDevices).Returns (mockDevices.Reverse ()); - - // Crash reporter - var crashReporterFactory = new Mock (); - crashReporterFactory - .Setup (x => x.Create (mainLog.Object, It.IsAny (), false, null)) - .Returns (snapshotReporter.Object); - - // Mock finding simulators - simulators - .Setup (x => x.LoadDevices (It.IsAny (), false, false, false, true, CancellationToken.None)) - .Returns (Task.FromResult (true)); - - string simulatorLogPath = Path.Combine (Path.GetTempPath (), "simulator-logs"); - - var simulator = new Mock (); - simulator.SetupGet (x => x.Name).Returns ("Test iPhone simulator"); - simulator.SetupGet (x => x.UDID).Returns ("58F21118E4D34FD69EAB7860BB9B38A0"); - simulator.SetupGet (x => x.LogPath).Returns (simulatorLogPath); - simulator.SetupGet (x => x.SystemLog).Returns (Path.Combine (simulatorLogPath, "system.log")); - - simulators - .Setup (x => x.FindSimulators (TestTarget.Simulator_iOS64, mainLog.Object, true, false, CancellationToken.None)) - .ReturnsAsync ((simulator.Object, null)); - - var testResultFilePath = Path.GetTempFileName (); - var listenerLogFile = Mock.Of (x => x.FullPath == testResultFilePath); - File.WriteAllLines (testResultFilePath, new [] { "Some result here", "Tests run: 124", "Some result there" }); - - logs - .Setup (x => x.Create (It.IsAny (), It.IsAny (), It.IsAny ())) - .Returns (listenerLogFile); - - logs - .Setup (x => x.CreateFile (It.IsAny (), It.IsAny ())) - .Returns ($"/path/to/log-{Guid.NewGuid ()}.log"); - - simpleListener.SetupGet (x => x.ConnectedTask).Returns (Task.FromResult (true)); - - var captureLog = new Mock (); - captureLog.SetupGet (x => x.FullPath).Returns (simulatorLogPath); - - var captureLogFactory = new Mock (); - captureLogFactory - .Setup (x => x.Create ( - Path.Combine (logs.Object.Directory, simulator.Object.Name + ".log"), - simulator.Object.SystemLog, - true, - It.IsAny ())) - .Returns (captureLog.Object); - - var expectedArgs = $"--sdkroot {StringUtils.FormatArguments (xcodePath)} -v -v " + - $"-argument=-connection-mode -argument=none -argument=-app-arg:-autostart " + - $"-setenv=NUNIT_AUTOSTART=true -argument=-app-arg:-autoexit -setenv=NUNIT_AUTOEXIT=true " + - $"-argument=-app-arg:-enablenetwork -setenv=NUNIT_ENABLE_NETWORK=true " + - $"-setenv=DISABLE_SYSTEM_PERMISSION_TESTS=1 -argument=-app-arg:-hostname:127.0.0.1 " + - $"-setenv=NUNIT_HOSTNAME=127.0.0.1 -argument=-app-arg:-transport:Tcp -setenv=NUNIT_TRANSPORT=TCP " + - $"-argument=-app-arg:-hostport:{listenerPort} -setenv=NUNIT_HOSTPORT={listenerPort} " + - $"-setenv=env1=value1 -setenv=env2=value2 --launchsim {StringUtils.FormatArguments (appPath)} " + - $"--stdout=tty1 --stderr=tty1 --device=:v2:udid={simulator.Object.UDID}"; - - processManager - .Setup (x => x.ExecuteCommandAsync ( - It.Is (args => args.AsCommandLine () == expectedArgs), - mainLog.Object, - TimeSpan.FromMinutes (harness.Timeout * 2), - null, - 5, - It.IsAny ())) - .ReturnsAsync (new ProcessExecutionResult () { ExitCode = 0 }); - - var xmlResultFile = Path.ChangeExtension (testResultFilePath, "xml"); - var testReporterFactory = new Mock (); - var testReporter = new Mock (); - testReporterFactory.SetReturnsDefault (testReporter.Object); - testReporter.Setup (r => r.ParseResult ()).Returns (() => { - return Task.FromResult<(TestExecutingResult, string)> ((TestExecutingResult.Succeeded, null)); - }); - testReporter.Setup (r => r.Success).Returns (true); - - // Act - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - crashReporterFactory.Object, - captureLogFactory.Object, - Mock.Of (), // Use for devices only - testReporterFactory.Object, - TestTarget.Simulator_iOS64, - harness, - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug", - timeoutMultiplier: 2, - ensureCleanSimulatorState: true); - appRunner.InitializeAsync ().Wait (); - - var result = await appRunner.RunAsync (); - - // Verify - Assert.AreEqual (0, result); - - simpleListener.Verify (x => x.InitializeAndGetPort (), Times.AtLeastOnce); - simpleListener.Verify (x => x.StartAsync (), Times.AtLeastOnce); - simpleListener.Verify (x => x.Cancel (), Times.AtLeastOnce); - simpleListener.Verify (x => x.Dispose (), Times.AtLeastOnce); - - simulators.VerifyAll (); - - captureLog.Verify (x => x.StartCapture (), Times.AtLeastOnce); - captureLog.Verify (x => x.StopCapture (null), Times.AtLeastOnce); - - // When ensureCleanSimulatorState == true - simulator.Verify (x => x.PrepareSimulator (It.IsAny (), appName)); - simulator.Verify (x => x.KillEverything (mainLog.Object)); - } - - [Test] - public void RunOnDeviceWithNoAvailableSimulatorTest () - { - devices.Setup (d => d.FindDevice (It.IsAny (), It.IsAny (), false, false, CancellationToken.None)).ReturnsAsync ((IHardwareDevice) null); - simulators - .Setup (s => s.FindSimulators (It.IsAny (), It.IsAny (), true, false, CancellationToken.None)) - .ReturnsAsync ((null, null)); - - // Crash reporter - var crashReporterFactory = new Mock (); - crashReporterFactory - .Setup (x => x.Create (mainLog.Object, It.IsAny (), false, null)) - .Returns (snapshotReporter.Object); - - var listenerLogFile = new Mock (); - var testReporterFactory = new Mock (); - var testReporter = new Mock (); - testReporterFactory.SetReturnsDefault (testReporter.Object); - testReporter.Setup (r => r.ParseResult ()).Returns (() => { - return Task.FromResult<(TestExecutingResult, string)> ((TestExecutingResult.Succeeded, null)); - }); - testReporter.Setup (r => r.Success).Returns (true); - - logs - .Setup (x => x.Create (It.IsAny (), "TestLog", It.IsAny ())) - .Returns (listenerLogFile.Object); - - simpleListener.SetupGet (x => x.ConnectedTask).Returns (Task.FromResult (true)); - - // Act - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - crashReporterFactory.Object, - Mock.Of (), - Mock.Of (), - testReporterFactory.Object, - TestTarget.Device_tvOS, - GetMockedHarness (), - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug", - timeoutMultiplier: 2); - appRunner.InitializeAsync ().Wait (); - - Assert.ThrowsAsync ( - async () => await appRunner.RunAsync (), - "Running requires connected devices"); - } - - [Test] - public async Task RunOnDeviceSuccessfullyTest () - { - var harness = GetMockedHarness (); - - devices.Setup (d => d.FindDevice (It.IsAny (), It.IsAny (), false, false, CancellationToken.None)).ReturnsAsync (mockDevices [1]); - - // Crash reporter - var crashReporterFactory = new Mock (); - crashReporterFactory - .Setup (x => x.Create (mainLog.Object, It.IsAny (), true, "Test iPad")) - .Returns (snapshotReporter.Object); - - var deviceSystemLog = new Mock (); - deviceSystemLog.SetupGet (x => x.FullPath).Returns (Path.GetTempFileName ()); - - var testResultFilePath = Path.GetTempFileName (); - var listenerLogFile = Mock.Of (x => x.FullPath == testResultFilePath); - File.WriteAllLines (testResultFilePath, new [] { "Some result here", "Some result there", "Tests run: 3" }); - - logs - .Setup (x => x.Create (It.Is (s => s.StartsWith ("test-ios-")), "TestLog", It.IsAny ())) - .Returns (listenerLogFile); - - logs - .Setup (x => x.Create (It.Is (s => s.StartsWith ("device-Test iPad-")), "Device log", It.IsAny ())) - .Returns (deviceSystemLog.Object); - - simpleListener.SetupGet (x => x.ConnectedTask).Returns (Task.FromResult (true)); - - var deviceLogCapturer = new Mock (); - - var deviceLogCapturerFactory = new Mock (); - deviceLogCapturerFactory - .Setup (x => x.Create (mainLog.Object, deviceSystemLog.Object, "Test iPad")) - .Returns (deviceLogCapturer.Object); - - var ips = new StringBuilder (); - var ipAddresses = System.Net.Dns.GetHostEntry (System.Net.Dns.GetHostName ()).AddressList; - for (int i = 0; i < ipAddresses.Length; i++) { - if (i > 0) - ips.Append (','); - ips.Append (ipAddresses [i].ToString ()); - } - - var expectedArgs = $"-v -v -argument=-connection-mode -argument=none " + - $"-argument=-app-arg:-autostart -setenv=NUNIT_AUTOSTART=true -argument=-app-arg:-autoexit " + - $"-setenv=NUNIT_AUTOEXIT=true -argument=-app-arg:-enablenetwork -setenv=NUNIT_ENABLE_NETWORK=true " + - $"-setenv=DISABLE_SYSTEM_PERMISSION_TESTS=1 -argument=-app-arg:-hostname:{ips} -setenv=NUNIT_HOSTNAME={ips} " + - $"-argument=-app-arg:-transport:Tcp -setenv=NUNIT_TRANSPORT=TCP -argument=-app-arg:-hostport:{listenerPort} " + - $"-setenv=NUNIT_HOSTPORT={listenerPort} -setenv=env1=value1 -setenv=env2=value2 " + - $"--launchdev {StringUtils.FormatArguments (appPath)} --disable-memory-limits --wait-for-exit --devname \"Test iPad\""; - - processManager - .Setup (x => x.ExecuteCommandAsync ( - It.Is (args => args.AsCommandLine () == expectedArgs), - It.IsAny (), - TimeSpan.FromMinutes (harness.Timeout * 2), - null, - 5, - It.IsAny ())) - .ReturnsAsync (new ProcessExecutionResult () { ExitCode = 0 }); - - var xmlResultFile = Path.ChangeExtension (testResultFilePath, "xml"); - var testReporterFactory = new Mock (); - var testReporter = new Mock (); - testReporterFactory.SetReturnsDefault (testReporter.Object); - testReporter.Setup (r => r.ParseResult ()).Returns (() => { - return Task.FromResult<(TestExecutingResult, string)> ((TestExecutingResult.Succeeded, null)); - }); - testReporter.Setup (r => r.Success).Returns (true); - - // Act - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - crashReporterFactory.Object, - Mock.Of (), // Used for simulators only - deviceLogCapturerFactory.Object, - testReporterFactory.Object, - TestTarget.Device_iOS, - harness, - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug", - timeoutMultiplier: 2); - appRunner.InitializeAsync ().Wait (); - - var result = await appRunner.RunAsync (); - - // Verify - Assert.AreEqual (0, result); - - processManager.VerifyAll (); - - simpleListener.Verify (x => x.InitializeAndGetPort (), Times.AtLeastOnce); - simpleListener.Verify (x => x.StartAsync (), Times.AtLeastOnce); - simpleListener.Verify (x => x.Cancel (), Times.AtLeastOnce); - simpleListener.Verify (x => x.Dispose (), Times.AtLeastOnce); - - snapshotReporter.Verify (x => x.StartCaptureAsync (), Times.AtLeastOnce); - snapshotReporter.Verify (x => x.StartCaptureAsync (), Times.AtLeastOnce); - - deviceSystemLog.Verify (x => x.Dispose (), Times.AtLeastOnce); - } - - [Test] - public async Task RunOnDeviceWithFailedTestsTest () - { - var harness = GetMockedHarness (); - - devices.Setup (d => d.FindDevice (It.IsAny (), It.IsAny (), false, false, CancellationToken.None)).ReturnsAsync (mockDevices [1]); - - // Crash reporter - var crashReporterFactory = new Mock (); - crashReporterFactory - .Setup (x => x.Create (mainLog.Object, It.IsAny (), true, "Test iPad")) - .Returns (snapshotReporter.Object); - - var deviceSystemLog = new Mock (); - deviceSystemLog.SetupGet (x => x.FullPath).Returns (Path.GetTempFileName ()); - - var testResultFilePath = Path.GetTempFileName (); - var listenerLogFile = Mock.Of (x => x.FullPath == testResultFilePath); - File.WriteAllLines (testResultFilePath, new [] { "Some result here", "[FAIL] This test failed", "Some result there", "Tests run: 3" }); - - logs - .Setup (x => x.Create (It.Is (s => s.StartsWith ("test-ios-")), "TestLog", It.IsAny ())) - .Returns (listenerLogFile); - - logs - .Setup (x => x.Create (It.Is (s => s.StartsWith ("device-Test iPad-")), "Device log", It.IsAny ())) - .Returns (deviceSystemLog.Object); - - simpleListener.SetupGet (x => x.ConnectedTask).Returns (Task.FromResult (true)); - - var deviceLogCapturer = new Mock (); - - var deviceLogCapturerFactory = new Mock (); - deviceLogCapturerFactory - .Setup (x => x.Create (mainLog.Object, deviceSystemLog.Object, "Test iPad")) - .Returns (deviceLogCapturer.Object); - - var ips = new StringBuilder (); - var ipAddresses = System.Net.Dns.GetHostEntry (System.Net.Dns.GetHostName ()).AddressList; - for (int i = 0; i < ipAddresses.Length; i++) { - if (i > 0) - ips.Append (','); - ips.Append (ipAddresses [i].ToString ()); - } - - var expectedArgs = $"-v -v -argument=-connection-mode -argument=none " + - $"-argument=-app-arg:-autostart -setenv=NUNIT_AUTOSTART=true -argument=-app-arg:-autoexit " + - $"-setenv=NUNIT_AUTOEXIT=true -argument=-app-arg:-enablenetwork -setenv=NUNIT_ENABLE_NETWORK=true " + - $"-setenv=DISABLE_SYSTEM_PERMISSION_TESTS=1 -argument=-app-arg:-hostname:{ips} -setenv=NUNIT_HOSTNAME={ips} " + - $"-argument=-app-arg:-transport:Tcp -setenv=NUNIT_TRANSPORT=TCP -argument=-app-arg:-hostport:{listenerPort} " + - $"-setenv=NUNIT_HOSTPORT={listenerPort} -setenv=env1=value1 -setenv=env2=value2 " + - $"--launchdev {StringUtils.FormatArguments (appPath)} --disable-memory-limits --wait-for-exit --devname \"Test iPad\""; - - processManager - .Setup (x => x.ExecuteCommandAsync ( - It.Is (args => args.AsCommandLine () == expectedArgs), - It.IsAny (), - TimeSpan.FromMinutes (harness.Timeout * 2), - null, - 5, - It.IsAny ())) - .ReturnsAsync (new ProcessExecutionResult () { ExitCode = 0 }); - - var xmlResultFile = Path.ChangeExtension (testResultFilePath, "xml"); - var testReporterFactory = new Mock (); - var testReporter = new Mock (); - testReporterFactory.SetReturnsDefault (testReporter.Object); - testReporter.Setup (r => r.ParseResult ()).Returns (() => { - return Task.FromResult<(TestExecutingResult, string)> ((TestExecutingResult.Failed, null)); - }); - testReporter.Setup (r => r.Success).Returns (false); - - // Act - var appRunner = new AppRunner (processManager.Object, - appBundleInformationParser, - simulatorsFactory, - listenerFactory, - devicesFactory, - crashReporterFactory.Object, - Mock.Of (), // Used for simulators only - deviceLogCapturerFactory.Object, - testReporterFactory.Object, - TestTarget.Device_iOS, - harness, - mainLog.Object, - logs.Object, - projectFilePath: projectFilePath, - buildConfiguration: "Debug", - timeoutMultiplier: 2); - appRunner.InitializeAsync ().Wait (); - - var result = await appRunner.RunAsync (); - - // Verify - Assert.AreEqual (1, result); - - processManager.VerifyAll (); - - simpleListener.Verify (x => x.InitializeAndGetPort (), Times.AtLeastOnce); - simpleListener.Verify (x => x.StartAsync (), Times.AtLeastOnce); - simpleListener.Verify (x => x.Cancel (), Times.AtLeastOnce); - simpleListener.Verify (x => x.Dispose (), Times.AtLeastOnce); - - snapshotReporter.Verify (x => x.StartCaptureAsync (), Times.AtLeastOnce); - snapshotReporter.Verify (x => x.StartCaptureAsync (), Times.AtLeastOnce); - - deviceSystemLog.Verify (x => x.Dispose (), Times.AtLeastOnce); - } - - IHarness GetMockedHarness () - { - return Mock.Of (x => x.Action == HarnessAction.Run - && x.Verbosity == 1 - && x.HarnessLog == mainLog.Object - && x.InCI == false - && x.EnvironmentVariables == new Dictionary () { - { "env1", "value1" }, - { "env2", "value2" }, - } - && x.Timeout == 1d); - } - } -} diff --git a/tests/xharness/Xharness.Tests/Tests/TestPlatformExtensionsTests.cs b/tests/xharness/Xharness.Tests/Tests/TestPlatformExtensionsTests.cs deleted file mode 100644 index b9e49c859ec8..000000000000 --- a/tests/xharness/Xharness.Tests/Tests/TestPlatformExtensionsTests.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections; -using Microsoft.DotNet.XHarness.iOS.Shared; -using NUnit.Framework; - -namespace Xharness.Tests.Tests { - - [TestFixture] - public class TestPlatformExtensionsTests { - - public class TestCasesData { - public static IEnumerable GetSimulatorTestCases { - get { - foreach (var platform in new [] { TestPlatform.iOS }) { - yield return new TestCaseData (platform).Returns ("iOS " + Xamarin.SdkVersions.MiniOSSimulator); - } - yield return new TestCaseData (TestPlatform.tvOS).Returns ("tvOS " + Xamarin.SdkVersions.MinTVOSSimulator); - } - } - - public static IEnumerable IsMacTestCases { - get { - - foreach (var platform in new [] { TestPlatform.None, - TestPlatform.All, - TestPlatform.iOS, - TestPlatform.tvOS }) { - yield return new TestCaseData (platform).Returns (false); - } - - foreach (var platform in new [] { TestPlatform.Mac }) { - yield return new TestCaseData (platform).Returns (true); - } - } - } - } - - [Test, TestCaseSource (typeof (TestCasesData), "GetSimulatorTestCases")] - public string GetSimulatorMinVersionTest (TestPlatform platform) - => platform.GetSimulatorMinVersion (); - - [Test, TestCaseSource (typeof (TestCasesData), "IsMacTestCases")] - public bool IsMacTest (TestPlatform platform) => platform.IsMac (); - - } - -} diff --git a/tests/xharness/Xharness.Tests/Tests/TestTargetExtensionsTests.cs b/tests/xharness/Xharness.Tests/Tests/TestTargetExtensionsTests.cs deleted file mode 100644 index 6ff560f46f9c..000000000000 --- a/tests/xharness/Xharness.Tests/Tests/TestTargetExtensionsTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections; -using Microsoft.DotNet.XHarness.iOS.Shared; -using NUnit.Framework; - -namespace Xharness.Tests.Tests { - - [TestFixture] - public class TestTargetExtensionsTests { - - [TestCase (TestPlatform.tvOS, new [] { TestTarget.Simulator_tvOS })] - public void GetAppRunnerTargetsTest (TestPlatform platform, TestTarget [] expectedTargets) - { - var targets = platform.GetTestTargetsForSimulator (); - Assert.AreEqual (expectedTargets.Length, targets.Length); - foreach (var t in expectedTargets) { - Assert.Contains (t, targets); - } - } - } -} diff --git a/tests/xharness/Xharness.Tests/Xharness.Tests.csproj b/tests/xharness/Xharness.Tests/Xharness.Tests.csproj deleted file mode 100644 index 904eaf9e99e4..000000000000 --- a/tests/xharness/Xharness.Tests/Xharness.Tests.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - net$(BundledNETCoreAppTargetFrameworkVersion) - Xharness.Tests - Xharness.Tests - latest - false - Nullable - - - - - - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - - - - - - - - - - - - - - {e1f53f80-8399-499b-8017-c414b9cd263b} - xharness - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/tests/xharness/Xharness.Tests/app.config b/tests/xharness/Xharness.Tests/app.config deleted file mode 100644 index 2833cc4412da..000000000000 --- a/tests/xharness/Xharness.Tests/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/xharness/XmlDocumentExtensions.cs b/tests/xharness/XmlDocumentExtensions.cs index db1cec8eb345..9b4b962b2ee5 100644 --- a/tests/xharness/XmlDocumentExtensions.cs +++ b/tests/xharness/XmlDocumentExtensions.cs @@ -5,13 +5,13 @@ namespace Xharness { public static class XmlDocumentExtensions { - public static void Save (this XmlDocument doc, string path, IHarness harness) => + public static void Save (this XmlDocument doc, string path, Harness harness) => doc.Save (path, (level, message) => harness.Log (level, message)); public static void Save (this XmlDocument doc, string path, Action log) { if (!File.Exists (path)) { - Directory.CreateDirectory (Path.GetDirectoryName (path)); + Directory.CreateDirectory (Path.GetDirectoryName (path)!); doc.Save (path); log?.Invoke (1, $"Created {path}"); } else { diff --git a/tests/xharness/xharness.csproj b/tests/xharness/xharness.csproj index 66e4fe3fe19e..03169bf8a1da 100644 --- a/tests/xharness/xharness.csproj +++ b/tests/xharness/xharness.csproj @@ -6,9 +6,8 @@ Xharness xharness latest - false Nullable - + enable false @@ -27,9 +26,6 @@ Project --verbose --jenkins --rootdir .. --label=skip-mac-tests,skip-ios-simulator-tests,skip-ios-msbuild-tests,skip-system-permission-tests,run-ios-device-tests,run-ios-extensions-tests --markdown-summary=../TestSummary.md - - - @@ -38,94 +34,23 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StringUtils.cs + tools\common\StringUtils.cs - NullableAttributes.cs + tools\common\NullableAttributes.cs - Cache.cs + tests\mtouch\Cache.cs - ApplePlatform.cs + tools\common\ApplePlatform.cs - - ParseTrxFile.cs + tests\common\ParseTrxFile.cs - - - SdkVersions.cs + tools\common\SdkVersions.cs @@ -136,9 +61,4 @@ PreserveNewest - - - - - diff --git a/tests/xharness/xharness.slnx b/tests/xharness/xharness.slnx index e85b6d9eb2b2..b9a0957f809b 100644 --- a/tests/xharness/xharness.slnx +++ b/tests/xharness/xharness.slnx @@ -1,4 +1,3 @@ -