Merge lp:~3v1n0/bamf/xunit-coverage-fixes-0.4 into lp:bamf/0.4

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Francis Ginther
Approved revision: 542
Merged at revision: 539
Proposed branch: lp:~3v1n0/bamf/xunit-coverage-fixes-0.4
Merge into: lp:bamf/0.4
Diff against target: 318 lines (+167/-15)
9 files modified
Makefile.am.coverage (+11/-8)
configure.ac (+12/-0)
debian/control (+1/-0)
tests/Makefile.am (+2/-0)
tests/Makefile.am.gtests (+13/-6)
tests/bamfdaemon/Makefile.am (+3/-1)
tests/gtester.xsl (+69/-0)
tests/gtester2xunit.py (+54/-0)
tests/libbamf/Makefile.am (+2/-0)
To merge this branch: bzr merge lp:~3v1n0/bamf/xunit-coverage-fixes-0.4
Reviewer Review Type Date Requested Status
Francis Ginther Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+168250@code.launchpad.net

Commit message

Makefile.am.gtests, Makefile.am.coverage: add missing entries to allow building in jenkins

Description of the change

Backporting changes introduced in trunk with lp:~3v1n0/bamf/libbamf-load-favorites-sticky-values and lp:~3v1n0/bamf/libbamf-private that allows to correctly build in jenkins.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Builds and produces the expected test and coverage files.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am.coverage'
2--- Makefile.am.coverage 2012-12-13 21:54:59 +0000
3+++ Makefile.am.coverage 2013-06-08 17:29:27 +0000
4@@ -7,8 +7,6 @@
5
6 clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr
7
8-if HAVE_GCOV
9-
10 clean-gcno:
11 @echo Removing old coverage instrumentation
12 -find -name '*.gcno' -print | xargs -r rm
13@@ -16,7 +14,8 @@
14 clean-gcda:
15 @echo Removing old coverage results
16 -find -name '*.gcda' -print | xargs -r rm
17-
18+
19+if HAVE_GCOV
20 coverage-html:
21 -$(MAKE) $(AM_MAKEFLAGS) -k check
22 $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
23@@ -35,14 +34,18 @@
24 coverage-gcovr:
25 -$(MAKE) $(AM_MAKEFLAGS) -k check
26 $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
27-
28+
29+coverage-xml: coverage-gcovr
30+
31 generate-coverage-gcovr:
32 @echo Generating coverage GCOVR report
33- $(GCOVR) --xml -r $(top_builddir) -o $(top_builddir)/coverage.xml
34-
35-clean-coverage-gcovr: clean-gcda
36- -rm -rf $(top_builddir)/coverage.xml
37+ $(GCOVR) --xml -r $(top_builddir) -e "tests.*" -o $(top_builddir)/coverage.xml
38
39 endif # HAVE_GCOVR
40
41 endif # HAVE_GCOV
42+
43+clean-coverage-gcovr: clean-gcda
44+ -rm -f $(top_builddir)/coverage.xml
45+
46+clean-coverage-xml: clean-coverage-gcovr
47
48=== modified file 'configure.ac'
49--- configure.ac 2013-05-24 18:37:43 +0000
50+++ configure.ac 2013-06-08 17:29:27 +0000
51@@ -120,6 +120,18 @@
52 AC_SUBST(LIBUNITY_WEBAPPS_LIBS)
53
54 ###########################
55+# gtester2xunit checks #
56+###########################
57+
58+AC_PATH_PROG([PYTHON],[python])
59+AC_MSG_CHECKING(for gtester2xunit dependencies)
60+if !($PYTHON -c "import libxslt, libxml2" 2> /dev/null); then
61+ AC_MSG_RESULT([no])
62+ AC_MSG_ERROR([You need to install python-libxslt1 and python-libxml2]);
63+fi
64+AC_MSG_RESULT([yes])
65+
66+###########################
67 # Headless tests
68 ###########################
69 AC_ARG_ENABLE([headless-tests],
70
71=== modified file 'debian/control'
72--- debian/control 2013-05-01 23:03:44 +0000
73+++ debian/control 2013-06-08 17:29:27 +0000
74@@ -16,6 +16,7 @@
75 libunity-webapps-dev (>= 2.3.3),
76 libwnck-3-dev (>= 3.4.5),
77 libgirepository1.0-dev,
78+ python-libxslt1,
79 valac,
80 xvfb,
81 Standards-Version: 3.9.3
82
83=== modified file 'tests/Makefile.am'
84--- tests/Makefile.am 2013-05-24 18:37:43 +0000
85+++ tests/Makefile.am 2013-06-08 17:29:27 +0000
86@@ -7,4 +7,6 @@
87 EXTRA_DIST = \
88 data \
89 run-xvfb.sh \
90+ gtester2xunit.py \
91+ gtester.xsl \
92 $(NULL)
93
94=== modified file 'tests/Makefile.am.gtests'
95--- tests/Makefile.am.gtests 2013-05-30 22:44:37 +0000
96+++ tests/Makefile.am.gtests 2013-06-08 17:29:27 +0000
97@@ -3,9 +3,11 @@
98 #
99 # Author: Marco Trevisan <marco@ubuntu.com>
100
101+GTESTER2XUNIT_RUN = $(abs_top_srcdir)/tests/gtester2xunit.py
102+
103 # Run tests as part of make check
104+
105 if ENABLE_HEADLESS_TESTS
106-check-local: test-headless
107
108 XVFB_RUN = $(abs_top_srcdir)/tests/run-xvfb.sh
109 LOG_PATH = headless-logs
110@@ -22,15 +24,20 @@
111 $(DBUS_LAUNCH) > $(LOG_PATH)/sessionbus.sh; \
112 source $(LOG_PATH)/sessionbus.sh; \
113 \
114- make test;
115-# END HEADLESS TESTS
116-else
117+ make $(AM_MAKEFLAGS) -k test
118+
119+check-local: test-headless
120+
121+else # END HEADLESS TESTS
122+
123 check-local: test
124+
125 endif
126
127
128 test:
129- @gtester -k --verbose -o=$(TEST_BINARY)-results.xml ./$(TEST_BINARY)
130+ @gtester -k --verbose -o=$(TEST_BINARY)-results.xml ./$(TEST_BINARY); \
131+ $(GTESTER2XUNIT_RUN) -x $(abs_top_srcdir)/tests/gtester.xsl $(TEST_BINARY)-results.xml
132
133 .PHONY: check-report full-report
134 check-report: $(TEST_BINARY)
135@@ -47,4 +54,4 @@
136 > $(TEST_BINARY)-results.html )
137
138 clean-generic:
139- rm -f $(TEST_BINARY)-results.xml $(TEST_BINARY)-results.html
140+ rm -f $(TEST_BINARY)-results*.xml $(TEST_BINARY)-results.html
141
142=== modified file 'tests/bamfdaemon/Makefile.am'
143--- tests/bamfdaemon/Makefile.am 2013-05-24 17:59:23 +0000
144+++ tests/bamfdaemon/Makefile.am 2013-06-08 17:29:27 +0000
145@@ -78,6 +78,7 @@
146 -I$(top_builddir)/src \
147 -DWNCK_I_KNOW_THIS_IS_UNSTABLE \
148 -DTESTDIR=\""$(abs_top_srcdir)/tests"\" \
149+ $(COVERAGE_CFLAGS) \
150 $(GCC_FLAGS) \
151 $(GTK_CFLAGS) \
152 $(GLIB_CFLAGS) \
153@@ -92,10 +93,11 @@
154 $(WNCK_LIBS) \
155 $(GTOP_LIBS) \
156 $(GTK_LIBS) \
157- $(LIBUNITY_WEBAPPS_LIBS)
158+ $(LIBUNITY_WEBAPPS_LIBS)
159
160 test_bamf_LDFLAGS = \
161 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions \
162+ $(COVERAGE_LDFLAGS) \
163 $(NULL)
164
165 EXTRA_DIST = \
166
167=== added file 'tests/gtester.xsl'
168--- tests/gtester.xsl 1970-01-01 00:00:00 +0000
169+++ tests/gtester.xsl 2013-06-08 17:29:27 +0000
170@@ -0,0 +1,69 @@
171+<?xml version="1.0"?>
172+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
173+
174+ <!-- I can't believe I have to do this -->
175+ <!-- Based on this code:
176+ http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx
177+ -->
178+ <xsl:template name="strreplace">
179+ <xsl:param name="string"/>
180+ <xsl:param name="token"/>
181+ <xsl:param name="newtoken"/>
182+ <xsl:choose>
183+ <xsl:when test="contains($string, $token)">
184+ <xsl:value-of select="substring-before($string, $token)"/>
185+ <xsl:value-of select="$newtoken"/>
186+ <xsl:call-template name="strreplace">
187+ <xsl:with-param name="string" select="substring-after($string, $token)"/>
188+ <xsl:with-param name="token" select="$token"/>
189+ <xsl:with-param name="newtoken" select="$newtoken"/>
190+ </xsl:call-template>
191+ </xsl:when>
192+ <xsl:otherwise>
193+ <xsl:value-of select="$string"/>
194+ </xsl:otherwise>
195+ </xsl:choose>
196+ </xsl:template>
197+
198+ <xsl:template match="/">
199+ <xsl:for-each select="gtester">
200+ <testsuite>
201+ <xsl:attribute name="name">
202+ <xsl:value-of select="testbinary[1]/@path"/>
203+ </xsl:attribute>
204+ <xsl:attribute name="tests">
205+ <xsl:value-of select="count(testbinary[1]/testcase)"/>
206+ </xsl:attribute>
207+ <xsl:attribute name="time">
208+ <xsl:value-of select="sum(testbinary[1]/testcase/duration)"/>
209+ </xsl:attribute>
210+ <xsl:attribute name="failures">
211+ <xsl:value-of select="count(testbinary[1]/testcase/status[@result='failed'])"/>
212+ </xsl:attribute>
213+ <xsl:for-each select="testbinary[1]/testcase">
214+ <testcase>
215+ <xsl:variable name="classname">
216+ <xsl:call-template name="strreplace">
217+ <xsl:with-param name="string" select="substring-after(@path, '/')"/>
218+ <xsl:with-param name="token" select="'/'"/>
219+ <xsl:with-param name="newtoken" select="'.'"/>
220+ </xsl:call-template>
221+ </xsl:variable>
222+ <xsl:attribute name="classname">
223+ <xsl:value-of select="$classname"/>
224+ </xsl:attribute>
225+ <xsl:attribute name="name">g_test</xsl:attribute>
226+ <xsl:attribute name="time">
227+ <xsl:value-of select="duration"/>
228+ </xsl:attribute>
229+ <xsl:if test="status[@result = 'failed']">
230+ <failure>
231+ <xsl:value-of select="error"/>
232+ </failure>
233+ </xsl:if>
234+ </testcase>
235+ </xsl:for-each>
236+ </testsuite>
237+ </xsl:for-each>
238+ </xsl:template>
239+</xsl:stylesheet>
240
241=== added file 'tests/gtester2xunit.py'
242--- tests/gtester2xunit.py 1970-01-01 00:00:00 +0000
243+++ tests/gtester2xunit.py 2013-06-08 17:29:27 +0000
244@@ -0,0 +1,54 @@
245+#! /usr/bin/python
246+from argparse import ArgumentParser
247+import libxslt
248+import libxml2
249+import sys
250+import os
251+
252+XSL_TRANSFORM='/usr/share/gtester2xunit/gtester.xsl'
253+
254+def transform_file(input_filename, output_filename, xsl_file):
255+ gtester = libxml2.parseFile(xsl_file)
256+ style = libxslt.parseStylesheetDoc(gtester)
257+ doc = libxml2.parseFile(input_filename)
258+ result = style.applyStylesheet(doc, None)
259+ result.saveFormatFile(filename=output_filename, format=True)
260+
261+
262+def get_output_filename(input_filename):
263+ filename, extension = os.path.splitext(input_filename)
264+ return '{filename}-xunit{extension}'.format(filename=filename,
265+ extension=extension)
266+
267+def main():
268+ parser = ArgumentParser(
269+ description="Simple utility that converts xml output of " +
270+ "gtester to xunit output for jenkins")
271+ parser.add_argument('-o', '--output',
272+ help="Write output to specified file instead of default")
273+ parser.add_argument('-x', '--xsl',
274+ help="xsl file that should be used for the transformation")
275+ parser.add_argument('-i', '--in-place',
276+ help="Write the ouput to the original file (i.e. replace " +
277+ "the original xml)",
278+ action='store_true',
279+ default=False)
280+ parser.add_argument('files', metavar='FILE', type=str, nargs='+',
281+ help="file(s) to transform to xunit format")
282+ args = vars(parser.parse_args())
283+ for input_filename in args['files']:
284+ if not args['output']:
285+ if args['in_place']:
286+ output_filename = input_filename
287+ else:
288+ output_filename = get_output_filename(input_filename)
289+ else:
290+ output_filename = args['output']
291+ if not args['xsl']:
292+ xsl = XSL_TRANSFORM
293+ else:
294+ xsl = args['xsl']
295+ transform_file(input_filename, output_filename, xsl)
296+
297+sys.exit(main())
298+# vim: set syntex=python:
299
300=== modified file 'tests/libbamf/Makefile.am'
301--- tests/libbamf/Makefile.am 2013-05-30 22:44:04 +0000
302+++ tests/libbamf/Makefile.am 2013-06-08 17:29:27 +0000
303@@ -12,6 +12,7 @@
304 -I$(top_srcdir)/lib/libbamf \
305 -I$(top_builddir)/lib/libbamf \
306 -DTESTDIR=\""$(abs_top_srcdir)/tests"\" \
307+ $(COVERAGE_CFLAGS) \
308 $(GCC_FLAGS) \
309 $(DBUS_CFLAGS) \
310 $(GTK_CFLAGS) \
311@@ -19,6 +20,7 @@
312
313 test_libbamf_LDADD = \
314 $(top_builddir)/lib/libbamf/libbamf$(LIBBAMF_VER).la \
315+ $(COVERAGE_LDFLAGS) \
316 $(GLIB_LIBS) \
317 $(GTK_LIBS) \
318 $(DBUS_LIBS)

Subscribers

People subscribed via source and target branches