Skip to content

Commit

Permalink
[FIXED JENKINS-19884] Visualize more information in test failure summary
Browse files Browse the repository at this point in the history
Now lists error details, stack trace, stderr and stdout provided its content is
not empty.
  • Loading branch information
olivergondza committed Oct 4, 2013
1 parent 968acad commit 0460a04
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 25 deletions.
47 changes: 33 additions & 14 deletions core/src/main/resources/hudson/tasks/junit/CaseResult/summary.jelly
Expand Up @@ -24,19 +24,38 @@ THE SOFTWARE.

<!-- this is loaded on demand in the failed test results summary -->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:local="local">
<d:taglib uri="local">
<d:tag name="item">
<j:if test="${value!=null and !empty value}">
<j:set var="id" value="${attrs.id}-${attrs.name}"/>
<j:set var="display" value="${attrs.opened ? '' : 'none'}"/>
<j:set var="idisplay" value="${attrs.opened ? 'none' : ''}"/>
<j:set var="open" value="javascript:showFailureSummary('${id}')"/>
<j:set var="close" value="javascript:hideFailureSummary('${id}')"/>
<h4>
<a id="${id}-showlink" href="${open}" title="Show ${title}" style="display: ${idisplay}">
<img src="${imagesURL}/16x16/document_add.png"/><st:nbsp/>${title}
</a>
<a id="${id}-hidelink" href="${close}" title="Hide ${title}" style="display: ${display}">
<img src="${imagesURL}/16x16/document_delete.png"/><st:nbsp/>${title}
</a>
</h4>
<pre id="${id}" style="display: ${display}">
<st:out value="${value}"/>
</pre>
</j:if>
</d:tag>
</d:taglib>
<st:contentType value="text/plain;charset=UTF-8"/>
<j:choose>
<j:when test="${it.errorDetails!=null}">
<h3>${%Error Details}</h3>
<pre><st:out value="${it.errorDetails}"/></pre>
</j:when>
<j:otherwise>
<j:if test="${it.errorStackTrace!=null}">
<h3>${%Stack Trace}</h3>
<pre><j:out value="${it.annotate(it.errorStackTrace)}"/></pre>
</j:if>
</j:otherwise>
</j:choose>

<j:new var="h" className="hudson.Functions" />
${h.initPageVariables(context)}

<j:set var="id" value="${h.generateId()}"/>

<local:item id="${id}" name="error" title="${%Error Details}" value="${it.errorDetails}" opened="true"/>
<local:item id="${id}" name="stacktrace" title="${%Stack Trace}" value="${it.errorStackTrace}"/>
<local:item id="${id}" name="stdout" title="${%Standard Output}" value="${it.stdout}"/>
<local:item id="${id}" name="stderr" title="${%Standard Error}" value="${it.stderr}"/>
</j:jelly>
53 changes: 42 additions & 11 deletions core/src/main/resources/lib/hudson/failed-test.jelly
Expand Up @@ -37,34 +37,65 @@ THE SOFTWARE.
<st:once>
<script type="text/javascript">
<!-- TODO make sure load doesn't happen every time -->
function showStackTrace(id,query) {
function showFailureSummary(id,query) {
var element = document.getElementById(id)
element.style.display = "";
document.getElementById(id + "-showlink").style.display = "none";
document.getElementById(id + "-hidelink").style.display = "";

var rqo = new XMLHttpRequest();
rqo.open('GET', query, true);
rqo.onreadystatechange = function() { element.innerHTML = rqo.responseText; }
rqo.send(null);
if (typeof query !== 'undefined') {
var rqo = new XMLHttpRequest();
rqo.open('GET', query, true);
rqo.onreadystatechange = function() { element.innerHTML = rqo.responseText; }
rqo.send(null);
}
}

function hideStackTrace(id) {
function hideFailureSummary(id) {
document.getElementById(id).style.display = "none";
document.getElementById(id + "-showlink").style.display = "";
document.getElementById(id + "-hidelink").style.display = "none";
}
</script>
<style type="text/css">
.failure-summary {
margin-left: 2em;
}

.failure-summary h4 {
margin: 0.5em 0 0.5em 0;
}

.failure-summary h4 a {
text-decoration: none;
color: inherit;
}

.failure-summary h4 a img {
width: 8px;
height: 8px;
}

.failure-summary pre {
margin-left: 2em;
}
</style>
</st:once>
<j:set var="id" value="${h.jsStringEscape(url)}"/>
<j:set var="open" value="javascript:showStackTrace('test-${id}','${url}/summary')"/>
<j:set var="close" value="javascript:hideStackTrace('test-${id}')"/>
<a id="test-${id}-showlink" href="${open}" title="${%Show details}"><img src="${imagesURL}/16x16/document_add.png"/></a>
<a id="test-${id}-hidelink" href="${close}" title="${%Hide details}" style="display:none"><img src="${imagesURL}/16x16/document_delete.png"/></a>
<j:set var="open" value="javascript:showFailureSummary('test-${id}','${url}/summary')"/>
<j:set var="close" value="javascript:hideFailureSummary('test-${id}')"/>
<a id="test-${id}-showlink" href="${open}" title="${%Show details}">
<img src="${imagesURL}/16x16/document_add.png"/>
</a>
<a id="test-${id}-hidelink" href="${close}" title="${%Hide details}" style="display:none">
<img src="${imagesURL}/16x16/document_delete.png"/>
</a>
<st:nbsp/>
<a href="${url}" class="model-link inside"><st:out value="${result.fullDisplayName}"/></a>
<j:forEach var="badge" items="${result.testActions}">
<st:include it="${badge}" page="badge.jelly" optional="true"/>
</j:forEach>
<div id="test-${id}" class="hidden" style="display:none">${%Loading...}</div>
<div id="test-${id}" class="failure-summary" style="display: none;">
${%Loading...}
</div>
</j:jelly>

0 comments on commit 0460a04

Please sign in to comment.