/// <summary> /// Adds the XML representation of the result as a child of the /// supplied parent node.. /// </summary> /// <param name="parentNode">The parent node.</param> /// <param name="recursive">If true, descendant results are included</param> /// <returns></returns> public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive) { // A result node looks like a test node with extra info added XmlNode thisNode = this.Test.AddToXml(parentNode, false); thisNode.AddAttribute("result", ResultState.Status.ToString()); if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString()) { thisNode.AddAttribute("label", ResultState.Label); } thisNode.AddAttribute("start-time", StartTime.ToString("u")); thisNode.AddAttribute("end-time", EndTime.ToString("u")); thisNode.AddAttribute("duration", Duration.TotalSeconds.ToString("0.000000", NumberFormatInfo.InvariantInfo)); if (this.Test is TestSuite) { thisNode.AddAttribute("total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString()); thisNode.AddAttribute("passed", PassCount.ToString()); thisNode.AddAttribute("failed", FailCount.ToString()); thisNode.AddAttribute("inconclusive", InconclusiveCount.ToString()); thisNode.AddAttribute("skipped", SkipCount.ToString()); } thisNode.AddAttribute("asserts", this.AssertCount.ToString()); switch (ResultState.Status) { case TestStatus.Failed: AddFailureElement(thisNode); break; case TestStatus.Skipped: AddReasonElement(thisNode); break; case TestStatus.Passed: case TestStatus.Inconclusive: if (this.Message != null) { AddReasonElement(thisNode); } break; } if (recursive && HasChildren) { foreach (TestResult child in Children) { child.AddToXml(thisNode, recursive); } } return(thisNode); }
public async Task RunTestsAsync(IEnumerable <Test> testList = null, IProgress <TestRunProgress> progress = null, CancellationToken cancellationToken = default(CancellationToken)) { if (testList == null) { testList = this.Tests; } else { testList = testList.ToList(); // snapshot the enumerable. } this.PassCount = 0; this.FailCount = 0; this.log.Length = 0; if (!this.IsUIThreadRequired) { await TaskScheduler.Default; } progress.ReportIfNotNull(new TestRunProgress(this.TestCount)); foreach (var test in testList) { cancellationToken.ThrowIfCancellationRequested(); // Give the app some breathing room to process a cancel button, // since otherwise running tests is only as async as the tests themselves. await TaskEx.Yield(); await test.RunAsync(); if (test.Result == TestState.Passed) { this.PassCount++; } else if (test.Result == TestState.Failed) { this.FailCount++; this.LogLine("Failed: " + test.FullName); this.LogLine(test.FailureException.ToString()); this.LogLine(""); } else { throw new InvalidOperationException("Unexpected test state: " + test.Result); } progress.ReportIfNotNull(new TestRunProgress(this.PassCount, this.FailCount, this.TestCount)); } this.LogLine(""); this.LogLine(PassCount.ToString() + " passed, " + FailCount + " failed, " + TestCount + " total"); }
/// <summary> /// Adds the XML representation of the result as a child of the /// supplied parent node.. /// </summary> /// <param name="parentNode">The parent node.</param> /// <param name="recursive">If true, descendant results are included</param> /// <returns></returns> public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive) { // A result node looks like a test node with extra info added XmlNode thisNode = this.test.AddToXml(parentNode, false); XmlHelper.AddAttribute(thisNode, "result", ResultState.Status.ToString()); if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString()) { XmlHelper.AddAttribute(thisNode, "label", ResultState.Label); } XmlHelper.AddAttribute(thisNode, "time", this.Time.ToString("0.000", System.Globalization.CultureInfo.InvariantCulture)); if (this.test is TestSuite) { XmlHelper.AddAttribute(thisNode, "total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString()); XmlHelper.AddAttribute(thisNode, "passed", PassCount.ToString()); XmlHelper.AddAttribute(thisNode, "failed", FailCount.ToString()); XmlHelper.AddAttribute(thisNode, "inconclusive", InconclusiveCount.ToString()); XmlHelper.AddAttribute(thisNode, "skipped", SkipCount.ToString()); } XmlHelper.AddAttribute(thisNode, "asserts", this.AssertCount.ToString()); switch (ResultState.Status) { case TestStatus.Failed: AddFailureElement(thisNode); break; case TestStatus.Skipped: AddReasonElement(thisNode); break; case TestStatus.Passed: break; case TestStatus.Inconclusive: break; } if (recursive && HasChildren) { foreach (TestResult child in Children) { child.AddToXml(thisNode, recursive); } } return(thisNode); }
public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive) { XmlNode xmlNode = test.AddToXml(parentNode, recursive: false); XmlHelper.AddAttribute(xmlNode, "result", ResultState.Status.ToString()); if (ResultState.Label != string.Empty) { XmlHelper.AddAttribute(xmlNode, "label", ResultState.Label); } XmlHelper.AddAttribute(xmlNode, "time", Time.ToString("0.000", CultureInfo.InvariantCulture)); if (test is TestSuite) { XmlHelper.AddAttribute(xmlNode, "total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString()); XmlHelper.AddAttribute(xmlNode, "passed", PassCount.ToString()); XmlHelper.AddAttribute(xmlNode, "failed", FailCount.ToString()); XmlHelper.AddAttribute(xmlNode, "inconclusive", InconclusiveCount.ToString()); XmlHelper.AddAttribute(xmlNode, "skipped", SkipCount.ToString()); } XmlHelper.AddAttribute(xmlNode, "asserts", AssertCount.ToString()); switch (ResultState.Status) { case TestStatus.Failed: AddFailureElement(xmlNode); break; case TestStatus.Skipped: AddReasonElement(xmlNode); break; } if (recursive && HasChildren) { foreach (TestResult child in Children) { child.AddToXml(xmlNode, recursive); } } return(xmlNode); }
public virtual TNode AddToXml(TNode parentNode, bool recursive) { // A result node looks like a test node with extra info added TNode thisNode = Test.AddToXml(parentNode, false); thisNode.AddAttribute("result", ResultState.Status.ToString()); if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString()) { thisNode.AddAttribute("label", ResultState.Label); } if (ResultState.Site != FailureSite.Test) { thisNode.AddAttribute("site", ResultState.Site.ToString()); } thisNode.AddAttribute("start-time", StartTime.ToString("o")); thisNode.AddAttribute("end-time", EndTime.ToString("o")); thisNode.AddAttribute("duration", Duration.ToString("0.000000", NumberFormatInfo.InvariantInfo)); if (Test is TestSuite) { thisNode.AddAttribute("total", TotalCount.ToString()); thisNode.AddAttribute("passed", PassCount.ToString()); thisNode.AddAttribute("failed", FailCount.ToString()); thisNode.AddAttribute("warnings", WarningCount.ToString()); thisNode.AddAttribute("inconclusive", InconclusiveCount.ToString()); thisNode.AddAttribute("skipped", SkipCount.ToString()); } thisNode.AddAttribute("asserts", AssertCount.ToString()); switch (ResultState.Status) { case TestStatus.Failed: AddFailureElement(thisNode); break; case TestStatus.Skipped: case TestStatus.Passed: case TestStatus.Inconclusive: case TestStatus.Warning: if (Message != null && Message.Trim().Length > 0) { TNode reasonNode = thisNode.AddElement("reason"); reasonNode.AddElementWithCDATA("message", Message); } break; } if (Output.Length > 0) { AddOutputElement(thisNode); } if (AssertionResults.Count > 0) { AddAssertionsElement(thisNode); } if (_testAttachments.Count > 0) { AddAttachmentsElement(thisNode); } if (recursive && HasChildren) { foreach (var child in Children) { child.AddToXml(thisNode, recursive); } } return(thisNode); }
public void Clean() { TestCount = 0; PassCount = 0; FailCount = 0; Yield = 0; TestCount_Nomal = 0; PassCount_Nomal = 0; FailCount_Nomal = 0; Yield_Nomal = 0; Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "PassCount_Nomal", PassCount_Nomal.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "FailCount_Nomal", FailCount_Nomal.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestCount_Nomal", TestCount_Nomal.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "Yield_Nomal", Yield_Nomal.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "PassCount", PassCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "FailCount", FailCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestCount", TestCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "Yield", Yield.ToString()); }
public void Update(TestResult tr) { TestCount++; if (tr == TestResult.Pass) { PassCount++; } else { FailCount++; } if (PassCount + FailCount != 0) { Yield = Math.Round((double)PassCount / (PassCount + FailCount) * 100, 2); } else { Yield = 0; } Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "PassCount", PassCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "FailCount", FailCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestCount", TestCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "Yield", Yield.ToString()); }
public override string ToString() { return(Name + " (" + PassCount.ToString() + " pass" + (PassCount != 1 ? "es" : "") + ")"); }
static Module DoCompile(string fileContents, OptimizeLevel opLevel = OptimizeLevel.OptimizeNone, PassCount passCount = PassCount.PassAlls) { var tokenizerTokens = Tokenizer.Tokenize(fileContents); var preprocessorParser = new PreprocessorParser(tokenizerTokens); var preProcessorTokens = preprocessorParser.Parse(); var tokenPassTokens = RunTokenPasses(preProcessorTokens); var tokens = tokenPassTokens.GetEnumerator(); tokens.MoveNext(); var currentModule = Module.ParseModule(ref tokens); if (optimizeLevel != OptimizeLevel.OptimizeNone) { Optimizer.Loop.Optimizer.RunOptimizer(ref currentModule, optimizeLevel); } WriteModule(currentModule, 1); // Statement passes if (passCount >= PassCount.Pass2) { StatementPasses.BlockCollapse.Run(currentModule); StatementPasses.IfGotoConversion.Run(currentModule); StatementPasses.LoopGotoConversion.Run(currentModule); StatementPasses.ReorderDeclarations.Run(currentModule); StatementPasses.MarkRecursiveFunctions.Run(currentModule); } WriteModule(currentModule, 2); //if (optimizeLevel != OptimizeLevel.OptimizeNone) // Optimizer.Optimizer.RunOptimizer(ref currentModule, optimizeLevel); WriteModule(currentModule, 3); if (passCount >= PassCount.Pass3) { //StatementPasses.ReplaceLocalsWithGlobals.Run(currentModule); StatementPasses.ApplyCallingConvention.Run(currentModule); StatementPasses.LabelMerger.Run(currentModule); StatementPasses.RemovePointlessGotos.Run(currentModule); // Adjust the arithmetic StatementPasses.ConvertAddSubToIncDec.Run(currentModule); StatementPasses.RemoveMathImmediates.Run(currentModule); StatementPasses.RegisterAllocator.DumbRegisterAllocator.Run(currentModule); } currentModule.IntermediateStrings.Add("#include <string.h>"); string code = currentModule.ToString(); var asmCode = AssemblyGenerator.GenerateCode(ref currentModule); return(currentModule); }
/// <summary> /// Parses a file and outputs a .asm file /// </summary> /// <returns></returns> public static bool DoCompileFile(string inputFile, OptimizeLevel opLevel = OptimizeLevel.OptimizeNone, PassCount passCount = PassCount.PassAlls) { optimizeLevel = opLevel; string fileContents = TryOpenFile(inputFile); if (string.IsNullOrEmpty(fileContents)) { return(false); } var module = DoCompile(fileContents); var asmWriter = new StreamWriter(Path.GetFileNameWithoutExtension(inputFile) + "_compiled.z80"); asmWriter.Write(AssemblyGenerator.GenerateCode(ref module)); asmWriter.Close(); string outputFile = inputFile.Replace("expected", "actual"); if (outputFile.Equals(inputFile)) { outputFile = Path.GetFileNameWithoutExtension(inputFile) + "_compiled.c"; } var writer = new StreamWriter(outputFile); writer.Write(module.ToString().Replace("\r\n", "\n").Replace("\n", "\r\n")); writer.Close(); return(true); }
public void UpdateTester1(int rst) { /*result = 0 -> Ng * result = 1 -> Pass * result = 2 -> Timeout */ switch (rst) { case 0: if (!IsInSampleMode) { FailCount++; } break; case 1: if (!IsInSampleMode) { PassCount++; } break; default: break; } if (!IsInSampleMode) { TestCount++; } Yield = Math.Round((double)PassCount / (PassCount + FailCount) * 100, 2); try { //Inifile.INIWriteValue(iniTesterResutPath, "Tester" + Index.ToString(), "TestSpan", TestSpan.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + Index.ToString(), "PassCount", PassCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + Index.ToString(), "FailCount", FailCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + Index.ToString(), "TestCount", TestCount.ToString()); Inifile.INIWriteValue(iniTesterResutPath, "Tester" + Index.ToString(), "Yield", Yield.ToString()); } catch { } }