private bool validateOnly(RunInput input, SystemRecycled systemRecycled) { var fixtures = buildFixturesWithOverrides(input, systemRecycled); var library = FixtureLibrary.From(fixtures); var specs = HierarchyLoader.ReadHierarchy(input.SpecPath).GetAllSpecs().ToArray(); SpecificationPostProcessor.PostProcessAll(specs, library); var errored = specs.Where(x => x.errors.Any()).ToArray(); if (errored.Any()) { ConsoleWriter.Write(ConsoleColor.Red, "Errors Detected!"); foreach (var errorSpec in errored) { ConsoleWriter.Write(ConsoleColor.Yellow, errorSpec.Filename); foreach (var error in errorSpec.errors) { Console.WriteLine($"{error.location.Join(" / ")} -> {error.message}"); } } return(false); } else { ConsoleWriter.Write(ConsoleColor.Green, "No validation errors or missing data detected in this project"); return(true); } }
private void sendFailedToStartMessage() { #if NET46 var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; #else var baseDirectory = AppContext.BaseDirectory; #endif var writer = new StringWriter(); writer.WriteLine($"Unable to start process '{_command}'"); writer.WriteLine(); writer.WriteLine("Check the console output for details, or try this command in the root of the specification project:"); writer.WriteLine(); writer.WriteLine(_testCommand); writer.WriteLine(); writer.WriteLine($"The error is logged to {baseDirectory.AppendPath("storyteller.log")}"); var message = new SystemRecycled { success = false, fixtures = new FixtureModel[0], system_name = "Unknown", system_full_name = "Unknown", name = Path.GetFileName(baseDirectory), error = writer.ToString() }; EventAggregator.SendMessage(message); }
private void writeSystemUsage(SystemRecycled systemRecycled) { Console.WriteLine("Using System: " + systemRecycled.system_name); systemRecycled.properties.Each(pair => { Console.WriteLine("{0}: {1}", pair.Key, pair.Value); }); Console.WriteLine(); }
public void Start(Project project) { if (_running != null) { Console.WriteLine($"AGENT: Trying to start specification runner for {_running.GetType().Name} at {project.ProjectPath} and port {project.Port}"); } Project.CurrentProject = project; _project = project; Type systemType = null; try { if (_running == null) { buildRunningSystem(); } if (project.Mode == EngineMode.ExportOnly) { EventAggregator.SendMessage(_running.RecycledMessage); return; } _engine = project.Mode == EngineMode.Interactive ? buildUserInterfaceEngine() : buildBatchedEngine(project.TracingStyle); _engine.Start(project.StopConditions); ConsoleWriter.Write("AGENT: Specification running engine ready at " + project.ProjectPath); } catch (Exception e) { StorytellerAgent.LogFailure(e); ConsoleWriter.Write(ConsoleColor.Red, e.ToString()); var message = new SystemRecycled { error = e.ToString(), success = false, }; EventAggregator.SendMessage(message); } }
public void Start(Project project) { if (_system != null) { Console.WriteLine($"AGENT: Trying to start specification runner for {_system.GetType().Name} at {project.ProjectPath} and port {project.Port}"); } Project.CurrentProject = project; _project = project; Type systemType = null; try { if (_system == null) { systemType = _project.DetermineSystemType(); _system = Activator.CreateInstance(systemType).As <ISystem>(); _disposables.Add(_system); } _specExpiration = new SpecExpiration(); _engine = project.Mode == EngineMode.Interactive ? buildUserInterfaceEngine() : buildBatchedEngine(project.TracingStyle); _engine.Start(project.StopConditions); ConsoleWriter.Write("AGENT: Specification running engine ready at " + project.ProjectPath); } catch (Exception e) { ConsoleWriter.Write(ConsoleColor.Red, e.ToString()); var message = new SystemRecycled { error = e.ToString(), success = false, }; if (systemType != null) { message.system_name = systemType.AssemblyQualifiedName; } EventAggregator.SendMessage(message); } }
internal FixtureModel[] BuildFixturesWithOverrides(SystemRecycled systemRecycled) { var overrides = FixtureLoader.LoadFromPath(FixturePath); var system = new FixtureLibrary(); foreach (var fixture in systemRecycled.fixtures) { system.Models[fixture.key] = fixture; } return(system.ApplyOverrides(overrides).Models.ToArray()); }
private static FixtureModel[] buildFixturesWithOverrides(RunInput input, SystemRecycled systemRecycled) { var overrides = FixtureLoader.LoadFromPath(input.FixturePath); var system = new FixtureLibrary(); foreach (var fixture in systemRecycled.fixtures) { system.Models[fixture.key] = fixture; } return(system.ApplyOverrides(overrides).Models.ToArray()); }
private static void writeResults(RunInput input, SystemRecycled systemRecycled, BatchRunResponse results) { results.suite = input.WorkspaceFlag; results.system = systemRecycled.system_name; results.time = DateTime.Now.ToString(); results.fixtures = buildFixturesWithOverrides(input, systemRecycled); var document = BatchResultsWriter.BuildResults(results); Console.WriteLine("Writing results to " + input.ResultsPathFlag); document.WriteToFile(input.ResultsPathFlag); }
private void sendFailedToStartMessage() { var message = new SystemRecycled { success = false, fixtures = new FixtureModel[0], system_name = "Unknown", system_full_name = "Unknown", name = Path.GetFileName(AppContext.BaseDirectory), error = $"Unable to start process '{_command}'" }; EventAggregator.SendMessage(message); }
private RunningSystem(ISystem system) { CellHandling cellHandling = null; System = system; try { cellHandling = system.Start() ?? CellHandling.Basic(); System = cellHandling.Extensions.Any() ? new CompositeSystem(system, cellHandling) : system; } catch (Exception ex) { ConsoleWriter.Write(ConsoleColor.Red, ex.ToString()); RecycledMessage = new SystemRecycled { success = false, fixtures = new FixtureModel[0], system_name = system.ToString(), system_full_name = system.GetType().FullName, #if NET46 name = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory), #else name = Path.GetFileName(AppContext.BaseDirectory), #endif error = ex.ToString() }; return; } Fixtures = FixtureLibrary.CreateForAppDomain(cellHandling); RecycledMessage = new SystemRecycled { success = true, fixtures = Fixtures.Models.GetAll().ToArray(), system_name = system.ToString(), #if NET46 name = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory) #else name = Path.GetFileName(AppContext.BaseDirectory) #endif }; }
public Task <SystemRecycled> Start() { var library = new FixtureLibrary() .With <OverriddenFixture>() .With <SystemFixture>(); var recycled = new SystemRecycled { fixtures = library.Fixtures.Select(x => x.Compile(CellHandling.Basic())).ToArray() }; LatestSystemRecycled = recycled; return(Task.FromResult(recycled)); }
public static SystemRecycled Initialize(this ISystem system, Action <FixtureLibrary> onStarted) { CellHandling cellHandling = null; try { cellHandling = system.Start() ?? CellHandling.Basic(); } catch (Exception ex) { ConsoleWriter.Write(ConsoleColor.Red, ex.ToString()); var message = new SystemRecycled { success = false, fixtures = new FixtureModel[0], system_name = system.ToString(), system_full_name = system.GetType().FullName, #if NET46 name = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory), #else name = Path.GetFileName(AppContext.BaseDirectory), #endif error = ex.ToString() }; return(message); } var library = FixtureLibrary.CreateForAppDomain(cellHandling); onStarted(library); return(new SystemRecycled { success = true, fixtures = library.Models.GetAll().ToArray(), system_name = system.ToString(), #if NET46 name = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory) #else name = Path.GetFileName(AppContext.BaseDirectory) #endif });
public Task <SystemRecycled> Start(EngineMode mode) { _mode = mode; var listener = bootstrap(mode); return(listener.Task.ContinueWith(x => { _watcher = new AppDomainFileChangeWatcher(Recycle); _watcher.WatchBinariesAt(_path.AppendPath("bin")); LatestSystemRecycled = x.Result; return x.Result; })); }
private bool executeAgainstTheSystem(RunInput input, SystemRecycled systemRecycled, EngineController controller) { if (!systemRecycled.success) { systemRecycled.WriteSystemUsage(); return(false); } writeSystemUsage(systemRecycled); if (input.ValidateFlag) { return(validateOnly(input, systemRecycled)); } var execution = input.StartBatch(controller); // TODO -- put a command level timeout on this thing execution.Wait(); var results = execution.Result; if (input.VerboseFlag) { writeVerbose(results); } var success = determineSuccess(input, results); writeResults(input, systemRecycled, results); writeData(input, results); openResults(input); writeSuccessOrFailure(success); return(success); }
private SystemRecycled tryToStart() { CellHandling cellHandling = null; try { cellHandling = _system.Start(); } catch (Exception ex) { ConsoleWriter.Write(ConsoleColor.Red, ex.ToString()); var message = new SystemRecycled { success = false, fixtures = new FixtureModel[0], system_name = _system.ToString(), system_full_name = _system.GetType().FullName, name = Path.GetFileName(AppContext.BaseDirectory), error = ex.ToString() }; return(message); } var library = FixtureLibrary.CreateForAppDomain(cellHandling); startTheConsumingQueues(library); return(new SystemRecycled { success = true, fixtures = library.Models.GetAll().ToArray(), system_name = _system.ToString(), name = Path.GetFileName(AppContext.BaseDirectory) }); }
public void Start(Project project) { if (_running != null) { Console.WriteLine($"AGENT: Trying to start specification runner for {_running.GetType().Name} at {project.ProjectPath} and port {project.Port}"); } Project.CurrentProject = project; _project = project; try { _engine = buildUserInterfaceEngine(); _engine.Start(project.StopConditions); ConsoleWriter.Write("AGENT: Specification running engine ready at " + project.ProjectPath); } catch (Exception e) { StorytellerAgent.LogFailure(e); ConsoleWriter.Write(ConsoleColor.Red, e.ToString()); var message = new SystemRecycled { error = e.ToString(), success = false, }; EventAggregator.SendMessage(message); } }
public void Receive(SystemRecycled message) { message.WriteSystemUsage(); SendMessageToClient(message); }
public InitialModel(SystemRecycled recycled, HierarchyLoaded hierarchy) : base("initial-model") { Recycled = recycled; Hierarchy = hierarchy; }
public void RecordSystemFixtures(SystemRecycled recycled) { _systemFixtures = FixtureLibrary.From(recycled.fixtures); }