aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-11 13:55:17 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-11 13:55:17 +0200
commitcc15d245adb2552b3c7fe766560bae725868c907 (patch)
tree06c2e07e757b6d5ef556b10922d7c236f3fdb7b3
parenta2aac2de9402709a0eeea16fb893d261a61624e6 (diff)
parent887b5f92bdd6485a4da521086ec88e63357d2260 (diff)
downloadayatana-indicator-session-cc15d245adb2552b3c7fe766560bae725868c907.tar.gz
ayatana-indicator-session-cc15d245adb2552b3c7fe766560bae725868c907.tar.bz2
ayatana-indicator-session-cc15d245adb2552b3c7fe766560bae725868c907.zip
Merge branch 'tari01-pr/cmake-extras-tests-coverage'
Attribute GH PR #41: https://github.com/AyatanaIndicators/ayatana-indicator-session/pull/41
-rw-r--r--CMakeLists.txt37
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/backend-dbus/CMakeLists.txt5
-rw-r--r--tests/CMakeLists.txt15
-rw-r--r--tests/backend-dbus/CMakeLists.txt21
5 files changed, 27 insertions, 58 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51e6c0a..f067b8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,9 +57,6 @@ add_custom_target (dist
COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-add_custom_target (clean-coverage
- COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f)
-
add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 --inline-suppr
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/tests)
@@ -67,28 +64,24 @@ add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/src)
-# testing & coverage
-if (${ENABLE_TESTS})
-
- if (EXISTS /usr/src/googletest/src)
- set (GTEST_SOURCE_DIR /usr/src/googletest/src)
- else ()
- set (GTEST_SOURCE_DIR /usr/src/gtest/src)
- endif ()
- set (GTEST_INCLUDE_DIR ${GTEST_SOURCE_DIR}/..)
- set (GTEST_LIBS -lpthread)
- enable_testing ()
- if (${ENABLE_COVERAGE})
- include(GCov)
- endif ()
-endif ()
-
add_subdirectory (src)
add_subdirectory (data)
add_subdirectory (po)
-if (${ENABLE_TESTS})
- add_subdirectory (tests)
-endif ()
+
+if (ENABLE_TESTS)
+
+ include(CTest)
+ enable_testing()
+ add_subdirectory(tests)
+
+ if (ENABLE_COVERAGE)
+
+ find_package(CoverageReport)
+ ENABLE_COVERAGE_REPORT(TARGETS "libayatanaindicatorsessionservice" "ayatana-indicator-session-service" TESTS "test-service" "test-actions" "test-guest" "test-users" FILTER /usr/include ${CMAKE_BINARY_DIR}/*)
+
+ endif()
+
+endif()
# Display config info
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7ee1692..eeaa113 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -26,10 +26,5 @@ set_property (SOURCE main.c
GETTEXT_PACKAGE="${GETTEXT_PACKAGE}"
LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
add_executable (${SERVICE_EXEC} main.c)
-target_link_libraries (${SERVICE_EXEC} libayatanaindicatorsessionservice backenddbus ${SERVICE_LIBRARIES} ${GCOV_LIBS} ${URLDISPATCHER_LIBRARIES})
+target_link_libraries (${SERVICE_EXEC} libayatanaindicatorsessionservice backenddbus ${SERVICE_LIBRARIES} ${URLDISPATCHER_LIBRARIES})
install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR})
-
-# common properties
-set_property (TARGET libayatanaindicatorsessionservice ${SERVICE_EXEC}
- APPEND_STRING PROPERTY COMPILE_FLAGS
- " -g ${CC_WARNING_ARGS} ${GCOV_FLAGS}")
diff --git a/src/backend-dbus/CMakeLists.txt b/src/backend-dbus/CMakeLists.txt
index faa09a9..5c99e9f 100644
--- a/src/backend-dbus/CMakeLists.txt
+++ b/src/backend-dbus/CMakeLists.txt
@@ -49,11 +49,6 @@ add_gdbus_codegen (BACKEND_GENERATED_SOURCES desktop-session
set (SOURCES actions.c guest.c users.c backend-dbus.c utils.c)
-# add warnings/coverage info on handwritten files
-# but not the autogenerated ones...
-set_source_files_properties (${SOURCES}
- PROPERTIES COMPILE_FLAGS " -g ${CC_WARNING_ARGS} ${GCOV_FLAGS}")
-
# add the bin dir to our include path s.t. our code can find the autogenerated header files
include_directories (${CMAKE_CURRENT_BINARY_DIR} ${SERVICE_INCLUDE_DIRS})
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4bd5a8a..1e81bc2 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,10 +1,12 @@
+find_package(GMock)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie")
+
# build the necessary schemas
set_directory_properties (PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES gschemas.compiled)
set_source_files_properties (gschemas.compiled GENERATED)
-SET(COVERAGE_TEST_TARGETS "")
-
# GSettings:
# compile the schemas our tests use (ayatana-indicator-session's, lockdown, media-keys)
# into a gschemas.compiled file in this directory, and help the tests to find
@@ -33,7 +35,7 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR} ${SERVICE_INCLUDE_DIRS})
# backendmock
add_library (backendmock STATIC
- backend-mock-actions.c
+ backend-mock-actions.c
backend-mock-actions.h
backend-mock.c
backend-mock.h
@@ -41,7 +43,6 @@ add_library (backendmock STATIC
backend-mock-guest.h
backend-mock-users.c
backend-mock-users.h)
-set_target_properties (backendmock PROPERTIES COMPILE_FLAGS " ${CC_WARNING_ARGS} -g")
add_custom_target(
gschemas-compiled ALL DEPENDS gschemas.compiled
@@ -50,11 +51,9 @@ add_custom_target(
# test-service
add_executable (test-service
test-service.cc)
-set_target_properties (test-service PROPERTIES COMPILE_FLAGS " ${CC_WARNING_ARGS} -std=c++0x -g")
+set_target_properties (test-service PROPERTIES COMPILE_FLAGS " -std=c++0x")
add_test (test-service test-service)
add_dependencies (test-service libayatanaindicatorsessionservice backendmock gschemas-compiled)
-target_link_libraries (test-service libayatanaindicatorsessionservice backendmock gtest ${SERVICE_LIBRARIES} ${GTEST_LIBS})
-
-SET(COVERAGE_TEST_TARGETS "${COVERAGE_TEST_TARGETS} test-service")
+target_link_libraries (test-service libayatanaindicatorsessionservice backendmock ${SERVICE_LIBRARIES} ${GTEST_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARIES})
add_subdirectory (backend-dbus)
diff --git a/tests/backend-dbus/CMakeLists.txt b/tests/backend-dbus/CMakeLists.txt
index 83c0886..0589487 100644
--- a/tests/backend-dbus/CMakeLists.txt
+++ b/tests/backend-dbus/CMakeLists.txt
@@ -1,11 +1,4 @@
-# build libgtest
-add_library (gtest STATIC
- ${GTEST_SOURCE_DIR}/gtest-all.cc
- ${GTEST_SOURCE_DIR}/gtest_main.cc)
-set_target_properties (gtest PROPERTIES INCLUDE_DIRECTORIES
- ${GTEST_INCLUDE_DIR})
-
-SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -g ${CC_WARNING_ARGS}")
+SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
# build desktopmock
add_library (desktopmock STATIC
@@ -43,22 +36,16 @@ include_directories (${CMAKE_SOURCE_DIR}/tests)
add_executable (test-actions
test-actions.cc)
add_test (test-actions test-actions)
-set_tests_properties (test-actions PROPERTIES COMPILE_FLAGS "${SERVICE_CFLAGS}")
-target_link_libraries (test-actions desktopmock backenddbus libayatanaindicatorsessionservice gtest ${SERVICE_LDFLAGS} ${GTEST_LIBS} ${GCOV_LIBS})
-SET(COVERAGE_TEST_TARGETS "${COVERAGE_TEST_TARGETS} test-actions")
+target_link_libraries (test-actions desktopmock backenddbus libayatanaindicatorsessionservice ${SERVICE_LDFLAGS} ${GTEST_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARIES})
# test the Guest class
add_executable (test-guest
test-guest.cc)
add_test (test-guest test-guest)
-set_tests_properties (test-guest PROPERTIES COMPILE_FLAGS "${SERVICE_CFLAGS}")
-target_link_libraries (test-guest desktopmock backenddbus libayatanaindicatorsessionservice gtest ${SERVICE_LDFLAGS} ${GTEST_LIBS} ${GCOV_LIBS})
-SET(COVERAGE_TEST_TARGETS "${COVERAGE_TEST_TARGETS} test-guest")
+target_link_libraries (test-guest desktopmock backenddbus libayatanaindicatorsessionservice ${SERVICE_LDFLAGS} ${GTEST_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARIES})
# test the Users class
add_executable (test-users
test-users.cc)
add_test (test-users test-users)
-set_tests_properties (test-users PROPERTIES COMPILE_FLAGS "${SERVICE_CFLAGS}")
-target_link_libraries (test-users desktopmock backenddbus libayatanaindicatorsessionservice gtest ${SERVICE_LDFLAGS} ${GTEST_LIBS} ${GCOV_LIBS})
-SET(COVERAGE_TEST_TARGETS "${COVERAGE_TEST_TARGETS} test-users")
+target_link_libraries (test-users desktopmock backenddbus libayatanaindicatorsessionservice ${SERVICE_LDFLAGS} ${GTEST_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARIES})