/// <summary> /// name is a unique identifier (example name) for each example, currently module name /// </summary> /// <param name="name"></param> /// <param name="currDir"></param> /// <param name="srcPath"></param> /// <param name="baseDir"></param> /// <param name="hrg"></param> private static void ProcessSingleModule(string name, string currDir, string srcPath, string baseDir, HtmlReportGeneration hrg) { var ari1 = new AvnResultInfo(currDir, srcPath, name); ari1.LoadResultInfo(); try { AvnResultInfo ari2 = null; BaselineInfo bi = null; if (baseDir != null) { ari2 = new AvnResultInfo(baseDir, srcPath, name); ari2.LoadResultInfo(); bi = new BaselineInfo(ari1, ari2); bi.MatchResults(); } hrg.WriteHtml(ari1, ari2, bi); } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Skipping {0} due to exception {1}", currDir, e.Message)); } }
/// <summary> /// Important: Do not pass a subset of traces to this function, as the annotation mapping will get confused /// dontUpdateAnnots when true indicates that the traces are for baseline, so we don't need to persist it /// </summary> /// <param name="ari"></param> /// <param name="traces"></param> /// <param name="filter"></param> /// <param name="htmlWriter"></param> /// <returns></returns> private int WriteTracesInHtml(AvnResultInfo ari, List <DefectTrace> traces, IEnumerable <DefectTrace> filter, HtmlTextWriter htmlWriter, bool dontUpdateAnnots = false) { int count = -1; if (!dontUpdateAnnots) { htmlWriter.AddAttribute(HtmlTextWriterAttribute.Id, "tracesPerExample_" + ari.Name); } htmlWriter.RenderBeginTag(HtmlTextWriterTag.Div); foreach (var tr in traces) { count++; //need to count before any continue, as we need to map count uniquely to a trace if (!filter.Contains(tr)) { continue; } htmlWriter.RenderBeginTag(HtmlTextWriterTag.P); //Form if (!dontUpdateAnnots) { htmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "traceAnnots"); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Id, "traceId" + count); } htmlWriter.RenderBeginTag(HtmlTextWriterTag.Form); var trace = tr.Id; //Raw defect trace htmlWriter.AddAttribute(HtmlTextWriterAttribute.Href, trace.Replace("\\\\", "\\")); htmlWriter.RenderBeginTag(HtmlTextWriterTag.A); //a htmlWriter.Write("Trace" + count); htmlWriter.RenderEndTag(); //a //button htmlWriter.AddAttribute(HtmlTextWriterAttribute.Type, "button"); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Onclick, "launchSdvDefectViewer(" + "\"" + @Options.defectViewerDir + "\"" + "," + "\"" + @ari.SrcDir + "\"" + "," + "\"" + @trace.Replace("\\", "\\\\") + "\"" + ")"); htmlWriter.RenderBeginTag(HtmlTextWriterTag.Button); htmlWriter.Write("View"); htmlWriter.RenderEndTag(); //button if (baseline) { htmlWriter.WriteBreak(); } var traceFound = ari.TraceAnnot.ContainsKey(count); var addInputBoxWithVal = new Action <string, string, string, int>((str, c, t, size) => { htmlWriter.Write(c); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Name, c); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Value, str); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Type, t); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Size, size.ToString()); htmlWriter.RenderBeginTag(HtmlTextWriterTag.Input); htmlWriter.RenderEndTag(); //input if (t == "url" && str != "") { htmlWriter.AddAttribute(HtmlTextWriterAttribute.Href, str.TrimStart()); htmlWriter.RenderBeginTag(HtmlTextWriterTag.A); htmlWriter.Write("link"); htmlWriter.RenderEndTag(); //A } if (baseline) { htmlWriter.WriteBreak(); } }); addInputBoxWithVal(traceFound ? ari.TraceAnnot[count].Item1 : "", "Category", "text", 20); addInputBoxWithVal(traceFound ? ari.TraceAnnot[count].Item2 : "", "Prefix", "url", 20); addInputBoxWithVal(traceFound ? ari.TraceAnnot[count].Item3 : "", "Comment", "text", 50); htmlWriter.RenderEndTag(); //Form htmlWriter.RenderEndTag(); //P } htmlWriter.RenderEndTag(); //div return(count); }
/// <summary> /// bi = null means that we are only given one version /// </summary> /// <param name="ar1"></param> /// <param name="ar2"></param> /// <param name="bi"></param> public void WriteHtml(AvnResultInfo ar1, AvnResultInfo ar2, BaselineInfo bi) { var name = ar1.Name; ////row1 htmlWriter.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); htmlWriter.RenderBeginTag(HtmlTextWriterTag.Tr); htmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); //need more info in this column //htmlWriter.Write(ar1.ResultsDir.Replace("\\\\", "\\")); htmlWriter.Write(ar1.Name); htmlWriter.WriteBreak(); htmlWriter.RenderBeginTag(HtmlTextWriterTag.B); htmlWriter.Write("STATS:"); htmlWriter.RenderEndTag(); //B htmlWriter.Write(ar1.Summary); htmlWriter.WriteBreak(); //B htmlWriter.RenderBeginTag(HtmlTextWriterTag.B); htmlWriter.Write("PREfix link:"); htmlWriter.RenderEndTag(); //B if (!Options.hideAnnotTextarea) { htmlWriter.RenderBeginTag(HtmlTextWriterTag.P); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Id, "displayAllAnnotsFor_" + name); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Rows, (ar1.AngelicTraces.Count).ToString()); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Cols, "30"); htmlWriter.RenderBeginTag(HtmlTextWriterTag.Textarea); htmlWriter.Write("Display annots for " + name + " here"); htmlWriter.RenderEndTag(); //textarea htmlWriter.WriteBreak(); //button htmlWriter.AddAttribute(HtmlTextWriterAttribute.Type, "button"); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Onclick, "enumAnnots(" + "\"" + name + "\"" + ")"); htmlWriter.RenderBeginTag(HtmlTextWriterTag.Button); //var traceFile = ar1.ResultsDir.Replace("\\\\", "\\") + @"\trace_annots.xml"; var traceFile = @"trace_annots.xml"; htmlWriter.Write("Generate content of annots"); htmlWriter.WriteBreak(); htmlWriter.Write(string.Format("Copy/paste into {0}", traceFile)); htmlWriter.RenderEndTag(); //button htmlWriter.RenderEndTag(); //P } htmlWriter.RenderEndTag(); //td //MkTableHeaderColumn(htmlWriter, ar1.AllTraces.Count().ToString()); if (!baseline) { MkTableHeaderColumn(htmlWriter, "Total = " + ar1.AngelicTraces.Count().ToString()); } else { MkTableHeaderColumn(htmlWriter, "Total/Matched = " + ar1.AngelicTraces.Count().ToString() + "/" + bi.matchedTraces.Count); } htmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); var matchedTraces = //if not baseline, then all traces ar1.AngelicTraces.Where(t => !baseline || bi.matchedTraces.Any(x => x.Item1 == t)); WriteTracesInHtml(ar1, ar1.AngelicTraces, matchedTraces, htmlWriter); htmlWriter.RenderEndTag(); //td if (baseline) { htmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); var unMatchedTraces = ar1.AngelicTraces.Where(t => !bi.matchedTraces.Any(x => x.Item1 == t)); WriteTracesInHtml(ar1, ar1.AngelicTraces, unMatchedTraces, htmlWriter); htmlWriter.RenderEndTag(); //td htmlWriter.RenderBeginTag(HtmlTextWriterTag.Td); var missingTraces = ar2.AngelicTraces.Where(t => !bi.matchedTraces.Any(x => x.Item2 == t)); WriteTracesInHtml(ar2, ar2.AngelicTraces, missingTraces, htmlWriter, true); //don't update the ar1\trace_annots htmlWriter.RenderEndTag(); //td } htmlWriter.RenderEndTag(); //tr }
public HashSet <Tuple <DefectTrace, DefectTrace> > matchedTraces; //v1 \cap v2 public BaselineInfo(AvnResultInfo ar1, AvnResultInfo ar2) { this.ar1 = ar1; this.ar2 = ar2; matchedTraces = null; }