<commit_before># From <NAME>
#
# lcov.cmake
# `ctest -S lcov.cmake`

#if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
#    message(FATAL_ERROR "LCOV is Linux-only")
#endif(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")

include(ProcessorCount)
ProcessorCount(N)

set(CTEST_PROJECT_NAME CoverageProject)
set(CTEST_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
set(CTEST_BINARY_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/build)
set(CTEST_CMAKE_GENERATOR "Ninja")
set(CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind)

set(LCOV_OUT "${CTEST_BINARY_DIRECTORY}/lcov_html")

ctest_start(lcov)
#ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
message("configuring...")
#ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS "-DCMAKE_CXX_FLAGS=-fprofile-arcs -ftest-coverage;-DCMAKE_BUILD_TYPE=debug")
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS "-DTESTS:BOOL=ON;-DCMAKE_CXX_FLAGS=-fprofile-arcs -ftest-coverage;-DCMAKE_BUILD_TYPE=Debug")
#execute_process(COMMAND cmake -G Ninja -DTESTS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug ..)
message("lcov: resetting counters...")
execute_process(COMMAND lcov -z -d ${CTEST_BINARY_DIRECTORY}
        WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET)

message("building...")
#ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" FLAGS -j${N} TARGET tests)
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" FLAGS -j${N})


message("running tests...")
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL ${N})

message("analyzing profiling data using lcov...")
execute_process(COMMAND lcov -c -d ${CTEST_BINARY_DIRECTORY} -o ${CTEST_BINARY_DIRECTORY}/stepcode.lcov
        WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET)

message("removing system headers, CGAL, Boost, TBB, docopt, date ...")
execute_process(COMMAND lcov -r ${CTEST_BINARY_DIRECTORY}/stepcode.lcov "*/usr/include" "*/usr/include/*" "*CGAL*" "*CGAL/*" "*boost*" "*boost/*" "*tbb*" "*tbb/*" "*/src/date/*" "*/docopt*"
        -o ${CTEST_BINARY_DIRECTORY}/stepcode_filtered.lcov
        WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${LCOV_OUT})

message("creating html files...")
execute_process(COMMAND genhtml ${CTEST_BINARY_DIRECTORY}/stepcode_filtered.lcov
        WORKING_DIRECTORY ${LCOV_OUT} OUTPUT_QUIET)

message("html files are located in ${LCOV_OUT}/index.html")

message("================================================ Success! ================================================")<commit_msg>Ignore test coverage on */test/*, since tests can't test themselves.<commit_after># From <NAME>
#
# lcov.cmake
# `ctest --quiet -S lcov.cmake`

include(ProcessorCount)
ProcessorCount(N)

set(CTEST_PROJECT_NAME CoverageProject)
set(CTEST_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
set(CTEST_BINARY_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/build)
set(CTEST_CMAKE_GENERATOR "Ninja")
#set(CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind)

set(LCOV_OUT "${CTEST_BINARY_DIRECTORY}/lcov_html")

ctest_start(lcov)
message("configuring...")
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS "-DTESTS:BOOL=ON;-DCMAKE_CXX_FLAGS=-fprofile-arcs -ftest-coverage;-DCMAKE_BUILD_TYPE=Debug")
message("lcov: resetting counters...")
execute_process(COMMAND lcov -z -d ${CTEST_BINARY_DIRECTORY}
        WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET)

message("building...")
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" FLAGS -j${N})


message("running tests...")
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL ${N})

message("analyzing profiling data using lcov...")
execute_process(COMMAND lcov -c -d ${CTEST_BINARY_DIRECTORY} -o ${CTEST_BINARY_DIRECTORY}/stepcode.lcov
        WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET)

message("removing system headers, CGAL, Boost, TBB, docopt, date, test ...")
execute_process(COMMAND lcov -r ${CTEST_BINARY_DIRECTORY}/stepcode.lcov "*/usr/include" "*/usr/include/*" "*CGAL*" "*CGAL/*" "*boost*" "*boost/*" "*tbb*" "*tbb/*" "*/src/date/*" "*/docopt*" "*/test/*"
        -o ${CTEST_BINARY_DIRECTORY}/stepcode_filtered.lcov
        WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${LCOV_OUT})

message("creating html files...")
execute_process(COMMAND genhtml ${CTEST_BINARY_DIRECTORY}/stepcode_filtered.lcov
        WORKING_DIRECTORY ${LCOV_OUT} OUTPUT_QUIET)

message("html files are located in ${LCOV_OUT}/index.html")

message("================================================ Success! ================================================")
{'fraction_non_alphanumeric': 0.18227792436235707, 'fraction_numerical': 0.0, 'mean_word_length': 7.377532228360957, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3037507', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1601, 'n_words': 270}