ci: run test in CI
+ Add CODE_COVERAGE option to be able to generate coverage reports
via gcov/lcov
+ CMake now fails if run build.py with an error status
+ Dockerfile now uses dependencies from contrib as specified in the
documentation
+ Add Jenkinsfile to run tests
+ Fix tests_fileUtils (removeAll return 0 if directory doesn't exists)
+ Disable test with sporadic failures, this needs to be fixed.
GitLab: #3
Change-Id: I7e6dd20c69ffa5900de56a1586f57603040bba73
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce1b59d..fc11e05 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,18 @@
option(BUILD_DEPENDENCIES "Build dependencies" ON)
option (DNC_SYSTEMD_UNIT_FILE_LOCATION "Where to install systemd unit file")
option(DNC_SYSTEMD "Enable dnc systemd integration" ON)
+option(CODE_COVERAGE "Enable coverage reporting" OFF)
+
+# Check if testing is enabled
+if(BUILD_TESTING)
+ if(CODE_COVERAGE)
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+ # Add the flags for coverage
+ add_compile_options(-fprofile-arcs -ftest-coverage --coverage -O0)
+ link_libraries(--coverage)
+ endif()
+ endif()
+endif()
if (NOT MSVC)
set(DEPENDENCIES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/install/${TARGET})
@@ -35,7 +47,11 @@
execute_process(
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/build.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dependencies
+ RESULT_VARIABLE BUILD_RESULT
)
+ if (BUILD_RESULT)
+ message(FATAL_ERROR "Failed to execute build.py script.")
+ endif()
endif()
include (GNUInstallDirs)
list(APPEND CMAKE_FIND_ROOT_PATH ${DEPENDENCIES_PATH})