Skip to content

Commit

Permalink
Do not calculate running time if the test failed with fatal error, al…
Browse files Browse the repository at this point in the history
…so make the fatal status of the test more visible (fixes lmc-eu#6)
  • Loading branch information
OndraM committed May 28, 2015
1 parent fafab93 commit 83fffe4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Fixed
- Properly trigger PHPUnit colored (ANSI) mode when Steward itself is in ANSI mode.
- Stop counting test's running time (shown in `results.xml`), if the test ended with fatal error (#6).

## 1.0.0 - 2015-05-09
### Added
Expand Down
67 changes: 42 additions & 25 deletions src/results.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -159,34 +159,49 @@
<xsl:value-of select="@name"/>
</td>
<td>
<xsl:value-of select="@status"/>
<!-- If the parent testcase ended with "fatal" and this one is still in "started" status, that
this must be the one that "fatal"-ed, so we won't print its confusing "started" status -->
<xsl:if test="not(@status = 'started' and ../@result = 'fatal')">
<xsl:value-of select="@status"/>
</xsl:if>
</td>
<td>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="@result = 'passed'">success</xsl:when>
<xsl:when test="@result = 'failed' or @result = 'broken'">danger</xsl:when>
<xsl:when test="@result = 'skipped' or @result = 'incomplete'">info</xsl:when>
</xsl:choose>
</xsl:attribute>
<span>
<xsl:attribute name="class">
glyphicon
<xsl:choose>
<xsl:when test="@result = 'passed'">glyphicon-ok</xsl:when>
<xsl:when test="@result = 'failed' or @result = 'broken'">glyphicon-remove</xsl:when>
<xsl:when test="@result = 'skipped' or @result = 'incomplete'">glyphicon-question-sign</xsl:when>
</xsl:choose>
</xsl:attribute>
</span>
<xsl:text>&#160;&#160;</xsl:text>
<xsl:value-of select="@result"/>
<xsl:choose>
<xsl:when test="@status = 'started' and ../@result = 'fatal'">
<xsl:attribute name="class">warning</xsl:attribute>
<span class="glyphicon glyphicon-warning-sign"></span>&#160;&#160;fatal
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="@result = 'passed'">success</xsl:when>
<xsl:when test="@result = 'failed' or @result = 'broken'">danger</xsl:when>
<xsl:when test="@result = 'skipped' or @result = 'incomplete'">info</xsl:when>
</xsl:choose>
</xsl:attribute>
<span>
<xsl:attribute name="class">
glyphicon
<xsl:choose>
<xsl:when test="@result = 'passed'">glyphicon-ok</xsl:when>
<xsl:when test="@result = 'failed' or @result = 'broken'">glyphicon-remove</xsl:when>
<xsl:when test="@result = 'skipped' or @result = 'incomplete'">glyphicon-question-sign</xsl:when>
</xsl:choose>
</xsl:attribute>
</span>
<xsl:text>&#160;&#160;</xsl:text>
<xsl:value-of select="@result"/>
</xsl:otherwise>
</xsl:choose>
</td>
<td class="date date-start">
<xsl:value-of select="@start"/>
</td>
<td class="date date-end">
<xsl:value-of select="@end"/>
<xsl:choose>
<xsl:when test="@status = 'started' and ../@result = 'fatal'">-</xsl:when>
<xsl:otherwise><xsl:value-of select="@end"/></xsl:otherwise>
</xsl:choose>
</td>
<td class="duration">
</td>
Expand All @@ -202,12 +217,13 @@
<script>
<![CDATA[
$(function () {
// caluclate and print test duration
// calculate and print test duration
$('table tr.test-row').each(function() {
var startDate = moment($('td.date-start', this).text());
var endDate = moment($('td.date-end', this).text());
var endValue = $('td.date-end', this).text();
var endDate = moment(endValue);
var isPending = false;
if (startDate.isValid()) {
if (startDate.isValid() && endValue != '-') { // do not calculate when test fatal-ed
if (!endDate.isValid()) { // still running, add current time
isPending = true;
endDate = moment();
Expand All @@ -220,9 +236,10 @@
);
}
});
// convert ISO-8601 dates to more readable ones
$("td.date").each(function () {
if ($(this).text().length) {
if ($(this).text().length && $(this).text() != '-') {
$(this).text(moment($(this).text()).format('YYYY-MM-DD H:mm:ss'));
}
});
Expand Down

0 comments on commit 83fffe4

Please sign in to comment.