public ServiceProcessInfo(RunnerMode mode, params string[] assemblies) { FilePath = "AxoCover.Runner.exe".ToAbsolutePath(); var assemblyArgs = string.Join(" ", assemblies.Select(p => "\"" + p + "\"")); Arguments = string.Join(" ", mode, Process.GetCurrentProcess().Id, assemblyArgs); }
public ServiceProcessInfo(RunnerMode mode, CommunicationProtocol protocol, bool debugMode, params string[] assemblies) { FilePath = "AxoCover.Runner.exe".ToAbsolutePath(); var assemblyArgs = string.Join(" ", assemblies.Select(p => "\"" + p + "\"")); Arguments = string.Join(" ", mode, Process.GetCurrentProcess().Id, protocol.ToString(), debugMode.ToString(), assemblyArgs); }
public static List <TestSuite> XmlGetTestExecutionInfo(RunnerMode mode) { if (!mode.Equals(RunnerMode.Xml)) { return(null); } var runSuites = new List <TestSuite>(); var runSuite = new TestSuite(); var runCases = new List <TestCase>(); var xmlPath = Config.TestExecutionXmlPath; if (File.Exists(xmlPath)) { using (XmlReader reader = XmlReader.Create(xmlPath)) { bool isCaseRun = false; bool isSuiteRun = false; string name = string.Empty; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Suite": isSuiteRun = bool.Parse(reader["IsRun"]); name = reader["Name"]; if (name != null && isSuiteRun) { runSuite = new TestSuite(); runSuite.SetName(name); runCases = new List <TestCase>(); } break; case "Case": isCaseRun = bool.Parse(reader["IsRun"]); if (isSuiteRun && isCaseRun && reader.Read()) { var runCase = new TestCase(); runCase.SetName(reader.Value.Trim()); runCases.Add(runCase); } break; } } } } } return(runSuites.ToList()); }
private static void RunTestService(RunnerMode runnerMode, int parentPid, CommunicationProtocol protocol, string[] assemblyPaths) { AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; foreach (var assemblyPath in assemblyPaths) { Console.Write($"Loading {assemblyPath}... "); Assembly.LoadFrom(assemblyPath); Console.WriteLine("Done."); } Process parentProcess = null; try { parentProcess = Process.GetProcessById(parentPid); parentProcess.EnableRaisingEvents = true; parentProcess.Exited += OnParentProcessExited; } catch (Exception e) { throw new Exception("Cannot open parent process.", e); } Type serviceInterface; Type serviceImplementation; GetService(runnerMode, out serviceInterface, out serviceImplementation); Console.WriteLine("AxoCover.Runner"); Console.WriteLine("Copyright (c) 2016-2017 Péter Major"); Console.WriteLine(); Console.WriteLine($"Starting {runnerMode} service..."); var serviceAddress = NetworkingExtensions.GetServiceAddress(protocol); var serviceBinding = NetworkingExtensions.GetServiceBinding(protocol); var serviceHost = new ServiceHost(serviceImplementation, new[] { serviceAddress }); serviceHost.AddServiceEndpoint(serviceInterface, serviceBinding, serviceAddress); serviceHost.Open(); ServiceProcess.PrintServiceStarted(serviceAddress); _isFinished.WaitOne(); Console.WriteLine("Exiting..."); try { serviceHost.Close(_closeTimeout); } catch { } //Make sure to kill leftover non-background threads started by tests Environment.Exit(0); }
public List <TestSuite> RunTest(RunnerMode mode) { var assembly = Assembly.GetCallingAssembly(); var xmlSuites = Supporter.XmlGetTestExecutionInfo(mode); var testClasses = Supporter.GetTestClasses(xmlSuites, assembly); Logger.LogMsg(Severity.INFO, $" >>> The following suites will be executed <<<<"); Logger.LogMsg(Severity.INFO, string.Join(Environment.NewLine, testClasses.Select(c => c.Name))); var index = 1; var testSuites = new List <TestSuite>(); foreach (var testClass in testClasses) { var isRerun = false; var rerunTime = 0; var failedCases = new List <TestCase>(); var testMethodsInClass = Supporter.GetTestMethods(xmlSuites, testClass); do { var testSuite = Supporter.CreateTestSuite(testClass, index); Logger.LogMsg(Severity.INFO, $"Test suite: {testSuite.Name} stared at: {DateTime.Now}"); var testMethodsExecuted = failedCases.Any() ? testMethodsInClass.Where(t => failedCases.Any(tc => tc.Name.ToLower().Equals(t.Name.ToLower()))).Distinct().ToList() : testMethodsInClass.Distinct().ToList(); var testCases = Supporter.ExecuteTestMethodsInClass(testClass, testMethodsExecuted, testSuite); testSuite.AddTestCases(testCases); testSuite.Finish(); testSuites.Add(testSuite); Logger.WriteLine(testSuite); Logger.LogMsg(Severity.INFO, $"Test suite: {testSuite.Name} completed at: {DateTime.Now} => runtime: {rerunTime + 1}, rerun: {rerunTime}"); failedCases = testCases.Where(t => t.Status == Status.Failed).ToList(); isRerun = (failedCases.Any() && rerunTime < Config.RerunCase && testSuite.Status == Status.Undefined); rerunTime++; index++; } while (isRerun); } var reporter = new Reporter(); reporter.GenerateReports(testSuites); return(testSuites); }
private static void GetService(RunnerMode runnerMode, out Type serviceInterface, out Type serviceImplementation) { switch (runnerMode) { case RunnerMode.Discovery: serviceInterface = typeof(ITestDiscoveryService); serviceImplementation = typeof(TestDiscoveryService); break; case RunnerMode.Execution: serviceInterface = typeof(ITestExecutionService); serviceImplementation = typeof(TestExecutionService); break; default: throw new Exception("Invalid mode of usage specified!"); } }
// protected void LoadDefaultGame() // { // // Boot the game // } public virtual bool Load(string path, RunnerMode newMode = RunnerMode.Playing, Dictionary <string, string> metaData = null) { try { if (newMode == RunnerMode.Loading) { nextPathToLoad = path; // Save a copy of the meta data nextMetaData = metaData?.ToDictionary(entry => entry.Key, entry => entry.Value); nextMode = RunnerMode.Playing; // Create new meta data for the pre-loader metaData = new Dictionary <string, string> { { "nextMode", nextMode.ToString() }, { "showDiskAnimation", "false" } }; // Look to see if the game's meta data changes the disk animation flag if (nextMetaData != null && nextMetaData.ContainsKey("showDiskAnimation")) { metaData["showDiskAnimation"] = nextMetaData["showDiskAnimation"]; } // TODO this was where the eject animation flag was set // Get the default path to the load tool from the bios path = bios.ReadBiosData("LoadTool", "/PixelVisionOS/Tools/LoadTool/"); // Change the mode to loading newMode = RunnerMode.Loading; } // Create a new meta data dictionary if one doesn't exist yet if (metaData == null) { metaData = new Dictionary <string, string>(); } // Spit path and convert to a list var splitPath = path.Split('/').ToList(); var gameName = ""; var rootPath = "/"; var total = splitPath.Count - 1; // Loop through each item in the path and get the game name and root path for (var i = 1; i < total; i++) { if (i < total - 1) { rootPath += splitPath[i] + "/"; } else { gameName = splitPath[i]; } } // Console.WriteLine("Load "+ gameName + " in " + rootPath); // Add the game's name and root path to the meta data if (metaData.ContainsKey("GameName")) { metaData["GameName"] = gameName; } else { metaData.Add("GameName", gameName); } // Change the root path for the game's meta data if (metaData.ContainsKey("RootPath")) { metaData["RootPath"] = rootPath; } else { metaData.Add("RootPath", rootPath); } // Update the runner mode mode = newMode; // When playing a game, save it to history and the meta data so it can be reloaded correctly if (mode == RunnerMode.Playing) { lastMode = mode; var metaDataCopy = metaData.ToDictionary(entry => entry.Key, entry => entry.Value); if (loadHistory.Count > 0) { // Console.WriteLine("History " + loadHistory.Last().Key + " " + path); // Only add the history if the last item is not the same // Loop through the history and see if the path already exists for (int i = loadHistory.Count - 1; i >= 0; i--) { if (loadHistory[i].Key == path) { loadHistory.RemoveAt(i); } } if (loadHistory.Last().Key != path) { loadHistory.Add(new KeyValuePair <string, Dictionary <string, string> >(path, metaDataCopy)); } } else { loadHistory.Add(new KeyValuePair <string, Dictionary <string, string> >(path, metaDataCopy)); } } // Create a new tmpEngine ConfigureEngine(metaData); // Path the full path to the engine's name tmpEngine.name = path; bool success; // Have the workspace run the game from the current path var files = workspaceService.LoadGame(path); if (files != null) { // Read and Run the disk ProcessFiles(tmpEngine, files, displayProgress); success = true; } else { DisplayError(ErrorCode.LoadError, new Dictionary <string, string> { { "@{path}", path } }); success = false; } // TODO need to remove old load disk animation? // if (metaDataCopy.ContainsKey("showDiskAnimation")) // { // metaData["showDiskAnimation"] = "false"; // } // If the game is unable to run, display an error // if (success == false) // Create new FileSystemPath return(success); // return base.Load(path, newMode, metaData); } catch (Exception e) { // Console.WriteLine("Load Error:\n"+e.Message); DisplayError(ErrorCode.Exception, new Dictionary <string, string> { { "@{error}", e is ScriptRuntimeException error ? error.DecoratedMessage : e.Message } }, e);