Merge lp:~cyphermox/bamf/fix-tests-gtester2xunit into lp:bamf

Proposed by Mathieu Trudel-Lapierre
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: 537
Merged at revision: 536
Proposed branch: lp:~cyphermox/bamf/fix-tests-gtester2xunit
Merge into: lp:bamf
Diff against target: 99 lines (+70/-3)
3 files modified
tests/Makefile.am.gtests (+1/-1)
tests/gtester.xsl (+69/-0)
tests/gtester2xunit.py (+0/-2)
To merge this branch: bzr merge lp:~cyphermox/bamf/fix-tests-gtester2xunit
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Didier Roche-Tolomelli Approve
Review via email: mp+167386@code.launchpad.net

Commit message

Fix test-libbamf to properly call gtester2xunit.

Description of the change

Fix test-libbamf to properly call gtester2xunit.

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

looks good and tested by Mathieu. Thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/Makefile.am.gtests'
2--- tests/Makefile.am.gtests 2013-05-31 16:45:50 +0000
3+++ tests/Makefile.am.gtests 2013-06-04 20:00:35 +0000
4@@ -37,7 +37,7 @@
5
6 test:
7 @gtester -k --verbose -o=$(TEST_BINARY)-results.xml ./$(TEST_BINARY); \
8- $(GTESTER2XUNIT_RUN) $(TEST_BINARY)-results.xml
9+ $(GTESTER2XUNIT_RUN) --xsl $(abs_top_srcdir)/tests/gtester.xsl $(TEST_BINARY)-results.xml
10
11 .PHONY: check-report full-report
12 check-report: $(TEST_BINARY)
13
14=== added file 'tests/gtester.xsl'
15--- tests/gtester.xsl 1970-01-01 00:00:00 +0000
16+++ tests/gtester.xsl 2013-06-04 20:00:35 +0000
17@@ -0,0 +1,69 @@
18+<?xml version="1.0"?>
19+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
20+
21+ <!-- I can't believe I have to do this -->
22+ <!-- Based on this code:
23+ http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx
24+ -->
25+ <xsl:template name="strreplace">
26+ <xsl:param name="string"/>
27+ <xsl:param name="token"/>
28+ <xsl:param name="newtoken"/>
29+ <xsl:choose>
30+ <xsl:when test="contains($string, $token)">
31+ <xsl:value-of select="substring-before($string, $token)"/>
32+ <xsl:value-of select="$newtoken"/>
33+ <xsl:call-template name="strreplace">
34+ <xsl:with-param name="string" select="substring-after($string, $token)"/>
35+ <xsl:with-param name="token" select="$token"/>
36+ <xsl:with-param name="newtoken" select="$newtoken"/>
37+ </xsl:call-template>
38+ </xsl:when>
39+ <xsl:otherwise>
40+ <xsl:value-of select="$string"/>
41+ </xsl:otherwise>
42+ </xsl:choose>
43+ </xsl:template>
44+
45+ <xsl:template match="/">
46+ <xsl:for-each select="gtester">
47+ <testsuite>
48+ <xsl:attribute name="name">
49+ <xsl:value-of select="testbinary[1]/@path"/>
50+ </xsl:attribute>
51+ <xsl:attribute name="tests">
52+ <xsl:value-of select="count(testbinary[1]/testcase)"/>
53+ </xsl:attribute>
54+ <xsl:attribute name="time">
55+ <xsl:value-of select="sum(testbinary[1]/testcase/duration)"/>
56+ </xsl:attribute>
57+ <xsl:attribute name="failures">
58+ <xsl:value-of select="count(testbinary[1]/testcase/status[@result='failed'])"/>
59+ </xsl:attribute>
60+ <xsl:for-each select="testbinary[1]/testcase">
61+ <testcase>
62+ <xsl:variable name="classname">
63+ <xsl:call-template name="strreplace">
64+ <xsl:with-param name="string" select="substring-after(@path, '/')"/>
65+ <xsl:with-param name="token" select="'/'"/>
66+ <xsl:with-param name="newtoken" select="'.'"/>
67+ </xsl:call-template>
68+ </xsl:variable>
69+ <xsl:attribute name="classname">
70+ <xsl:value-of select="$classname"/>
71+ </xsl:attribute>
72+ <xsl:attribute name="name">g_test</xsl:attribute>
73+ <xsl:attribute name="time">
74+ <xsl:value-of select="duration"/>
75+ </xsl:attribute>
76+ <xsl:if test="status[@result = 'failed']">
77+ <failure>
78+ <xsl:value-of select="error"/>
79+ </failure>
80+ </xsl:if>
81+ </testcase>
82+ </xsl:for-each>
83+ </testsuite>
84+ </xsl:for-each>
85+ </xsl:template>
86+</xsl:stylesheet>
87
88=== modified file 'tests/gtester2xunit.py'
89--- tests/gtester2xunit.py 2013-05-31 16:45:50 +0000
90+++ tests/gtester2xunit.py 2013-06-04 20:00:35 +0000
91@@ -6,8 +6,6 @@
92 import os
93
94 XSL_TRANSFORM='/usr/share/gtester2xunit/gtester.xsl'
95-#XSL_TRANSFORM='./gtester.xsl'
96-
97
98 def transform_file(input_filename, output_filename, xsl_file):
99 gtester = libxml2.parseFile(xsl_file)

Subscribers

People subscribed via source and target branches