Skip to content

Commit

Permalink
Merge pull request #5 from marlinprotocol/roshan/coverage
Browse files Browse the repository at this point in the history
Enable code coverage
  • Loading branch information
roshanrags authored Jul 8, 2020
2 parents 789bb71 + f61e4a6 commit ba4e2f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ project(marlin VERSION 0.0.1 LANGUAGES CXX)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

add_subdirectory(vendor EXCLUDE_FROM_ALL)

if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(--coverage)
add_link_options(--coverage)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/coverage)
add_custom_target(coverage
COMMAND gcovr -r ${CMAKE_CURRENT_SOURCE_DIR} --gcov-executable 'llvm-cov gcov' --html-details ${CMAKE_CURRENT_BINARY_DIR}/coverage/index.html -e '.*/?vendor/.*' -e '.*/?build/.*' -e '.*/examples/.*'
)
endif()

enable_testing()
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
Expand Down
7 changes: 7 additions & 0 deletions core/test/testBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

using namespace marlin::core;

namespace marlin {
namespace core {
// Explicit instantiation hack for accurate coverage of templates
template class BaseBuffer<Buffer>;
}
}

TEST(BufferConstruct, SizeConstructible) {
auto buf = Buffer(1400);

Expand Down

0 comments on commit ba4e2f9

Please sign in to comment.