Extract AppBundleInformationParser (#8174)

This commit is contained in:
Přemek Vysoký 2020-03-24 10:02:22 +01:00 коммит произвёл GitHub
Родитель e9ff1f854d
Коммит 6a58674960
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
19 изменённых файлов: 298 добавлений и 205 удалений

Просмотреть файл

@ -0,0 +1,64 @@
using System.IO;
using System.Xml;
using Xharness.Utilities;
namespace Xharness {
public class AppBundleInformation {
public string AppName { get; }
public string BundleIdentifier { get; }
public string AppPath { get; }
public string LaunchAppPath { get; }
public Extension? Extension { get; }
public AppBundleInformation (string appName, string bundleIdentifier, string appPath, string launchAppPath, Extension? extension)
{
AppName = appName;
BundleIdentifier = bundleIdentifier;
AppPath = appPath;
LaunchAppPath = launchAppPath;
Extension = extension;
}
}
public interface IAppBundleInformationParser {
AppBundleInformation ParseFromProject (string projectFilePath, TestTarget target, string buildConfiguration);
}
public class AppBundleInformationParser : IAppBundleInformationParser {
public AppBundleInformation ParseFromProject (string projectFilePath, TestTarget target, string buildConfiguration)
{
var csproj = new XmlDocument ();
csproj.LoadWithoutNetworkAccess (projectFilePath);
string appName = csproj.GetAssemblyName ();
string info_plist_path = csproj.GetInfoPListInclude ();
var info_plist = new XmlDocument ();
string plistPath = Path.Combine (Path.GetDirectoryName (projectFilePath), info_plist_path.Replace ('\\', Path.DirectorySeparatorChar));
info_plist.LoadWithoutNetworkAccess (plistPath);
string bundleIdentifier = info_plist.GetCFBundleIdentifier ();
Extension? extension = null;
string extensionPointIdentifier = info_plist.GetNSExtensionPointIdentifier ();
if (!string.IsNullOrEmpty (extensionPointIdentifier))
extension = extensionPointIdentifier.ParseFromNSExtensionPointIdentifier ();
var platform = target.IsSimulator () ? "iPhoneSimulator" : "iPhone";
string appPath = Path.Combine (Path.GetDirectoryName (projectFilePath),
csproj.GetOutputPath (platform, buildConfiguration).Replace ('\\', Path.DirectorySeparatorChar),
appName + (extension != null ? ".appex" : ".app"));
if (!Directory.Exists (appPath))
throw new DirectoryNotFoundException ($"The app bundle directory `{appPath}` does not exist");
string launchAppPath = (target.ToRunMode () == RunMode.WatchOS)
? Directory.GetDirectories (Path.Combine (appPath, "Watch"), "*.app") [0]
: appPath;
return new AppBundleInformation (appName, bundleIdentifier, appPath, launchAppPath, extension);
}
}
}

Просмотреть файл

@ -16,38 +16,6 @@ using Xharness.Utilities;
namespace Xharness { namespace Xharness {
public enum RunMode {
Sim32,
Sim64,
Classic,
iOS,
TvOS,
WatchOS,
}
public enum Extension
{
WatchKit2,
TodayExtension,
}
public class AppInformation {
public string AppName { get; }
public string BundleIdentifier { get; }
public string AppPath { get; }
public string LaunchAppPath { get; }
public Extension? Extension { get; }
public AppInformation (string appName, string bundleIdentifier, string appPath, string launchAppPath, Extension? extension)
{
AppName = appName;
BundleIdentifier = bundleIdentifier;
AppPath = appPath;
LaunchAppPath = launchAppPath;
Extension = extension;
}
}
class AppRunner class AppRunner
{ {
readonly IProcessManager processManager; readonly IProcessManager processManager;
@ -59,12 +27,10 @@ namespace Xharness {
readonly IDeviceLogCapturerFactory deviceLogCapturerFactory; readonly IDeviceLogCapturerFactory deviceLogCapturerFactory;
readonly IResultParser resultParser; readonly IResultParser resultParser;
readonly RunMode mode; readonly RunMode runMode;
readonly bool isSimulator; readonly bool isSimulator;
readonly AppRunnerTarget target; readonly TestTarget target;
readonly string projectFilePath;
readonly IHarness harness; readonly IHarness harness;
readonly string buildConfiguration;
readonly string variation; readonly string variation;
readonly double timeoutMultiplier; readonly double timeoutMultiplier;
readonly BuildToolTask buildTask; readonly BuildToolTask buildTask;
@ -82,7 +48,7 @@ namespace Xharness {
bool IsExtension => AppInformation.Extension.HasValue; bool IsExtension => AppInformation.Extension.HasValue;
public AppInformation AppInformation { get; } public AppBundleInformation AppInformation { get; }
public TestExecutingResult Result { get; private set; } public TestExecutingResult Result { get; private set; }
@ -93,6 +59,7 @@ namespace Xharness {
public ILogs Logs { get; } public ILogs Logs { get; }
public AppRunner (IProcessManager processManager, public AppRunner (IProcessManager processManager,
IAppBundleInformationParser appBundleInformationParser,
ISimulatorsLoaderFactory simulatorsFactory, ISimulatorsLoaderFactory simulatorsFactory,
ISimpleListenerFactory simpleListenerFactory, ISimpleListenerFactory simpleListenerFactory,
IDeviceLoaderFactory devicesFactory, IDeviceLoaderFactory devicesFactory,
@ -100,7 +67,7 @@ namespace Xharness {
ICaptureLogFactory captureLogFactory, ICaptureLogFactory captureLogFactory,
IDeviceLogCapturerFactory deviceLogCapturerFactory, IDeviceLogCapturerFactory deviceLogCapturerFactory,
IResultParser resultParser, IResultParser resultParser,
AppRunnerTarget target, TestTarget target,
IHarness harness, IHarness harness,
ILog mainLog, ILog mainLog,
ILogs logs, ILogs logs,
@ -114,6 +81,9 @@ namespace Xharness {
string variation = null, string variation = null,
BuildToolTask buildTask = null) BuildToolTask buildTask = null)
{ {
if (appBundleInformationParser is null)
throw new ArgumentNullException (nameof (appBundleInformationParser));
this.processManager = processManager ?? throw new ArgumentNullException (nameof (processManager)); this.processManager = processManager ?? throw new ArgumentNullException (nameof (processManager));
this.simulatorsLoaderFactory = simulatorsFactory ?? throw new ArgumentNullException (nameof (simulatorsFactory)); this.simulatorsLoaderFactory = simulatorsFactory ?? throw new ArgumentNullException (nameof (simulatorsFactory));
this.listenerFactory = simpleListenerFactory ?? throw new ArgumentNullException (nameof (simpleListenerFactory)); this.listenerFactory = simpleListenerFactory ?? throw new ArgumentNullException (nameof (simpleListenerFactory));
@ -124,9 +94,7 @@ namespace Xharness {
this.resultParser = resultParser ?? throw new ArgumentNullException (nameof (resultParser)); this.resultParser = resultParser ?? throw new ArgumentNullException (nameof (resultParser));
this.harness = harness ?? throw new ArgumentNullException (nameof (harness)); this.harness = harness ?? throw new ArgumentNullException (nameof (harness));
this.MainLog = mainLog ?? throw new ArgumentNullException (nameof (mainLog)); this.MainLog = mainLog ?? throw new ArgumentNullException (nameof (mainLog));
this.projectFilePath = projectFilePath ?? throw new ArgumentNullException (nameof (projectFilePath));
this.Logs = logs ?? throw new ArgumentNullException (nameof (logs)); this.Logs = logs ?? throw new ArgumentNullException (nameof (logs));
this.buildConfiguration = buildConfiguration ?? throw new ArgumentNullException (nameof (buildConfiguration));
this.timeoutMultiplier = timeoutMultiplier; this.timeoutMultiplier = timeoutMultiplier;
this.deviceName = deviceName; this.deviceName = deviceName;
this.companionDeviceName = companionDeviceName; this.companionDeviceName = companionDeviceName;
@ -136,41 +104,9 @@ namespace Xharness {
this.buildTask = buildTask; this.buildTask = buildTask;
this.target = target; this.target = target;
mode = target.ToRunMode (); runMode = target.ToRunMode ();
isSimulator = target.IsSimulator (); isSimulator = target.IsSimulator ();
AppInformation = Initialize (); AppInformation = appBundleInformationParser.ParseFromProject (projectFilePath, target, buildConfiguration);
}
AppInformation Initialize ()
{
var csproj = new XmlDocument ();
csproj.LoadWithoutNetworkAccess (projectFilePath);
string appName = csproj.GetAssemblyName ();
string info_plist_path = csproj.GetInfoPListInclude ();
var info_plist = new XmlDocument ();
string plistPath = Path.Combine (Path.GetDirectoryName (projectFilePath), info_plist_path.Replace ('\\', Path.DirectorySeparatorChar));
info_plist.LoadWithoutNetworkAccess (plistPath);
string bundleIdentifier = info_plist.GetCFBundleIdentifier ();
Extension? extension = null;
string extensionPointIdentifier = info_plist.GetNSExtensionPointIdentifier ();
if (!string.IsNullOrEmpty (extensionPointIdentifier))
extension = extensionPointIdentifier.ParseFromNSExtensionPointIdentifier ();
string appPath = Path.Combine (Path.GetDirectoryName (projectFilePath),
csproj.GetOutputPath (isSimulator ? "iPhoneSimulator" : "iPhone", buildConfiguration).Replace ('\\', Path.DirectorySeparatorChar),
appName + (extension != null ? ".appex" : ".app"));
if (!Directory.Exists (appPath))
throw new Exception (string.Format ("The app directory {0} does not exist. This is probably a bug in the test harness.", appPath));
string launchAppPath = mode == RunMode.WatchOS
? Directory.GetDirectories (Path.Combine (appPath, "Watch"), "*.app") [0]
: appPath;
return new AppInformation (appName, bundleIdentifier, appPath, launchAppPath, extension);
} }
async Task<bool> FindSimulatorAsync () async Task<bool> FindSimulatorAsync ()
@ -201,7 +137,7 @@ namespace Xharness {
}).Wait (); }).Wait ();
DeviceClass [] deviceClasses; DeviceClass [] deviceClasses;
switch (mode) { switch (runMode) {
case RunMode.iOS: case RunMode.iOS:
deviceClasses = new [] { DeviceClass.iPhone, DeviceClass.iPad, DeviceClass.iPod }; deviceClasses = new [] { DeviceClass.iPhone, DeviceClass.iPad, DeviceClass.iPod };
break; break;
@ -212,7 +148,7 @@ namespace Xharness {
deviceClasses = new [] { DeviceClass.AppleTV }; // Untested deviceClasses = new [] { DeviceClass.AppleTV }; // Untested
break; break;
default: default:
throw new ArgumentException (nameof(mode)); throw new ArgumentException (nameof(runMode));
} }
var selected = devs.ConnectedDevices.Where ((v) => deviceClasses.Contains (v.DeviceClass) && v.IsUsableForDebugging != false); var selected = devs.ConnectedDevices.Where ((v) => deviceClasses.Contains (v.DeviceClass) && v.IsUsableForDebugging != false);
@ -236,7 +172,7 @@ namespace Xharness {
deviceName = selected_data.Name; deviceName = selected_data.Name;
if (mode == RunMode.WatchOS) if (runMode == RunMode.WatchOS)
companionDeviceName = devs.FindCompanionDevice (MainLog, selected_data).Name; companionDeviceName = devs.FindCompanionDevice (MainLog, selected_data).Name;
} }
@ -261,7 +197,7 @@ namespace Xharness {
args.Add (AppInformation.AppPath); args.Add (AppInformation.AppPath);
AddDeviceName (args, companionDeviceName ?? deviceName); AddDeviceName (args, companionDeviceName ?? deviceName);
if (mode == RunMode.WatchOS) { if (runMode == RunMode.WatchOS) {
args.Add ("--device"); args.Add ("--device");
args.Add ("ios,watchos"); args.Add ("ios,watchos");
} }
@ -294,7 +230,7 @@ namespace Xharness {
return await processManager.ExecuteCommandAsync (harness.MlaunchPath, args, MainLog, TimeSpan.FromMinutes (1)); return await processManager.ExecuteCommandAsync (harness.MlaunchPath, args, MainLog, TimeSpan.FromMinutes (1));
} }
(string resultLine, bool failed, bool crashed) ParseResult (AppInformation appInfo, string test_log_path, bool timed_out, out bool crashed) (string resultLine, bool failed, bool crashed) ParseResult (AppBundleInformation appInfo, string test_log_path, bool timed_out, out bool crashed)
{ {
crashed = false; crashed = false;
if (!File.Exists (test_log_path)) { if (!File.Exists (test_log_path)) {
@ -366,10 +302,10 @@ namespace Xharness {
MainLog.WriteLine (new string ('#', 10)); MainLog.WriteLine (new string ('#', 10));
MainLog.WriteLine ("End of xml results."); MainLog.WriteLine ("End of xml results.");
if (timed_out) { if (timed_out) {
WrenchLog.WriteLine ($"AddSummary: <b><i>{mode} timed out</i></b><br/>"); WrenchLog.WriteLine ($"AddSummary: <b><i>{runMode} timed out</i></b><br/>");
return parseResult; return parseResult;
} else { } else {
WrenchLog.WriteLine ($"AddSummary: <b><i>{mode} crashed</i></b><br/>"); WrenchLog.WriteLine ($"AddSummary: <b><i>{runMode} crashed</i></b><br/>");
MainLog.WriteLine ("Test run crashed"); MainLog.WriteLine ("Test run crashed");
crashed = true; crashed = true;
parseResult.crashed = true; parseResult.crashed = true;
@ -400,26 +336,26 @@ namespace Xharness {
} }
} }
public bool TestsSucceeded (AppInformation appInfo, string test_log_path, bool timed_out, out bool crashed) public bool TestsSucceeded (AppBundleInformation appInfo, string test_log_path, bool timed_out, out bool crashed)
{ {
var (resultLine, failed, crashed_out) = ParseResult (appInfo, test_log_path, timed_out, out crashed); var (resultLine, failed, crashed_out) = ParseResult (appInfo, test_log_path, timed_out, out crashed);
// read the parsed logs in a human readable way // read the parsed logs in a human readable way
if (resultLine != null) { if (resultLine != null) {
var tests_run = resultLine.Replace ("Tests run: ", ""); var tests_run = resultLine.Replace ("Tests run: ", "");
if (failed) { if (failed) {
WrenchLog.WriteLine ("AddSummary: <b>{0} failed: {1}</b><br/>", mode, tests_run); WrenchLog.WriteLine ("AddSummary: <b>{0} failed: {1}</b><br/>", runMode, tests_run);
MainLog.WriteLine ("Test run failed"); MainLog.WriteLine ("Test run failed");
return false; return false;
} else { } else {
WrenchLog.WriteLine ("AddSummary: {0} succeeded: {1}<br/>", mode, tests_run); WrenchLog.WriteLine ("AddSummary: {0} succeeded: {1}<br/>", runMode, tests_run);
MainLog.WriteLine ("Test run succeeded"); MainLog.WriteLine ("Test run succeeded");
return true; return true;
} }
} else if (timed_out) { } else if (timed_out) {
WrenchLog.WriteLine ("AddSummary: <b><i>{0} timed out</i></b><br/>", mode); WrenchLog.WriteLine ("AddSummary: <b><i>{0} timed out</i></b><br/>", runMode);
return false; return false;
} else { } else {
WrenchLog.WriteLine ("AddSummary: <b><i>{0} crashed</i></b><br/>", mode); WrenchLog.WriteLine ("AddSummary: <b><i>{0} crashed</i></b><br/>", runMode);
MainLog.WriteLine ("Test run crashed"); MainLog.WriteLine ("Test run crashed");
crashed = true; crashed = true;
return false; return false;
@ -480,8 +416,8 @@ namespace Xharness {
args.Add ($"-setenv=NUNIT_HOSTNAME={ips}"); args.Add ($"-setenv=NUNIT_HOSTNAME={ips}");
} }
var listener_log = Logs.Create ($"test-{mode.ToString().ToLower()}-{Helpers.Timestamp}.log", LogType.TestLog.ToString (), timestamp: !useXmlOutput); var listener_log = Logs.Create ($"test-{runMode.ToString().ToLower()}-{Helpers.Timestamp}.log", LogType.TestLog.ToString (), timestamp: !useXmlOutput);
var (transport, listener, listenerTmpFile) = listenerFactory.Create (mode, MainLog, listener_log, isSimulator, true, useXmlOutput); var (transport, listener, listenerTmpFile) = listenerFactory.Create (runMode, MainLog, listener_log, isSimulator, true, useXmlOutput);
args.Add ($"-argument=-app-arg:-transport:{transport}"); args.Add ($"-argument=-app-arg:-transport:{transport}");
args.Add ($"-setenv=NUNIT_TRANSPORT={transport.ToString ().ToUpper ()}"); args.Add ($"-setenv=NUNIT_TRANSPORT={transport.ToString ().ToUpper ()}");
@ -549,7 +485,7 @@ namespace Xharness {
if (!await FindSimulatorAsync ()) if (!await FindSimulatorAsync ())
return 1; return 1;
if (mode != RunMode.WatchOS) { if (runMode != RunMode.WatchOS) {
var stderr_tty = harness.GetStandardErrorTty (); var stderr_tty = harness.GetStandardErrorTty ();
if (!string.IsNullOrEmpty (stderr_tty)) { if (!string.IsNullOrEmpty (stderr_tty)) {
args.Add ($"--stdout={stderr_tty}"); args.Add ($"--stdout={stderr_tty}");
@ -581,7 +517,7 @@ namespace Xharness {
WrenchLog.WriteLine ("AddFile: {0}", log.FullPath); WrenchLog.WriteLine ("AddFile: {0}", log.FullPath);
} }
MainLog.WriteLine ("*** Executing {0}/{1} in the simulator ***", AppInformation.AppName, mode); MainLog.WriteLine ("*** Executing {0}/{1} in the simulator ***", AppInformation.AppName, runMode);
if (EnsureCleanSimulatorState) { if (EnsureCleanSimulatorState) {
foreach (var sim in simulators) foreach (var sim in simulators)
@ -652,9 +588,9 @@ namespace Xharness {
log.StopCapture (); log.StopCapture ();
} else { } else {
MainLog.WriteLine ("*** Executing {0}/{1} on device '{2}' ***", AppInformation.AppName, mode, deviceName); MainLog.WriteLine ("*** Executing {0}/{1} on device '{2}' ***", AppInformation.AppName, runMode, deviceName);
if (mode == RunMode.WatchOS) { if (runMode == RunMode.WatchOS) {
args.Add ("--attach-native-debugger"); // this prevents the watch from backgrounding the app. args.Add ("--attach-native-debugger"); // this prevents the watch from backgrounding the app.
} else { } else {
args.Add ("--wait-for-exit"); args.Add ("--wait-for-exit");
@ -724,15 +660,15 @@ namespace Xharness {
WrenchLog.WriteLine ("AddFile: {0}", listener_log.FullPath); WrenchLog.WriteLine ("AddFile: {0}", listener_log.FullPath);
success = TestsSucceeded (AppInformation, listener_log.FullPath, timed_out, out crashed); success = TestsSucceeded (AppInformation, listener_log.FullPath, timed_out, out crashed);
} else if (timed_out) { } else if (timed_out) {
WrenchLog.WriteLine ("AddSummary: <b><i>{0} never launched</i></b><br/>", mode); WrenchLog.WriteLine ("AddSummary: <b><i>{0} never launched</i></b><br/>", runMode);
MainLog.WriteLine ("Test run never launched"); MainLog.WriteLine ("Test run never launched");
success = false; success = false;
} else if (launch_failure) { } else if (launch_failure) {
WrenchLog.WriteLine ("AddSummary: <b><i>{0} failed to launch</i></b><br/>", mode); WrenchLog.WriteLine ("AddSummary: <b><i>{0} failed to launch</i></b><br/>", runMode);
MainLog.WriteLine ("Test run failed to launch"); MainLog.WriteLine ("Test run failed to launch");
success = false; success = false;
} else { } else {
WrenchLog.WriteLine ("AddSummary: <b><i>{0} crashed at startup (no log)</i></b><br/>", mode); WrenchLog.WriteLine ("AddSummary: <b><i>{0} crashed at startup (no log)</i></b><br/>", runMode);
MainLog.WriteLine ("Test run crashed before it started (no log file produced)"); MainLog.WriteLine ("Test run crashed before it started (no log file produced)");
crashed = true; crashed = true;
success = false; success = false;

Просмотреть файл

@ -1,43 +0,0 @@
using System;
namespace Xharness {
public enum AppRunnerTarget {
None,
Simulator_iOS,
Simulator_iOS32,
Simulator_iOS64,
Simulator_tvOS,
Simulator_watchOS,
Device_iOS,
Device_tvOS,
Device_watchOS,
}
public static class AppRunnerTargetExtensions {
public static RunMode ToRunMode (this AppRunnerTarget target) => target switch
{
AppRunnerTarget.Simulator_iOS => RunMode.Classic,
AppRunnerTarget.Simulator_iOS32 => RunMode.Sim32,
AppRunnerTarget.Simulator_iOS64 => RunMode.Sim64,
AppRunnerTarget.Simulator_tvOS => RunMode.TvOS,
AppRunnerTarget.Simulator_watchOS => RunMode.WatchOS,
AppRunnerTarget.Device_iOS => RunMode.iOS,
AppRunnerTarget.Device_tvOS => RunMode.TvOS,
AppRunnerTarget.Device_watchOS => RunMode.WatchOS,
_ => throw new ArgumentOutOfRangeException ($"Unknown target: {target}"),
};
public static bool IsSimulator (this AppRunnerTarget target) => target switch
{
AppRunnerTarget.Simulator_iOS => true,
AppRunnerTarget.Simulator_iOS32 => true,
AppRunnerTarget.Simulator_iOS64 => true,
AppRunnerTarget.Simulator_tvOS => true,
AppRunnerTarget.Simulator_watchOS => true,
AppRunnerTarget.Device_iOS => false,
AppRunnerTarget.Device_tvOS => false,
AppRunnerTarget.Device_watchOS => false,
_ => throw new ArgumentOutOfRangeException ($"Unknown target: {target}"),
};
}
}

Просмотреть файл

@ -0,0 +1,7 @@
namespace Xharness {
public enum Extension
{
WatchKit2,
TodayExtension,
}
}

Просмотреть файл

@ -51,9 +51,9 @@ namespace Xharness.Hardware {
IEnumerable<SimDeviceType> SupportedDeviceTypes { get; } IEnumerable<SimDeviceType> SupportedDeviceTypes { get; }
IEnumerable<SimulatorDevice> AvailableDevices { get; } IEnumerable<SimulatorDevice> AvailableDevices { get; }
IEnumerable<SimDevicePair> AvailableDevicePairs { get; } IEnumerable<SimDevicePair> AvailableDevicePairs { get; }
Task<ISimulatorDevice []> FindAsync (AppRunnerTarget target, ILog log, bool create_if_needed = true, bool min_version = false); Task<ISimulatorDevice []> FindAsync (TestTarget target, ILog log, bool create_if_needed = true, bool min_version = false);
ISimulatorDevice FindCompanionDevice (ILog log, ISimulatorDevice device); ISimulatorDevice FindCompanionDevice (ILog log, ISimulatorDevice device);
IEnumerable<ISimulatorDevice> SelectDevices (AppRunnerTarget target, ILog log, bool min_version); IEnumerable<ISimulatorDevice> SelectDevices (TestTarget target, ILog log, bool min_version);
} }
} }

Просмотреть файл

@ -259,7 +259,7 @@ namespace Xharness.Hardware {
return pairs.FirstOrDefault (); return pairs.FirstOrDefault ();
} }
public async Task<ISimulatorDevice []> FindAsync (AppRunnerTarget target, ILog log, bool create_if_needed = true, bool min_version = false) public async Task<ISimulatorDevice []> FindAsync (TestTarget target, ILog log, bool create_if_needed = true, bool min_version = false)
{ {
ISimulatorDevice [] simulators = null; ISimulatorDevice [] simulators = null;
@ -269,23 +269,23 @@ namespace Xharness.Hardware {
string companion_runtime = null; string companion_runtime = null;
switch (target) { switch (target) {
case AppRunnerTarget.Simulator_iOS32: case TestTarget.Simulator_iOS32:
simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType.iPhone-5"; simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType.iPhone-5";
simulator_runtime = "com.apple.CoreSimulator.SimRuntime.iOS-" + (min_version ? SdkVersions.MiniOSSimulator : "10-3").Replace ('.', '-'); simulator_runtime = "com.apple.CoreSimulator.SimRuntime.iOS-" + (min_version ? SdkVersions.MiniOSSimulator : "10-3").Replace ('.', '-');
break; break;
case AppRunnerTarget.Simulator_iOS64: case TestTarget.Simulator_iOS64:
simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType." + (min_version ? "iPhone-6" : "iPhone-X"); simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType." + (min_version ? "iPhone-6" : "iPhone-X");
simulator_runtime = "com.apple.CoreSimulator.SimRuntime.iOS-" + (min_version ? SdkVersions.MiniOSSimulator : SdkVersions.MaxiOSSimulator).Replace ('.', '-'); simulator_runtime = "com.apple.CoreSimulator.SimRuntime.iOS-" + (min_version ? SdkVersions.MiniOSSimulator : SdkVersions.MaxiOSSimulator).Replace ('.', '-');
break; break;
case AppRunnerTarget.Simulator_iOS: case TestTarget.Simulator_iOS:
simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType.iPhone-5"; simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType.iPhone-5";
simulator_runtime = "com.apple.CoreSimulator.SimRuntime.iOS-" + (min_version ? SdkVersions.MiniOSSimulator : SdkVersions.MaxiOSSimulator).Replace ('.', '-'); simulator_runtime = "com.apple.CoreSimulator.SimRuntime.iOS-" + (min_version ? SdkVersions.MiniOSSimulator : SdkVersions.MaxiOSSimulator).Replace ('.', '-');
break; break;
case AppRunnerTarget.Simulator_tvOS: case TestTarget.Simulator_tvOS:
simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p"; simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p";
simulator_runtime = "com.apple.CoreSimulator.SimRuntime.tvOS-" + (min_version ? SdkVersions.MinTVOSSimulator : SdkVersions.MaxTVOSSimulator).Replace ('.', '-'); simulator_runtime = "com.apple.CoreSimulator.SimRuntime.tvOS-" + (min_version ? SdkVersions.MinTVOSSimulator : SdkVersions.MaxTVOSSimulator).Replace ('.', '-');
break; break;
case AppRunnerTarget.Simulator_watchOS: case TestTarget.Simulator_watchOS:
simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType." + (min_version ? "Apple-Watch-38mm" : "Apple-Watch-Series-3-38mm"); simulator_devicetype = "com.apple.CoreSimulator.SimDeviceType." + (min_version ? "Apple-Watch-38mm" : "Apple-Watch-Series-3-38mm");
simulator_runtime = "com.apple.CoreSimulator.SimRuntime.watchOS-" + (min_version ? SdkVersions.MinWatchOSSimulator : SdkVersions.MaxWatchOSSimulator).Replace ('.', '-'); simulator_runtime = "com.apple.CoreSimulator.SimRuntime.watchOS-" + (min_version ? SdkVersions.MinWatchOSSimulator : SdkVersions.MaxWatchOSSimulator).Replace ('.', '-');
companion_devicetype = "com.apple.CoreSimulator.SimDeviceType." + (min_version ? "iPhone-6" : "iPhone-X"); companion_devicetype = "com.apple.CoreSimulator.SimDeviceType." + (min_version ? "iPhone-6" : "iPhone-X");
@ -341,7 +341,7 @@ namespace Xharness.Hardware {
return available_devices.Single ((v) => v.UDID == pair.Companion); return available_devices.Single ((v) => v.UDID == pair.Companion);
} }
public IEnumerable<ISimulatorDevice> SelectDevices (AppRunnerTarget target, ILog log, bool min_version) public IEnumerable<ISimulatorDevice> SelectDevices (TestTarget target, ILog log, bool min_version)
{ {
return new SimulatorEnumerable { return new SimulatorEnumerable {
Simulators = this, Simulators = this,
@ -365,7 +365,7 @@ namespace Xharness.Hardware {
class SimulatorEnumerable : IEnumerable<ISimulatorDevice>, IAsyncEnumerable { class SimulatorEnumerable : IEnumerable<ISimulatorDevice>, IAsyncEnumerable {
public Simulators Simulators; public Simulators Simulators;
public AppRunnerTarget Target; public TestTarget Target;
public bool MinVersion; public bool MinVersion;
public ILog Log; public ILog Log;
readonly object lock_obj = new object (); readonly object lock_obj = new object ();

Просмотреть файл

@ -40,7 +40,7 @@ namespace Xharness
public string PeriodicCommandArguments { get; set; } public string PeriodicCommandArguments { get; set; }
public TimeSpan PeriodicCommandInterval { get; set; } public TimeSpan PeriodicCommandInterval { get; set; }
public string SdkRoot { get; set; } public string SdkRoot { get; set; }
public AppRunnerTarget Target { get; set; } public TestTarget Target { get; set; }
public double TimeoutInMinutes { get; set; } = 15; public double TimeoutInMinutes { get; set; } = 15;
public bool UseSystemXamarinIOSMac { get; set; } public bool UseSystemXamarinIOSMac { get; set; }
public int Verbosity { get; set; } public int Verbosity { get; set; }
@ -102,7 +102,7 @@ namespace Xharness
} }
public class Harness : IHarness { public class Harness : IHarness {
readonly AppRunnerTarget target; readonly TestTarget target;
readonly string buildConfiguration = "Debug"; readonly string buildConfiguration = "Debug";
public HarnessAction Action { get; } public HarnessAction Action { get; }
@ -605,6 +605,7 @@ namespace Xharness
foreach (var project in IOSTestProjects) { foreach (var project in IOSTestProjects) {
var runner = new AppRunner (ProcessManager, var runner = new AppRunner (ProcessManager,
new AppBundleInformationParser (),
new SimulatorsLoaderFactory (this, ProcessManager), new SimulatorsLoaderFactory (this, ProcessManager),
new SimpleListenerFactory (), new SimpleListenerFactory (),
new DeviceLoaderFactory (this, ProcessManager), new DeviceLoaderFactory (this, ProcessManager),
@ -635,6 +636,7 @@ namespace Xharness
foreach (var project in IOSTestProjects) { foreach (var project in IOSTestProjects) {
var runner = new AppRunner (ProcessManager, var runner = new AppRunner (ProcessManager,
new AppBundleInformationParser (),
new SimulatorsLoaderFactory (this, ProcessManager), new SimulatorsLoaderFactory (this, ProcessManager),
new SimpleListenerFactory (), new SimpleListenerFactory (),
new DeviceLoaderFactory (this, ProcessManager), new DeviceLoaderFactory (this, ProcessManager),
@ -663,6 +665,7 @@ namespace Xharness
foreach (var project in IOSTestProjects) { foreach (var project in IOSTestProjects) {
var runner = new AppRunner (ProcessManager, var runner = new AppRunner (ProcessManager,
new AppBundleInformationParser (),
new SimulatorsLoaderFactory (this, ProcessManager), new SimulatorsLoaderFactory (this, ProcessManager),
new SimpleListenerFactory (), new SimpleListenerFactory (),
new DeviceLoaderFactory (this, ProcessManager), new DeviceLoaderFactory (this, ProcessManager),

Просмотреть файл

@ -154,22 +154,22 @@ namespace Xharness.Jenkins
return Task.WhenAll (devs, sims); return Task.WhenAll (devs, sims);
} }
AppRunnerTarget[] GetAppRunnerTargets (TestPlatform platform) TestTarget[] GetAppRunnerTargets (TestPlatform platform)
{ {
switch (platform) { switch (platform) {
case TestPlatform.tvOS: case TestPlatform.tvOS:
return new AppRunnerTarget [] { AppRunnerTarget.Simulator_tvOS }; return new TestTarget [] { TestTarget.Simulator_tvOS };
case TestPlatform.watchOS: case TestPlatform.watchOS:
case TestPlatform.watchOS_32: case TestPlatform.watchOS_32:
case TestPlatform.watchOS_64_32: case TestPlatform.watchOS_64_32:
return new AppRunnerTarget [] { AppRunnerTarget.Simulator_watchOS }; return new TestTarget [] { TestTarget.Simulator_watchOS };
case TestPlatform.iOS_Unified: case TestPlatform.iOS_Unified:
return new AppRunnerTarget [] { AppRunnerTarget.Simulator_iOS32, AppRunnerTarget.Simulator_iOS64 }; return new TestTarget [] { TestTarget.Simulator_iOS32, TestTarget.Simulator_iOS64 };
case TestPlatform.iOS_Unified32: case TestPlatform.iOS_Unified32:
return new AppRunnerTarget [] { AppRunnerTarget.Simulator_iOS32 }; return new TestTarget [] { TestTarget.Simulator_iOS32 };
case TestPlatform.iOS_Unified64: case TestPlatform.iOS_Unified64:
case TestPlatform.iOS_TodayExtension64: case TestPlatform.iOS_TodayExtension64:
return new AppRunnerTarget [] { AppRunnerTarget.Simulator_iOS64 }; return new TestTarget [] { TestTarget.Simulator_iOS64 };
default: default:
throw new NotImplementedException (platform.ToString ()); throw new NotImplementedException (platform.ToString ());
} }
@ -199,7 +199,7 @@ namespace Xharness.Jenkins
{ {
var runtasks = new List<RunSimulatorTask> (); var runtasks = new List<RunSimulatorTask> ();
AppRunnerTarget [] targets = GetAppRunnerTargets (buildTask.Platform); TestTarget [] targets = GetAppRunnerTargets (buildTask.Platform);
TestPlatform [] platforms; TestPlatform [] platforms;
bool [] ignored; bool [] ignored;
@ -217,7 +217,7 @@ namespace Xharness.Jenkins
ignored = new [] { !IncludeiOS32, false}; ignored = new [] { !IncludeiOS32, false};
break; break;
case TestPlatform.iOS_TodayExtension64: case TestPlatform.iOS_TodayExtension64:
targets = new AppRunnerTarget[] { AppRunnerTarget.Simulator_iOS64 }; targets = new TestTarget[] { TestTarget.Simulator_iOS64 };
platforms = new TestPlatform[] { TestPlatform.iOS_TodayExtension64 }; platforms = new TestPlatform[] { TestPlatform.iOS_TodayExtension64 };
ignored = new [] { false }; ignored = new [] { false };
break; break;

Просмотреть файл

@ -48,18 +48,18 @@ namespace Xharness.Jenkins.TestTasks
case TestPlatform.iOS_Unified: case TestPlatform.iOS_Unified:
case TestPlatform.iOS_Unified32: case TestPlatform.iOS_Unified32:
case TestPlatform.iOS_Unified64: case TestPlatform.iOS_Unified64:
AppRunnerTarget = AppRunnerTarget.Device_iOS; AppRunnerTarget = TestTarget.Device_iOS;
break; break;
case TestPlatform.iOS_TodayExtension64: case TestPlatform.iOS_TodayExtension64:
AppRunnerTarget = AppRunnerTarget.Device_iOS; AppRunnerTarget = TestTarget.Device_iOS;
break; break;
case TestPlatform.tvOS: case TestPlatform.tvOS:
AppRunnerTarget = AppRunnerTarget.Device_tvOS; AppRunnerTarget = TestTarget.Device_tvOS;
break; break;
case TestPlatform.watchOS: case TestPlatform.watchOS:
case TestPlatform.watchOS_32: case TestPlatform.watchOS_32:
case TestPlatform.watchOS_64_32: case TestPlatform.watchOS_64_32:
AppRunnerTarget = AppRunnerTarget.Device_watchOS; AppRunnerTarget = TestTarget.Device_watchOS;
break; break;
default: default:
throw new NotImplementedException (); throw new NotImplementedException ();
@ -82,6 +82,7 @@ namespace Xharness.Jenkins.TestTasks
Jenkins.MainLog.WriteLine ("Acquired device '{0}' for '{1}'", Device.Name, ProjectFile); Jenkins.MainLog.WriteLine ("Acquired device '{0}' for '{1}'", Device.Name, ProjectFile);
runner = new AppRunner (processManager, runner = new AppRunner (processManager,
new AppBundleInformationParser (),
new SimulatorsLoaderFactory (Harness, processManager), new SimulatorsLoaderFactory (Harness, processManager),
new SimpleListenerFactory (), new SimpleListenerFactory (),
new DeviceLoaderFactory (Harness, processManager), new DeviceLoaderFactory (Harness, processManager),
@ -148,6 +149,7 @@ namespace Xharness.Jenkins.TestTasks
// will do both of these things, preparing the device for launching the today extension). // will do both of these things, preparing the device for launching the today extension).
AppRunner todayRunner = new AppRunner (processManager, AppRunner todayRunner = new AppRunner (processManager,
new AppBundleInformationParser (),
new SimulatorsLoaderFactory (Harness, processManager), new SimulatorsLoaderFactory (Harness, processManager),
new SimpleListenerFactory (), new SimpleListenerFactory (),
new DeviceLoaderFactory (Harness, processManager), new DeviceLoaderFactory (Harness, processManager),

Просмотреть файл

@ -34,11 +34,11 @@ namespace Xharness.Jenkins.TestTasks
{ {
var project = Path.GetFileNameWithoutExtension (ProjectFile); var project = Path.GetFileNameWithoutExtension (ProjectFile);
if (project.EndsWith ("-tvos", StringComparison.Ordinal)) { if (project.EndsWith ("-tvos", StringComparison.Ordinal)) {
AppRunnerTarget = AppRunnerTarget.Simulator_tvOS; AppRunnerTarget = TestTarget.Simulator_tvOS;
} else if (project.EndsWith ("-watchos", StringComparison.Ordinal)) { } else if (project.EndsWith ("-watchos", StringComparison.Ordinal)) {
AppRunnerTarget = AppRunnerTarget.Simulator_watchOS; AppRunnerTarget = TestTarget.Simulator_watchOS;
} else { } else {
AppRunnerTarget = AppRunnerTarget.Simulator_iOS; AppRunnerTarget = TestTarget.Simulator_iOS;
} }
this.simulators = simulators ?? throw new ArgumentNullException (nameof (simulators)); this.simulators = simulators ?? throw new ArgumentNullException (nameof (simulators));
@ -78,6 +78,7 @@ namespace Xharness.Jenkins.TestTasks
var clean_state = false;//Platform == TestPlatform.watchOS; var clean_state = false;//Platform == TestPlatform.watchOS;
runner = new AppRunner (processManager, runner = new AppRunner (processManager,
new AppBundleInformationParser (),
new SimulatorsLoaderFactory (Harness, processManager), new SimulatorsLoaderFactory (Harness, processManager),
new SimpleListenerFactory (), new SimpleListenerFactory (),
new DeviceLoaderFactory (Harness, processManager), new DeviceLoaderFactory (Harness, processManager),

Просмотреть файл

@ -11,7 +11,7 @@ namespace Xharness.Jenkins.TestTasks
{ {
abstract class RunXITask<TDevice> : RunTestTask where TDevice : class, IDevice abstract class RunXITask<TDevice> : RunTestTask where TDevice : class, IDevice
{ {
public AppRunnerTarget AppRunnerTarget; public TestTarget AppRunnerTarget;
protected AppRunner runner; protected AppRunner runner;
protected AppRunner additional_runner; protected AppRunner additional_runner;

10
tests/xharness/RunMode.cs Normal file
Просмотреть файл

@ -0,0 +1,10 @@
namespace Xharness {
public enum RunMode {
Sim32,
Sim64,
Classic,
iOS,
TvOS,
WatchOS,
}
}

Просмотреть файл

@ -0,0 +1,43 @@
using System;
namespace Xharness {
public enum TestTarget {
None,
Simulator_iOS,
Simulator_iOS32,
Simulator_iOS64,
Simulator_tvOS,
Simulator_watchOS,
Device_iOS,
Device_tvOS,
Device_watchOS,
}
public static class TestTargetExtensions {
public static RunMode ToRunMode (this TestTarget target) => target switch
{
TestTarget.Simulator_iOS => RunMode.Classic,
TestTarget.Simulator_iOS32 => RunMode.Sim32,
TestTarget.Simulator_iOS64 => RunMode.Sim64,
TestTarget.Simulator_tvOS => RunMode.TvOS,
TestTarget.Simulator_watchOS => RunMode.WatchOS,
TestTarget.Device_iOS => RunMode.iOS,
TestTarget.Device_tvOS => RunMode.TvOS,
TestTarget.Device_watchOS => RunMode.WatchOS,
_ => throw new ArgumentOutOfRangeException ($"Unknown target: {target}"),
};
public static bool IsSimulator (this TestTarget target) => target switch
{
TestTarget.Simulator_iOS => true,
TestTarget.Simulator_iOS32 => true,
TestTarget.Simulator_iOS64 => true,
TestTarget.Simulator_tvOS => true,
TestTarget.Simulator_watchOS => true,
TestTarget.Device_iOS => false,
TestTarget.Device_tvOS => false,
TestTarget.Device_watchOS => false,
_ => throw new ArgumentOutOfRangeException ($"Unknown target: {target}"),
};
}
}

Просмотреть файл

@ -5,54 +5,54 @@ using System.Threading.Tasks;
namespace Xharness.Utilities { namespace Xharness.Utilities {
public static class Extensions { public static class Extensions {
public static string AsString (this AppRunnerTarget @this) public static string AsString (this TestTarget @this)
{ {
switch (@this) { switch (@this) {
case AppRunnerTarget.None: case TestTarget.None:
return null; return null;
case AppRunnerTarget.Device_iOS: case TestTarget.Device_iOS:
return "ios-device"; return "ios-device";
case AppRunnerTarget.Device_tvOS: case TestTarget.Device_tvOS:
return "tvos-device"; return "tvos-device";
case AppRunnerTarget.Device_watchOS: case TestTarget.Device_watchOS:
return "watchos-device"; return "watchos-device";
case AppRunnerTarget.Simulator_iOS: case TestTarget.Simulator_iOS:
return "ios-simulator"; return "ios-simulator";
case AppRunnerTarget.Simulator_iOS32: case TestTarget.Simulator_iOS32:
return "ios-simulator-32"; return "ios-simulator-32";
case AppRunnerTarget.Simulator_iOS64: case TestTarget.Simulator_iOS64:
return "ios-simulator-64"; return "ios-simulator-64";
case AppRunnerTarget.Simulator_tvOS: case TestTarget.Simulator_tvOS:
return "tvos-simulator"; return "tvos-simulator";
case AppRunnerTarget.Simulator_watchOS: case TestTarget.Simulator_watchOS:
return "watchos-simulator"; return "watchos-simulator";
default: default:
throw new NotImplementedException (); throw new NotImplementedException ();
} }
} }
public static AppRunnerTarget ParseAsAppRunnerTarget (this string @this) public static TestTarget ParseAsAppRunnerTarget (this string @this)
{ {
switch (@this) { switch (@this) {
case "ios-device": case "ios-device":
return AppRunnerTarget.Device_iOS; return TestTarget.Device_iOS;
case "tvos-device": case "tvos-device":
return AppRunnerTarget.Device_tvOS; return TestTarget.Device_tvOS;
case "watchos-device": case "watchos-device":
return AppRunnerTarget.Device_watchOS; return TestTarget.Device_watchOS;
case "ios-simulator": case "ios-simulator":
return AppRunnerTarget.Simulator_iOS; return TestTarget.Simulator_iOS;
case "ios-simulator-32": case "ios-simulator-32":
return AppRunnerTarget.Simulator_iOS32; return TestTarget.Simulator_iOS32;
case "ios-simulator-64": case "ios-simulator-64":
return AppRunnerTarget.Simulator_iOS64; return TestTarget.Simulator_iOS64;
case "tvos-simulator": case "tvos-simulator":
return AppRunnerTarget.Simulator_tvOS; return TestTarget.Simulator_tvOS;
case "watchos-simulator": case "watchos-simulator":
return AppRunnerTarget.Simulator_watchOS; return TestTarget.Simulator_watchOS;
case null: case null:
case "": case "":
return AppRunnerTarget.None; return TestTarget.None;
default: default:
throw new NotImplementedException (@this); throw new NotImplementedException (@this);
} }

Просмотреть файл

@ -134,11 +134,11 @@ namespace Xharness.Tests.Hardware.Tests {
Assert.AreEqual (75, simulators.AvailableDevices.Count()); Assert.AreEqual (75, simulators.AvailableDevices.Count());
} }
[TestCase (AppRunnerTarget.Simulator_iOS64, 1)] [TestCase (TestTarget.Simulator_iOS64, 1)]
[TestCase (AppRunnerTarget.Simulator_iOS32, 1)] [TestCase (TestTarget.Simulator_iOS32, 1)]
[TestCase (AppRunnerTarget.Simulator_tvOS, 1)] [TestCase (TestTarget.Simulator_tvOS, 1)]
[TestCase (AppRunnerTarget.Simulator_watchOS, 2)] [TestCase (TestTarget.Simulator_watchOS, 2)]
public async Task FindAsyncDoNotCreateTest (AppRunnerTarget target, int expected) public async Task FindAsyncDoNotCreateTest (TestTarget target, int expected)
{ {
string processPath = null; string processPath = null;
MlaunchArguments passedArguments = null; MlaunchArguments passedArguments = null;

Просмотреть файл

@ -0,0 +1,41 @@
using System.IO;
using System.Reflection;
using NUnit.Framework;
namespace Xharness.Tests {
[TestFixture]
public class AppBundleInformationParserTests {
const string appName = "com.xamarin.bcltests.SystemXunit";
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");
[SetUp]
public void SetUp ()
{
Directory.CreateDirectory (appPath);
}
[TearDown]
public void TearDown ()
{
Directory.Delete (appPath, true);
}
[Test]
public void InitializeTest ()
{
var parser = new AppBundleInformationParser ();
var info = parser.ParseFromProject (projectFilePath, TestTarget.Simulator_iOS64, "Debug");
Assert.AreEqual (appName, info.AppName);
Assert.AreEqual (appPath, info.AppPath);
Assert.AreEqual (appPath, info.LaunchAppPath);
Assert.AreEqual (appName, info.BundleIdentifier);
}
}
}

Просмотреть файл

@ -63,6 +63,7 @@ namespace Xharness.Tests {
IDeviceLoaderFactory devicesFactory; IDeviceLoaderFactory devicesFactory;
ISimpleListenerFactory listenerFactory; ISimpleListenerFactory listenerFactory;
ICrashSnapshotReporterFactory snapshotReporterFactory; ICrashSnapshotReporterFactory snapshotReporterFactory;
IAppBundleInformationParser appBundleInformationParser;
[SetUp] [SetUp]
public void SetUp () public void SetUp ()
@ -95,15 +96,29 @@ namespace Xharness.Tests {
mock4.Setup (m => m.Create (It.IsAny<ILog> (), It.IsAny<ILogs> (), It.IsAny<bool> (), It.IsAny<string> ())).Returns (snapshotReporter.Object); mock4.Setup (m => m.Create (It.IsAny<ILog> (), It.IsAny<ILogs> (), It.IsAny<bool> (), It.IsAny<string> ())).Returns (snapshotReporter.Object);
snapshotReporterFactory = mock4.Object; snapshotReporterFactory = mock4.Object;
var mock5 = new Mock<IAppBundleInformationParser> ();
mock5
.Setup (x => x.ParseFromProject (projectFilePath, It.IsAny<TestTarget> (), "Debug"))
.Returns (new AppBundleInformation (appName, appName, appPath, appPath, null));
appBundleInformationParser = mock5.Object;
mainLog = new Mock<ILog> (); mainLog = new Mock<ILog> ();
Directory.CreateDirectory (appPath); Directory.CreateDirectory (appPath);
} }
[TearDown]
public void TearDown ()
{
Directory.Delete (appPath, true);
}
[Test] [Test]
public void InitializeTest () public void InitializeTest ()
{ {
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -111,7 +126,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), Mock.Of<ICaptureLogFactory> (),
Mock.Of<IDeviceLogCapturerFactory> (), Mock.Of<IDeviceLogCapturerFactory> (),
Mock.Of<IResultParser> (), Mock.Of<IResultParser> (),
AppRunnerTarget.Simulator_iOS64, TestTarget.Simulator_iOS64,
Mock.Of<IHarness> (), Mock.Of<IHarness> (),
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -128,6 +143,7 @@ namespace Xharness.Tests {
public void InstallToSimulatorTest () public void InstallToSimulatorTest ()
{ {
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -135,7 +151,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), Mock.Of<ICaptureLogFactory> (),
Mock.Of<IDeviceLogCapturerFactory> (), Mock.Of<IDeviceLogCapturerFactory> (),
Mock.Of<IResultParser> (), Mock.Of<IResultParser> (),
AppRunnerTarget.Simulator_iOS64, TestTarget.Simulator_iOS64,
Mock.Of<IHarness> (), Mock.Of<IHarness> (),
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -151,6 +167,7 @@ namespace Xharness.Tests {
public void UninstallToSimulatorTest () public void UninstallToSimulatorTest ()
{ {
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -158,7 +175,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), Mock.Of<ICaptureLogFactory> (),
Mock.Of<IDeviceLogCapturerFactory> (), Mock.Of<IDeviceLogCapturerFactory> (),
Mock.Of<IResultParser> (), Mock.Of<IResultParser> (),
AppRunnerTarget.Simulator_iOS64, TestTarget.Simulator_iOS64,
Mock.Of<IHarness> (), Mock.Of<IHarness> (),
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -174,6 +191,7 @@ namespace Xharness.Tests {
public void InstallWhenNoDevicesTest () public void InstallWhenNoDevicesTest ()
{ {
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -181,7 +199,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), Mock.Of<ICaptureLogFactory> (),
Mock.Of<IDeviceLogCapturerFactory> (), Mock.Of<IDeviceLogCapturerFactory> (),
Mock.Of<IResultParser> (), Mock.Of<IResultParser> (),
AppRunnerTarget.Device_iOS, TestTarget.Device_iOS,
Mock.Of<IHarness> (), Mock.Of<IHarness> (),
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -206,6 +224,7 @@ namespace Xharness.Tests {
processManager.SetReturnsDefault (Task.FromResult (processResult)); processManager.SetReturnsDefault (Task.FromResult (processResult));
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -213,7 +232,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), Mock.Of<ICaptureLogFactory> (),
Mock.Of<IDeviceLogCapturerFactory> (), Mock.Of<IDeviceLogCapturerFactory> (),
Mock.Of<IResultParser> (), Mock.Of<IResultParser> (),
AppRunnerTarget.Device_iOS, TestTarget.Device_iOS,
harness, harness,
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -259,6 +278,7 @@ namespace Xharness.Tests {
processManager.SetReturnsDefault (Task.FromResult (processResult)); processManager.SetReturnsDefault (Task.FromResult (processResult));
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -266,7 +286,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), Mock.Of<ICaptureLogFactory> (),
Mock.Of<IDeviceLogCapturerFactory> (), Mock.Of<IDeviceLogCapturerFactory> (),
Mock.Of<IResultParser> (), Mock.Of<IResultParser> (),
AppRunnerTarget.Device_iOS, TestTarget.Device_iOS,
harness, harness,
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -316,7 +336,7 @@ namespace Xharness.Tests {
string simulatorLogPath = Path.Combine (Path.GetTempPath (), "simulator-logs"); string simulatorLogPath = Path.Combine (Path.GetTempPath (), "simulator-logs");
simulators simulators
.Setup (x => x.FindAsync (AppRunnerTarget.Simulator_tvOS, mainLog.Object, true, false)) .Setup (x => x.FindAsync (TestTarget.Simulator_tvOS, mainLog.Object, true, false))
.ReturnsAsync ((ISimulatorDevice []) null); .ReturnsAsync ((ISimulatorDevice []) null);
var listenerLogFile = new Mock<ILogFile> (); var listenerLogFile = new Mock<ILogFile> ();
@ -342,6 +362,7 @@ namespace Xharness.Tests {
// Act // Act
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -349,7 +370,7 @@ namespace Xharness.Tests {
captureLogFactory.Object, captureLogFactory.Object,
Mock.Of<IDeviceLogCapturerFactory> (), Mock.Of<IDeviceLogCapturerFactory> (),
Mock.Of<IResultParser> (), Mock.Of<IResultParser> (),
AppRunnerTarget.Simulator_tvOS, TestTarget.Simulator_tvOS,
GetMockedHarness (), GetMockedHarness (),
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -397,7 +418,7 @@ namespace Xharness.Tests {
simulator.SetupGet (x => x.SystemLog).Returns (Path.Combine (simulatorLogPath, "system.log")); simulator.SetupGet (x => x.SystemLog).Returns (Path.Combine (simulatorLogPath, "system.log"));
simulators simulators
.Setup (x => x.FindAsync (AppRunnerTarget.Simulator_iOS64, mainLog.Object, true, false)) .Setup (x => x.FindAsync (TestTarget.Simulator_iOS64, mainLog.Object, true, false))
.ReturnsAsync (new ISimulatorDevice [] { simulator.Object }); .ReturnsAsync (new ISimulatorDevice [] { simulator.Object });
var testResultFilePath = Path.GetTempFileName (); var testResultFilePath = Path.GetTempFileName ();
@ -450,6 +471,7 @@ namespace Xharness.Tests {
// Act // Act
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -457,7 +479,7 @@ namespace Xharness.Tests {
captureLogFactory.Object, captureLogFactory.Object,
Mock.Of<IDeviceLogCapturerFactory> (), // Use for devices only Mock.Of<IDeviceLogCapturerFactory> (), // Use for devices only
resultParser.Object, resultParser.Object,
AppRunnerTarget.Simulator_iOS64, TestTarget.Simulator_iOS64,
harness, harness,
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -513,6 +535,7 @@ namespace Xharness.Tests {
// Act // Act
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -520,7 +543,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), Mock.Of<ICaptureLogFactory> (),
Mock.Of<IDeviceLogCapturerFactory> (), Mock.Of<IDeviceLogCapturerFactory> (),
Mock.Of<IResultParser> (), Mock.Of<IResultParser> (),
AppRunnerTarget.Device_tvOS, TestTarget.Device_tvOS,
GetMockedHarness (), GetMockedHarness (),
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -604,6 +627,7 @@ namespace Xharness.Tests {
// Act // Act
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -611,7 +635,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), // Used for simulators only Mock.Of<ICaptureLogFactory> (), // Used for simulators only
deviceLogCapturerFactory.Object, deviceLogCapturerFactory.Object,
resultParser.Object, resultParser.Object,
AppRunnerTarget.Device_iOS, TestTarget.Device_iOS,
harness, harness,
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,
@ -712,6 +736,7 @@ namespace Xharness.Tests {
// Act // Act
var appRunner = new AppRunner (processManager.Object, var appRunner = new AppRunner (processManager.Object,
appBundleInformationParser,
simulatorsFactory, simulatorsFactory,
listenerFactory, listenerFactory,
devicesFactory, devicesFactory,
@ -719,7 +744,7 @@ namespace Xharness.Tests {
Mock.Of<ICaptureLogFactory> (), // Used for simulators only Mock.Of<ICaptureLogFactory> (), // Used for simulators only
deviceLogCapturerFactory.Object, deviceLogCapturerFactory.Object,
resultParser.Object, resultParser.Object,
AppRunnerTarget.Device_iOS, TestTarget.Device_iOS,
harness, harness,
mainLog.Object, mainLog.Object,
logs.Object, logs.Object,

Просмотреть файл

@ -58,6 +58,7 @@
<Compile Include="BCLTestImporter\Tests\BCLTestProjectGeneratorTest.cs" /> <Compile Include="BCLTestImporter\Tests\BCLTestProjectGeneratorTest.cs" />
<Compile Include="BCLTestImporter\Tests\TestAssemblyDefinitionTest.cs" /> <Compile Include="BCLTestImporter\Tests\TestAssemblyDefinitionTest.cs" />
<Compile Include="BCLTestImporter\Tests\TestProjectDefinitionTest.cs" /> <Compile Include="BCLTestImporter\Tests\TestProjectDefinitionTest.cs" />
<Compile Include="Tests\AppBundleInformationParserTests.cs" />
<Compile Include="Tests\AppRunnerTests.cs" /> <Compile Include="Tests\AppRunnerTests.cs" />
<Compile Include="Tests\CrashReportSnapshotTests.cs" /> <Compile Include="Tests\CrashReportSnapshotTests.cs" />
<Compile Include="Tests\XmlResultParserTests.cs" /> <Compile Include="Tests\XmlResultParserTests.cs" />

Просмотреть файл

@ -73,9 +73,12 @@
<PackageReference Include="Mono.Options" Version="5.3.0.1" /> <PackageReference Include="Mono.Options" Version="5.3.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AppBundleInformationParser.cs" />
<Compile Include="AppInstallMonitorLog.cs" /> <Compile Include="AppInstallMonitorLog.cs" />
<Compile Include="AppRunner.cs" /> <Compile Include="AppRunner.cs" />
<Compile Include="AppRunnerTarget.cs" /> <Compile Include="Extension.cs" />
<Compile Include="RunMode.cs" />
<Compile Include="TestTarget.cs" />
<Compile Include="BCLTestImporter\BCLTestImportTargetFactory.cs" /> <Compile Include="BCLTestImporter\BCLTestImportTargetFactory.cs" />
<Compile Include="BCLTestImporter\BCLTestInfoPlistGenerator.cs" /> <Compile Include="BCLTestImporter\BCLTestInfoPlistGenerator.cs" />
<Compile Include="BCLTestImporter\BCLTestProjectDefinition.cs" /> <Compile Include="BCLTestImporter\BCLTestProjectDefinition.cs" />