Merge lp:~allanlesage/coverage-builder/qmake-test into lp:coverage-builder

Proposed by Allan LeSage
Status: Merged
Merged at revision: 276
Proposed branch: lp:~allanlesage/coverage-builder/qmake-test
Merge into: lp:coverage-builder
Prerequisite: lp:~allanlesage/coverage-builder/build-test
Diff against target: 281 lines (+207/-0)
14 files modified
test/qmake-project/coverage.pri (+45/-0)
test/qmake-project/debian/changelog (+5/-0)
test/qmake-project/debian/control (+12/-0)
test/qmake-project/debian/rules (+3/-0)
test/qmake-project/fibonacci.cpp (+11/-0)
test/qmake-project/fibonacci.h (+7/-0)
test/qmake-project/fibonacci.pro (+9/-0)
test/qmake-project/gtest/gtest.pro (+32/-0)
test/qmake-project/main.cpp (+9/-0)
test/qmake-project/tests/fibonacci-test.pro (+11/-0)
test/qmake-project/tests/test_fibonacci.cpp (+22/-0)
test/qmake-project/tests/test_main.cpp (+8/-0)
test/qmake-project/tests/tests.pro (+9/-0)
test/test_qmake.py (+24/-0)
To merge this branch: bzr merge lp:~allanlesage/coverage-builder/qmake-test
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Review via email: mp+234915@code.launchpad.net

Description of the change

Add a minimal qmake test; note that once we have .gcnos we're all set, and all the same further diversions (dh_auto_test, e.g.) will be the same--this test just ensures that we can get .gcnos from the same minimal fibonacci codebase.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

LGTM, except for the debian package name of the test project (similar to the other MP).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'test/qmake-project'
2=== added file 'test/qmake-project/coverage.pri'
3--- test/qmake-project/coverage.pri 1970-01-01 00:00:00 +0000
4+++ test/qmake-project/coverage.pri 2014-09-17 05:43:33 +0000
5@@ -0,0 +1,45 @@
6+# Coverage
7+CONFIG(coverage) {
8+ LIBS += -lgcov
9+ QMAKE_CXXFLAGS += --coverage
10+ QMAKE_LDFLAGS += --coverage
11+
12+ QMAKE_EXTRA_TARGETS += coverage cov
13+ QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \
14+ generate-coverage-html clean-coverage-html coverage-gcovr \
15+ generate-gcovr generate-coverage-gcovr clean-coverage-gcovr
16+
17+ clean-gcno.commands = \
18+ "@echo Removing old coverage instrumentation"; \
19+ "find -name '*.gcno' -print | xargs -r rm"
20+
21+ clean-gcda.commands = \
22+ "@echo Removing old coverage results"; \
23+ "find -name '*.gcda' -print | xargs -r rm"
24+
25+ coverage-html.depends = clean-gcda check generate-coverage-html
26+
27+ generate-coverage-html.commands = \
28+ "@echo Collecting coverage data"; \
29+ "lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \
30+ "lcov --extract coverage.info \"*/src/*.cpp\" -o coverage.info"; \
31+ "lcov --remove coverage.info \"moc_*.cpp\" -o coverage.info"; \
32+ "LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info"
33+
34+ clean-coverage-html.depends = clean-gcda
35+ clean-coverage-html.commands = \
36+ "lcov --directory $${TOP_SRC_DIR} -z"; \
37+ "rm -rf coverage.info coverage-html"
38+
39+ coverage-gcovr.depends = clean-gcda check generate-coverage-gcovr
40+
41+ generate-coverage-gcovr.commands = \
42+ "@echo Generating coverage GCOVR report"; \
43+ "gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"tests/.*\" -e \".*\\.h\""
44+
45+ clean-coverage-gcovr.depends = clean-gcda
46+ clean-coverage-gcovr.commands = \
47+ "rm -rf $${TOP_SRC_DIR}/coverage.xml"
48+
49+ QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml
50+}
51
52=== added directory 'test/qmake-project/debian'
53=== added file 'test/qmake-project/debian/changelog'
54--- test/qmake-project/debian/changelog 1970-01-01 00:00:00 +0000
55+++ test/qmake-project/debian/changelog 2014-09-17 05:43:33 +0000
56@@ -0,0 +1,5 @@
57+dummy-coverage-mangler (1.0) UNRELEASED; urgency=medium
58+
59+ * Initial release.
60+
61+ -- Pep Peroni <pep8000@fansofpitti.org> Sun, 24 Aug 2014 20:54:32 -0500
62
63=== added file 'test/qmake-project/debian/control'
64--- test/qmake-project/debian/control 1970-01-01 00:00:00 +0000
65+++ test/qmake-project/debian/control 2014-09-17 05:43:33 +0000
66@@ -0,0 +1,12 @@
67+Source: dummy-coverage-mangler
68+Maintainer: Al Fresco <n00b@fansofpitt.org>
69+Section: misc
70+Priority: optional
71+Standards-Version: 3.9.5
72+Build-Depends: debhelper (>= 9)
73+
74+Package: dummy-coverage-mangler
75+Architecture: any
76+Depends: ${shlibs:Depends}, ${misc:Depends}
77+Description: Say hello world
78+ Say "Hello world!" and exit!
79
80=== added file 'test/qmake-project/debian/copyright'
81=== added file 'test/qmake-project/debian/rules'
82--- test/qmake-project/debian/rules 1970-01-01 00:00:00 +0000
83+++ test/qmake-project/debian/rules 2014-09-17 05:43:33 +0000
84@@ -0,0 +1,3 @@
85+#!/usr/bin/make -f
86+%:
87+ dh $@
88
89=== added file 'test/qmake-project/fibonacci.cpp'
90--- test/qmake-project/fibonacci.cpp 1970-01-01 00:00:00 +0000
91+++ test/qmake-project/fibonacci.cpp 2014-09-17 05:43:33 +0000
92@@ -0,0 +1,11 @@
93+
94+#include "fibonacci.h"
95+
96+int fib(int x)
97+{
98+ if (x == 0)
99+ return 0;
100+ if (x == 1)
101+ return 1;
102+ return fib(x-1) + fib(x-2);
103+}
104
105=== added file 'test/qmake-project/fibonacci.h'
106--- test/qmake-project/fibonacci.h 1970-01-01 00:00:00 +0000
107+++ test/qmake-project/fibonacci.h 2014-09-17 05:43:33 +0000
108@@ -0,0 +1,7 @@
109+
110+#ifndef _FIBONACCI_H
111+#define _FIBONACCI_H
112+
113+int fib(int x);
114+
115+#endif
116
117=== added file 'test/qmake-project/fibonacci.pro'
118--- test/qmake-project/fibonacci.pro 1970-01-01 00:00:00 +0000
119+++ test/qmake-project/fibonacci.pro 2014-09-17 05:43:33 +0000
120@@ -0,0 +1,9 @@
121+include(coverage.pri)
122+TARGET = fibonacci
123+CONFIG += coverage
124+TEMPLATE = subdirs
125+SUBDIRS = gtest \
126+ tests
127+SOURCES = main.cpp \
128+ fibonacci.cpp
129+HEADERS = fibonacci.h
130
131=== added directory 'test/qmake-project/gtest'
132=== added file 'test/qmake-project/gtest/gtest.pro'
133--- test/qmake-project/gtest/gtest.pro 1970-01-01 00:00:00 +0000
134+++ test/qmake-project/gtest/gtest.pro 2014-09-17 05:43:33 +0000
135@@ -0,0 +1,32 @@
136+
137+TEMPLATE = lib
138+CONFIG += static
139+TARGET = gtest
140+
141+INCLUDEPATH += /usr/src/gtest
142+
143+HEADERS = /usr/include/gtest/*.h
144+SOURCES = /usr/src/gtest/src/gtest-all.cc
145+
146+# culled from Googling
147+#INCLUDEPATH += ../path/to/gtest/includes
148+#LIBS += -L../path/to/gtest/libraries -lgtest
149+
150+# this is what we do in CMake
151+## Check for google test and build it locally
152+#set(
153+# GTEST_ROOT_DIR
154+# "/usr/src/gtest" # Default value, adjustable by user with e.g., ccmake
155+# CACHE
156+# PATH
157+# "Path to Google test srcs"
158+#)
159+#
160+#find_path(GTEST_INCLUDE_DIR gtest/gtest.h)
161+#if (GTEST_INCLUDE_DIR)
162+# #FIXME - hardcoded is bad!
163+# add_subdirectory(
164+# ${GTEST_ROOT_DIR}
165+# gtest
166+# )
167+#endif(GTEST_INCLUDE_DIR)
168
169=== added file 'test/qmake-project/main.cpp'
170--- test/qmake-project/main.cpp 1970-01-01 00:00:00 +0000
171+++ test/qmake-project/main.cpp 2014-09-17 05:43:33 +0000
172@@ -0,0 +1,9 @@
173+#include <iostream>
174+#include "fibonacci.h"
175+
176+int main ()
177+{
178+ std::cout << "Hello world!" << std::endl;
179+ int x = fib(2);
180+ return x;
181+}
182
183=== added directory 'test/qmake-project/tests'
184=== added file 'test/qmake-project/tests/fibonacci-test.pro'
185--- test/qmake-project/tests/fibonacci-test.pro 1970-01-01 00:00:00 +0000
186+++ test/qmake-project/tests/fibonacci-test.pro 2014-09-17 05:43:33 +0000
187@@ -0,0 +1,11 @@
188+
189+SOURCES = test_main.cpp \
190+ test_fibonacci.cpp
191+ ../fibonacci.cpp
192+
193+HEADERS = ../fibonacci.h
194+
195+INCLUDEPATH += \
196+ $${TOP_SRC_DIR}
197+
198+QMAKE_EXTRA_TARGETS += check
199
200=== added file 'test/qmake-project/tests/test_fibonacci.cpp'
201--- test/qmake-project/tests/test_fibonacci.cpp 1970-01-01 00:00:00 +0000
202+++ test/qmake-project/tests/test_fibonacci.cpp 2014-09-17 05:43:33 +0000
203@@ -0,0 +1,22 @@
204+
205+
206+#include "gtest/gtest.h"
207+
208+#include "fibonacci.h"
209+
210+
211+TEST(FibonacciTest, FirstTermIsCorrect) {
212+ EXPECT_EQ(0, fib(0));
213+}
214+
215+TEST(FibonacciTest, SecondTermIsCorrect) {
216+ EXPECT_EQ(1, fib(1));
217+}
218+
219+TEST(FibonacciTest, ThirdTermIsCorrect) {
220+ EXPECT_EQ(1, fib(2));
221+}
222+
223+TEST(FibonacciTest, FourthTermIsCorrect) {
224+ EXPECT_EQ(2, fib(3));
225+}
226
227=== added file 'test/qmake-project/tests/test_main.cpp'
228--- test/qmake-project/tests/test_main.cpp 1970-01-01 00:00:00 +0000
229+++ test/qmake-project/tests/test_main.cpp 2014-09-17 05:43:33 +0000
230@@ -0,0 +1,8 @@
231+
232+#include "gtest/gtest.h"
233+
234+int main(int argc, char** argv)
235+{
236+ ::testing::InitGoogleTest(&argc, argv);
237+ return RUN_ALL_TESTS();
238+}
239
240=== added file 'test/qmake-project/tests/tests.pro'
241--- test/qmake-project/tests/tests.pro 1970-01-01 00:00:00 +0000
242+++ test/qmake-project/tests/tests.pro 2014-09-17 05:43:33 +0000
243@@ -0,0 +1,9 @@
244+include(../coverage.pri)
245+TARGET = tests
246+CONFIG += testcase
247+SOURCES = test_main.cpp \
248+ test_fibonacci.cpp \
249+ ../fibonacci.cpp
250+HEADERS = ../fibonacci.h
251+INCLUDEPATH += ..
252+LIBS += -L../gtest -lgtest
253
254=== added file 'test/test_qmake.py'
255--- test/test_qmake.py 1970-01-01 00:00:00 +0000
256+++ test/test_qmake.py 2014-09-17 05:43:33 +0000
257@@ -0,0 +1,24 @@
258+#!/usr/bin/python3
259+# coverage-builder tests
260+# (C) 2014 Canonical Ltd.
261+# Author: Allan LeSage <allan.lesage@canonical.com>
262+# License: GPL 3 or later
263+
264+from test import CoverageBuilderTestCase
265+
266+
267+class QmakeBuildTestCase(CoverageBuilderTestCase):
268+
269+ def setUp(self):
270+ super(QmakeBuildTestCase, self).setUp()
271+ self._copy_dummy_project_into_place('qmake-project')
272+
273+ def test_gcnos_appear(self):
274+ """dh_auto_build makes .gcno files appear.
275+
276+ qmake is relatively tight-lipped with no configure feedback;
277+ just make sure that we get gcnos on build.
278+ """
279+ self._call_dh_auto_configure()
280+ out, err = self._call_dh_auto_build()
281+ self.assertTrue(self._find_gcno())

Subscribers

People subscribed via source and target branches