Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions tests/xharness/Jenkins/Reports/HtmlReportWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,13 @@ public void Write (IList<ITestTask> allTasks, StreamWriter writer)
}

if (logs.Count () > 0) {
foreach (var log in logs) {
if (!(log is IFileBackedLog fileLog)) {
continue;
}

var query = logs.
OfType<IFileBackedLog> ().
OrderBy (v => v.Description).
ThenBy (v => v.FullPath);
var hasListedErrors = false;
foreach (var fileLog in query) {
var log = fileLog;
log.Flush ();
var exists = File.Exists (fileLog.FullPath);
string log_type = GetMimeMapping (fileLog.FullPath);
Expand Down Expand Up @@ -495,11 +497,12 @@ public void Write (IList<ITestTask> allTasks, StreamWriter writer)
fails = data_tuple.Item2;
}
}
if (fails.Count > 0) {
if (!hasListedErrors && fails.Count > 0) {
writer.WriteLine ("<div style='padding-left: 15px;'>");
foreach (var fail in fails)
writer.WriteLine ("{0} <br />", fail.AsHtml ());
writer.WriteLine ("</div>");
hasListedErrors = true;
}
if (!string.IsNullOrEmpty (summary))
writer.WriteLine ("<span style='padding-left: 15px;'>{0}</span><br />", summary);
Expand Down Expand Up @@ -532,29 +535,32 @@ public void Write (IList<ITestTask> allTasks, StreamWriter writer)
errors = (HashSet<string>) data.Item2;
}
}
if (errors.Count > 0) {
if (!hasListedErrors && errors.Count > 0) {
writer.WriteLine ("<div style='padding-left: 15px;'>");
foreach (var error in errors)
writer.WriteLine ("{0} <br />", error.AsHtml ());
writer.WriteLine ("</div>");
hasListedErrors = true;
}
} catch (Exception ex) {
writer.WriteLine ("<span style='padding-left: 15px;'>Could not parse log file: {0}: {1}</span><br />", ex.Message?.AsHtml (), ex.StackTrace?.AsHtml ());
}
} else if (log.Description == LogType.NUnitResult.ToString () || log.Description == LogType.XmlLog.ToString ()) {
try {
if (File.Exists (fileLog.FullPath) && new FileInfo (fileLog.FullPath).Length > 0) {
if (!hasListedErrors && File.Exists (fileLog.FullPath) && new FileInfo (fileLog.FullPath).Length > 0) {
if (resultParser.IsValidXml (fileLog.FullPath, out var jargon)) {
resultParser.GenerateTestReport (writer, fileLog.FullPath, jargon);
hasListedErrors = true;
}
}
} catch (Exception ex) {
writer.WriteLine ($"<span style='padding-left: 15px;'>Could not parse {log.Description}: {ex.Message?.AsHtml ()} : {ex.StackTrace?.AsHtml ()}</span><br />");
}
} else if (log.Description == LogType.TrxLog.ToString ()) {
try {
if (resultParser.IsValidXml (fileLog.FullPath, out var jargon)) {
if (!hasListedErrors && resultParser.IsValidXml (fileLog.FullPath, out var jargon)) {
resultParser.GenerateTestReport (writer, fileLog.FullPath, jargon);
hasListedErrors = true;
}
} catch (Exception ex) {
writer.WriteLine ($"<span style='padding-left: 15px;'>Could not parse {log.Description}: {ex.Message?.AsHtml ()}</span><br />");
Expand Down
Loading