public static void WriteCSV(BatchRunResponse results, string file) { using (var stream = new FileStream(file, FileMode.Create)) { using (var writer = new StreamWriter(stream)) { results.records.Each(record => { var suite = record.specification.SuitePath(); var name = record.specification.name.Replace(',', ' '); var id = record.specification.id; record.results.Performance.Each(x => { writer.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7}", id, suite, name, x.Type, x.Subject, x.Duration, x.Start, x.End ); }); }); } } }
private static void dumpJson(RunInput input, BatchRunResponse results) { Console.WriteLine("Dumping the raw JSON results to " + input.DumpFlag); var json = JsonSerialization.ToJson(results); new FileSystem().WriteStringToFile(input.DumpFlag, json); }
private void writeResponse(BatchRunResponse response) { var json = JsonSerialization.ToIndentedJson(response); var path = TestingContext.FindClientFolder().AppendPath("batch-run-response-data.js"); new FileSystem().WriteStringToFile(path, "module.exports = " + json); }
private static void writeJavascript(BatchRunResponse results, HtmlDocument document) { var cleanJson = JsonSerialization.ToCleanJson(results); document.Body.Add("div").Hide().Id("batch-data").Text(cleanJson); document.Body.Add("div").Id("main"); var js = readFile("StoryTeller.batch-bundle.js"); document.Body.Add("script").Attr("language", "javascript").Text("\n\n" + js + "\n\n").Encoded(false); }
private void writeResponse(BatchRunResponse response) { var json = JsonSerialization.ToIndentedJson(response); var path = AppDomain.CurrentDomain.BaseDirectory .ParentDirectory().ParentDirectory() // project dir .ParentDirectory().ParentDirectory() // root .AppendPath("client", "batch-run-response-data.js"); new FileSystem().WriteStringToFile(path, "module.exports = " + json); }
public BatchRunResponse FullResults() { var response = new BatchRunResponse { fixtures = _library.Models.ToArray(), suite = "Interactive Execution", system = typeof(T).FullName, records = _records.ToArray() }; return(response); }
public static HtmlDocument BuildResults(BatchRunResponse results) { var document = new HtmlDocument { Title = "Storyteller Batch Results for {0}: {1}".ToFormat(results.system, results.suite) }; WriteCSS(document); writeJavascript(results, document); return(document); }
public BatchRunResponse FullResults() { var response = new BatchRunResponse { fixtures = _running.Fixtures.Models.ToArray(), suite = "Interactive Execution", system = _running.System.GetType().FullName, records = _records.ToArray() }; return(response); }
private void writeVerbose(BatchRunResponse results) { foreach (var record in results.records) { if (record.WasSuccessful()) { ConsoleWriter.Write(ConsoleColor.Green, $"{record.specification.path} succeeded with {record.results.Counts} "); } else { ConsoleWriter.Write(ConsoleColor.Red, $"{record.specification.path} failed with {record.results.Counts}"); } } }
private static bool determineSuccess(RunInput input, BatchRunResponse results) { var regression = results.Summarize(Lifecycle.Regression); var acceptance = results.Summarize(Lifecycle.Acceptance); if (input.LifecycleFlag != Lifecycle.Regression) { Console.WriteLine(acceptance); } if (input.LifecycleFlag != Lifecycle.Acceptance) { Console.WriteLine(regression); } return(regression.Failed == 0); }
private static void writeData(RunInput input, BatchRunResponse results) { if (input.DumpFlag.IsNotEmpty()) { dumpJson(input, results); } if (input.CsvFlag.IsNotEmpty()) { writePerformanceData(input, results); } if (input.JsonFlag.IsNotEmpty()) { Console.WriteLine("Writing the raw result information to " + input.JsonFlag); PerformanceDataWriter.WriteJSON(results, input.JsonFlag); } }
private static void writeJavascript(BatchRunResponse results, HtmlDocument document) { var cleanJson = JsonSerialization.ToCleanJson(results); document.Body.Add("div").Hide().Id("batch-data").Text(cleanJson); document.Body.Add("div").Id("main"); var js = readFile("StoryTeller.batch-bundle.js"); var foot = new HtmlTag("foot"); document.Body.Next = foot; foot.Add("script").Attr("language", "javascript").Text("\n\n" + js + "\n\n").Encoded(false); /* foot.Add("script") .Attr("language", "Javascript") .Attr("src", "file://Z:/code/storyteller/src/ST/batch-bundle.js"); */ }
private static void writePerformanceData(RunInput input, BatchRunResponse results) { Console.WriteLine("Writing performance data as CSV data to " + input.CsvFlag.ToFullPath()); PerformanceDataWriter.WriteCSV(results, input.CsvFlag); }
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); }
public static void WriteJSON(BatchRunResponse results, string file) { new FileSystem().WriteStringToFile(file, JsonSerialization.ToIndentedJson(results.records)); }
private async Task <bool> execute(RunInput input) { var specFetching = input.ReadSpecs(); var running = RunningSystem.Create(input.System); using (running.System) { if (!running.RecycledMessage.success) { throw new Exception("System startup failed."); } await running.System.Warmup(); var specs = await specFetching; var runner = buildRunner(input, specs, running, out var executionObserver); buildExecutionQueue(runner, executionObserver); var requests = createExecutionPlans(specs, running); var finished = Task.WhenAll(requests.Select(x => x.Completion)); var timeout = Task.Delay(input.GlobalTimeoutFlag.Minutes()); await Task.WhenAny(timeout, finished); if (timeout.IsCompleted) { showTimeoutMessage(input, requests); } var records = requests.Select(x => new BatchRecord { results = x.Completion.Result, specification = x.Specification }).ToArray(); var results = new BatchRunResponse { fixtures = running.Fixtures.Models.ToArray(), suite = "Interactive Execution", system = running.System.GetType().FullName, records = records }; var success = determineSuccess(input, results); writeResults(input, running.RecycledMessage, results); writeData(input, results); if (input.OpenFlag) { ProcessLauncher.OpenFile(input.ResultsPathFlag); } writeSuccessOrFailure(success); return(success); } }