Merge lp:~ken-vandine/content-hub/gtest_1_8 into lp:content-hub

Proposed by Ken VanDine
Status: Merged
Approved by: Arthur Mello
Approved revision: 308
Merged at revision: 308
Proposed branch: lp:~ken-vandine/content-hub/gtest_1_8
Merge into: lp:content-hub
Diff against target: 267 lines (+107/-100)
4 files modified
CMakeLists.txt (+2/-0)
cmake/FindGtest.cmake (+67/-0)
tests/CMakeLists.txt (+0/-7)
tests/acceptance-tests/CMakeLists.txt (+38/-93)
To merge this branch: bzr merge lp:~ken-vandine/content-hub/gtest_1_8
Reviewer Review Type Date Requested Status
Arthur Mello (community) Approve
system-apps-ci-bot continuous-integration Needs Fixing
Review via email: mp+311968@code.launchpad.net

Commit message

Fix build failure on zesty due to googletest 1.8. Also refactored tests/acceptance-tests/CMakeLists.txt to make adding tests less cumbersome.

Description of the change

Fix build failure on zesty due to googletest 1.8. Also refactored tests/acceptance-tests/CMakeLists.txt to make adding tests less cumbersome.

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:308
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/108/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2067/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2070
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1900
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1900/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1900/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1900
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1900/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1900
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1900/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1900
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1900/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1900
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1900/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1900
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1900/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1900/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1900/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/108/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Arthur Mello (artmello) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-08-23 20:17:57 +0000
3+++ CMakeLists.txt 2016-11-28 17:37:05 +0000
4@@ -52,6 +52,8 @@
5 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" )
6 ENDIF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE])
7
8+find_package(Gtest REQUIRED)
9+include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})
10 enable_testing()
11
12 set(CMAKE_INCLUDE_CURRENT_DIR ON)
13
14=== added file 'cmake/FindGtest.cmake'
15--- cmake/FindGtest.cmake 1970-01-01 00:00:00 +0000
16+++ cmake/FindGtest.cmake 2016-11-28 17:37:05 +0000
17@@ -0,0 +1,67 @@
18+include(ExternalProject)
19+include(FindPackageHandleStandardArgs)
20+
21+#gtest
22+if (EXISTS /usr/src/googletest)
23+ set (USING_GOOGLETEST_1_8 TRUE)
24+ set (GTEST_INSTALL_DIR /usr/src/googletest/googletest/include)
25+else()
26+ set(GTEST_INSTALL_DIR /usr/src/gmock/gtest/include)
27+endif()
28+find_path(GTEST_INCLUDE_DIR gtest/gtest.h
29+ HINTS ${GTEST_INSTALL_DIR})
30+
31+#gmock
32+find_path(GMOCK_INSTALL_DIR CMakeLists.txt
33+ HINTS /usr/src/googletest /usr/src/gmock)
34+if(${GMOCK_INSTALL_DIR} STREQUAL "GMOCK_INSTALL_DIR-NOTFOUND")
35+ message(FATAL_ERROR "google-mock package not found")
36+endif()
37+
38+find_path(GMOCK_INCLUDE_DIR gmock/gmock.h)
39+
40+if (USING_GOOGLETEST_1_8)
41+ set(GMOCK_BASE_BINARY_DIR ${CMAKE_BINARY_DIR}/gmock/libs)
42+ set(GMOCK_BINARY_DIR ${GMOCK_BASE_BINARY_DIR}/googlemock)
43+ set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest)
44+else()
45+ set(GMOCK_BASE_BINARY_DIR ${CMAKE_BINARY_DIR}/gmock/libs)
46+ set(GMOCK_BINARY_DIR ${GMOCK_BASE_BINARY_DIR})
47+ set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest)
48+endif()
49+
50+set(GTEST_CMAKE_ARGS "")
51+if (${MIR_IS_CROSS_COMPILING})
52+ set(GTEST_CMAKE_ARGS
53+ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake)
54+endif()
55+
56+if (USING_GOOGLETEST_1_8)
57+ list(APPEND GTEST_CMAKE_ARGS -DBUILD_GTEST=ON)
58+endif()
59+
60+ExternalProject_Add(
61+ GMock
62+ #where to build in source tree
63+ PREFIX ${GMOCK_PREFIX}
64+ #where the source is external to the project
65+ SOURCE_DIR ${GMOCK_INSTALL_DIR}
66+ #forward the compilers to the subproject so cross-arch builds work
67+ CMAKE_ARGS ${GTEST_CMAKE_ARGS}
68+ BINARY_DIR ${GMOCK_BASE_BINARY_DIR}
69+
70+ #we don't need to install, so skip
71+ INSTALL_COMMAND ""
72+)
73+
74+set(GMOCK_LIBRARY ${GMOCK_BINARY_DIR}/libgmock.a)
75+set(GMOCK_MAIN_LIBRARY ${GMOCK_BINARY_DIR}/libgmock_main.a)
76+set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY})
77+set(GTEST_LIBRARY ${GTEST_BINARY_DIR}/libgtest.a)
78+set(GTEST_MAIN_LIBRARY ${GTEST_BINARY_DIR}/libgtest_main.a)
79+set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY})
80+set(GTEST_ALL_LIBRARIES ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
81+
82+find_package_handle_standard_args(GTest DEFAULT_MSG
83+ GMOCK_INCLUDE_DIR
84+ GTEST_INCLUDE_DIR)
85
86=== modified file 'tests/CMakeLists.txt'
87--- tests/CMakeLists.txt 2015-09-23 14:45:09 +0000
88+++ tests/CMakeLists.txt 2016-11-28 17:37:05 +0000
89@@ -14,15 +14,8 @@
90 #
91 # Authored by: Thomas Voss <thomas.voss@canonical.com>
92
93-# Build with system gmock and embedded gtest
94-set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory")
95-set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory")
96-set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")
97-
98 add_definitions(-DQT_NO_KEYWORDS)
99
100-add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
101-
102 include_directories (
103 ${CMAKE_SOURCE_DIR}/src
104 ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content
105
106=== modified file 'tests/acceptance-tests/CMakeLists.txt'
107--- tests/acceptance-tests/CMakeLists.txt 2016-11-23 14:27:28 +0000
108+++ tests/acceptance-tests/CMakeLists.txt 2016-11-28 17:37:05 +0000
109@@ -14,54 +14,52 @@
110 #
111 # Authored by: Thomas Voss <thomas.voss@canonical.com>
112
113+project(test CXX C)
114 qt5_wrap_cpp(MOCS test_harness.h)
115
116-add_executable(
117+set(TESTS
118 app_hub_communication_default_source
119- app_hub_communication_default_source.cpp
120- ${MOCS}
121-)
122-
123-add_executable(
124 app_hub_communication_known_sources
125- app_hub_communication_known_sources.cpp
126- ${MOCS}
127-)
128-
129-add_executable(
130 app_hub_communication_stores
131- app_hub_communication_stores.cpp
132- ${MOCS}
133-)
134-
135-add_executable(
136 app_hub_communication_transfer
137- app_hub_communication_transfer.cpp
138- ${MOCS}
139-)
140-
141-add_executable(
142 app_hub_communication_paste
143- app_hub_communication_paste.cpp
144- ${MOCS}
145-)
146-
147-add_executable(
148 app_hub_communication_handler
149- app_hub_communication_handler.cpp
150- ${MOCS}
151- transfer_files
152-)
153-
154-add_executable(
155 test_utils
156- test_utils.cpp
157-)
158-
159-add_executable(
160 test_types
161- test_types.cpp
162-)
163+ mimedata_test
164+)
165+
166+set(TEST_LIBS
167+ ${GMOCK_LIBRARY}
168+ ${GTEST_BOTH_LIBRARIES}
169+ content-hub
170+)
171+
172+foreach(test ${TESTS})
173+ # set the sources per test
174+ set(${test}_SOURCES
175+ ${test}.cpp
176+ ${MOCS}
177+ transfer_files
178+ )
179+endforeach(test)
180+
181+foreach(test ${TESTS})
182+ # set targets, linked libs and test
183+ add_executable(${test}
184+ ${${test}_SOURCES}
185+ )
186+ qt5_use_modules(${test} Core Gui DBus Test)
187+
188+ target_link_libraries(${test}
189+ ${TEST_LIBS}
190+ )
191+
192+ add_test(NAME ${test} COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/${test})
193+
194+ SET_TESTS_PROPERTIES(${test}
195+ PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
196+endforeach(test)
197
198 add_executable(
199 test_hook
200@@ -74,65 +72,12 @@
201 source_all.json
202 )
203
204-add_executable(
205- mimedata_test
206- mimedata_test.cpp
207- ${MOCS}
208-)
209-
210-qt5_use_modules(app_hub_communication_default_source Core Gui DBus Test)
211-qt5_use_modules(app_hub_communication_known_sources Core Gui DBus Test)
212-qt5_use_modules(app_hub_communication_stores Core Gui DBus Test)
213-qt5_use_modules(app_hub_communication_transfer Core Gui DBus Test)
214-qt5_use_modules(app_hub_communication_paste Core Gui DBus Test)
215-qt5_use_modules(app_hub_communication_handler Core Gui DBus Test)
216-qt5_use_modules(test_utils Core Test)
217 qt5_use_modules(test_hook Core Gui DBus Test)
218-qt5_use_modules(mimedata_test Core Test)
219-
220-target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main)
221-target_link_libraries(app_hub_communication_default_source content-hub gmock gtest gtest_main)
222-target_link_libraries(app_hub_communication_known_sources content-hub gmock gtest gtest_main)
223-target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main)
224-target_link_libraries(app_hub_communication_transfer content-hub gmock gtest gtest_main)
225-target_link_libraries(app_hub_communication_paste content-hub gmock gtest gtest_main)
226-target_link_libraries(app_hub_communication_handler content-hub gmock gtest gtest_main)
227-target_link_libraries(test_utils content-hub gmock gtest gtest_main)
228-target_link_libraries(test_types content-hub gmock gtest gtest_main)
229-target_link_libraries(test_hook content-hub gmock gtest gtest_main ${GSETTINGS_LDFLAGS})
230-target_link_libraries(mimedata_test content-hub gmock gtest gtest_main)
231-
232-add_test(NAME app_hub_communication_default_source COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/app_hub_communication_default_source)
233-add_test(NAME app_hub_communication_known_sources COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/app_hub_communication_known_sources)
234-add_test(NAME app_hub_communication_stores COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/app_hub_communication_stores)
235-add_test(NAME app_hub_communication_transfer COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/app_hub_communication_transfer)
236-add_test(NAME app_hub_communication_paste COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/app_hub_communication_paste)
237-add_test(NAME app_hub_communication_handler COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/app_hub_communication_handler)
238-add_test(NAME test_utils COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/test_utils)
239-add_test(NAME test_types COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/test_types)
240+target_link_libraries(test_hook content-hub ${GTEST_ALL_LIBRARIES} ${GSETTINGS_LDFLAGS})
241 add_test(NAME test_hook COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/test_hook)
242-add_test(NAME mimedata_test COMMAND mimedata_test)
243
244-SET_TESTS_PROPERTIES(app_hub_communication_stores
245- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
246-SET_TESTS_PROPERTIES(app_hub_communication_default_source
247- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
248-SET_TESTS_PROPERTIES(app_hub_communication_known_sources
249- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
250-SET_TESTS_PROPERTIES(app_hub_communication_transfer
251- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
252-SET_TESTS_PROPERTIES(app_hub_communication_paste
253- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
254-SET_TESTS_PROPERTIES(app_hub_communication_handler
255- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
256-SET_TESTS_PROPERTIES(test_utils
257- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
258-SET_TESTS_PROPERTIES(test_types
259- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
260 SET_TESTS_PROPERTIES(test_hook
261- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
262-SET_TESTS_PROPERTIES(mimedata_test
263- PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
264+ PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
265
266 set_target_properties(
267 test_hook

Subscribers

People subscribed via source and target branches