Coverage but not OK: todo make lib with character_sheet to test it easily in coverage mode.

This commit is contained in:
Pcornat 2022-02-09 23:26:12 +01:00
parent 367d030ff1
commit 9e4e6fa226
Signed by: Pcornat
GPG Key ID: 2F3932FF46D9ECA0
3 changed files with 19 additions and 32 deletions

View File

@ -2,8 +2,9 @@
<project version="4">
<component name="CMakeSharedSettings">
<configurations>
<configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" />
<configuration PROFILE_NAME="Release" ENABLED="true" CONFIG_NAME="Release" />
<configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" GENERATION_OPTIONS="-G Ninja" />
<configuration PROFILE_NAME="Debug Coverage" ENABLED="true" CONFIG_NAME="Debug" GENERATION_OPTIONS="-G Ninja -DENABLE_COVERAGE=ON" />
<configuration PROFILE_NAME="Release" ENABLED="true" CONFIG_NAME="Release" GENERATION_OPTIONS="-G Ninja" />
</configurations>
</component>
</project>

View File

@ -102,7 +102,6 @@ option(CATCH_INSTALL_DOCS "Install documentation alongside library" OFF)
option(CATCH_INSTALL_EXTRAS "Install extras alongside library" OFF)
add_subdirectory(external/catch2)
add_subdirectory("Unit testing")
set(COMPILE_FLAGS
-pipe
@ -132,6 +131,17 @@ set(LINKER_FLAGS
jemalloc
)
option(ENABLE_COVERAGE "Enabling coverage" OFF)
if (${ENABLE_COVERAGE})
message(STATUS "Coverage enabled")
list(APPEND COMPILE_FLAGS --coverage)
list(APPEND LINKER_OPTIONS --coverage)
list(APPEND LINKER_FLAGS gcov)
endif ()
add_subdirectory("Unit testing")
add_executable(BillySheet ${SOURCES})
target_include_directories(BillySheet PRIVATE include include/imgui external/ImFileDialog)

View File

@ -2,33 +2,7 @@ cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
project(UnitTest CXX)
set(COMPILE_FLAGS
-pipe
-march=skylake # change to native or your architecture.
-mtune=skylake # same as above
-mrdseed # be careful about this, this is linked to the x86 architecture.
-mrdrnd # same as above
-Wall
-Wextra
-Wpedantic
# -Wpadded
-pedantic
-ffunction-sections
-fdata-sections
-fuse-ld=gold
-funroll-loops
-fdevirtualize-at-ltrans
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
)
set(LINKER_OPTIONS
-Wl,--sort-common,--as-needed,--gc-sections,--strip-all
-fuse-ld=gold
-fdevirtualize-at-ltrans
)
set(LINKER_FLAGS
jemalloc
)
include(../external/catch2/contrib/Catch.cmake)
add_executable(UnitTest adummy.cpp characteristics_tests.cpp)
@ -37,11 +11,13 @@ set_target_properties(Catch2 UnitTest PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
# UNITY_BUILD ON
# UNITY_BUILD ON
)
target_include_directories(UnitTest PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_compile_definitions(UnitTest PRIVATE ${DEF_COMP})
target_compile_options(UnitTest PRIVATE ${COMPILE_FLAGS})
target_link_options(UnitTest PRIVATE ${LINKER_OPTIONS})
target_link_libraries(UnitTest ${LINKER_FLAGS} Catch2 nlohmann_json::nlohmann_json)
enable_testing()
catch_discover_tests(UnitTest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} REPORTER junit OUTPUT_DIR ${CMAKE_SOURCE_DIR} OUTPUT_PREFIX cppspec- OUTPUT_SUFFIX .xml)