Tests: add live integration test (optional via PRIVATEBIN_IT), fix WinHTTP host/port + TLS opts, robust JSON parser (meta.time_to_live), CTest wiring; Add LLVM/clang-cl coverage option and docs; add build_thinkpad.bat; README updates
This commit is contained in:
@@ -64,4 +64,49 @@ install(TARGETS privatebinapi
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
install(FILES ${HEADERS} DESTINATION include/privatebinapi)
|
||||
install(FILES ${HEADERS} DESTINATION include/privatebinapi)
|
||||
|
||||
# Tests
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
|
||||
# ===================== LLVM/clang-cl Coverage (optional) =====================
|
||||
option(ENABLE_LLVM_COVERAGE "Enable LLVM/clang-cl coverage instrumentation" OFF)
|
||||
|
||||
if(ENABLE_LLVM_COVERAGE)
|
||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
message(FATAL_ERROR "ENABLE_LLVM_COVERAGE requires clang/clang-cl as compiler (CMAKE_CXX_COMPILER_ID=Clang)")
|
||||
endif()
|
||||
|
||||
# Instrumentation flags
|
||||
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
||||
add_link_options(-fprofile-instr-generate)
|
||||
|
||||
# Helper variables for report tools (can be overridden from environment)
|
||||
set(LLVM_PROFDATA "llvm-profdata" CACHE STRING "Path to llvm-profdata")
|
||||
set(LLVM_COV "llvm-cov" CACHE STRING "Path to llvm-cov")
|
||||
|
||||
# Custom target to run tests and produce coverage report
|
||||
# Usage: cmake --build build --target coverage_llvm --config Release
|
||||
add_custom_target(
|
||||
coverage_llvm
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
LLVM_PROFILE_FILE=${CMAKE_BINARY_DIR}/coverage/%p-%m.profraw
|
||||
ctest -C $<IF:$<CONFIG:>,${CMAKE_BUILD_TYPE},$<CONFIG>> --output-on-failure
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/coverage
|
||||
COMMAND ${LLVM_PROFDATA} merge -sparse ${CMAKE_BINARY_DIR}/coverage/*.profraw -o ${CMAKE_BINARY_DIR}/coverage/merged.profdata
|
||||
COMMAND ${LLVM_COV} report
|
||||
$<TARGET_FILE:privatebinapi>
|
||||
--instr-profile=${CMAKE_BINARY_DIR}/coverage/merged.profdata
|
||||
--ignore-filename-regex="(vcpkg|external|CMakeFiles)"
|
||||
COMMAND ${LLVM_COV} show
|
||||
$<TARGET_FILE:privatebinapi>
|
||||
--instr-profile=${CMAKE_BINARY_DIR}/coverage/merged.profdata
|
||||
--ignore-filename-regex="(vcpkg|external|CMakeFiles)"
|
||||
--format=html
|
||||
--output-dir=${CMAKE_BINARY_DIR}/coverage/html
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
DEPENDS privatebinapi
|
||||
)
|
||||
endif()
|
||||
Reference in New Issue
Block a user