<commit_before># CMakeUnitRunner.cmake
#
# The main test runner for the CMakeUnit framework.
#
# Users should first call bootstrap_cmake_unit which will
# set up some necessary global variables. Tests are organized
# into test scripts (because CMake doesn't have the ability to
# refer to function names as variables and call them later).
#
# As a performance consideration, there are two types of tests,
# CMake tests and Build Tests.
#
# CMake tests should be added with add_cmake_test . These tests
# will only run cmake in script-execution mode on the specified
# script and check for success.
#
# Build tests are a superset of CMake tests. They will run cmake
# on the specified script, but also use cmake --build to build
# the resulting project and then run the verfication script
# specified in order to check that the build succeeded in the
# way that the user expected it to. Build tests can take
# much longer to execute and should be used sparingly.
#
# See LICENCE.md for Copyright information.

# bootstrap_cmake_unit:
#
# Defines some global variables for the CMakeUnit framework. Pass
# VARIABLES to forward those variables to tests.
include (CMakeParseArguments)
include (CTest)

enable_testing ()

option (CMAKE_UNIT_LOG_COVERAGE OFF
        "Log line hits to ${CMAKE_PROJECT_NAME}.trace")
option (CMAKE_UNIT_NO_DEV_WARNINGS OFF
        "Turn off developer warnings")
option (CMAKE_UNIT_NO_UNINITIALIZED_WARNINGS OFF
        "Turn off uninitialized variable usage warnings")

if (CMAKE_UNIT_LOG_COVERAGE)

    set (CMAKE_UNIT_COVERAGE_FILE
         "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.trace")

endif (CMAKE_UNIT_LOG_COVERAGE)

# bootstrap_cmake_unit
#
# Sets up the initial environment to use cmake-unit. Call this function
# before calling add_cmake_test or add_cmake_build_test.
#
# VARIABLES: A list of variables to "forward" on to the tests with the same
#            value that they have at the time of calling bootstrap_cmake_unit
# COVERAGE_FILES: A list of full absolute paths to files which should
#                 be tracked for code coverage.
function (bootstrap_cmake_unit)

    set (BOOTSTRAP_MULTIVAR_ARGS VARIABLES COVERAGE_FILES)

    cmake_parse_arguments (BOOTSTRAP
                           ""
                           ""
                           "${BOOTSTRAP_MULTIVAR_ARGS}"
                           ${ARGN})

    # Put variables we want to forward to the tests into their cache
    foreach (VAR ${BOOTSTRAP_VARIABLES})

        get_property (TYPE
                      CACHE ${VAR}
                      PROPERTY TYPE)

        if (NOT TYPE STREQUAL "STRING" OR
            NOT TYPE STREQUAL "BOOL" OR
            NOT TYPE STREQUAL "PATH" OR
            NOT TYPE STREQUAL "FILEPATH")

            # If the variable is not part of the "public" cache, then
            # we can still forward it, but we need to set a type of "STRING"
            set (TYPE STRING)

        endif (NOT TYPE STREQUAL "STRING" OR
               NOT TYPE STREQUAL "BOOL" OR
               NOT TYPE STREQUAL "PATH" OR
               NOT TYPE STREQUAL "FILEPATH")

        # This needs to be squeezed all on to one line so that we don't get
        # semicolonization from having multiple strings in the set () command
        set (ICC "${ICC}set (${VAR} \"${${VAR}}\" CACHE ${TYPE} \"\" FORCE)\n")

    endforeach ()

    # Escape semicolons
    string (REPLACE ";" "/;" ICC "${ICC}")
    set (_CMAKE_UNIT_INITIAL_CACHE_CONTENTS "${ICC}" PARENT_SCOPE)

    if (CMAKE_UNIT_LOG_COVERAGE)

        set (_CMAKE_UNIT_COVERAGE_LOGGING_FILES
             ${BOOTSTRAP_COVERAGE_FILES} PARENT_SCOPE)<commit_msg>Escape special regex characters from filenames.<commit_after># CMakeUnitRunner.cmake
#
# The main test runner for the CMakeUnit framework.
#
# Users should first call bootstrap_cmake_unit which will
# set up some necessary global variables. Tests are organized
# into test scripts (because CMake doesn't have the ability to
# refer to function names as variables and call them later).
#
# As a performance consideration, there are two types of tests,
# CMake tests and Build Tests.
#
# CMake tests should be added with add_cmake_test . These tests
# will only run cmake in script-execution mode on the specified
# script and check for success.
#
# Build tests are a superset of CMake tests. They will run cmake
# on the specified script, but also use cmake --build to build
# the resulting project and then run the verfication script
# specified in order to check that the build succeeded in the
# way that the user expected it to. Build tests can take
# much longer to execute and should be used sparingly.
#
# See LICENCE.md for Copyright information.

# bootstrap_cmake_unit:
#
# Defines some global variables for the CMakeUnit framework. Pass
# VARIABLES to forward those variables to tests.
include (CMakeParseArguments)
include (CTest)

enable_testing ()

option (CMAKE_UNIT_LOG_COVERAGE OFF
        "Log line hits to ${CMAKE_PROJECT_NAME}.trace")
option (CMAKE_UNIT_NO_DEV_WARNINGS OFF
        "Turn off developer warnings")
option (CMAKE_UNIT_NO_UNINITIALIZED_WARNINGS OFF
        "Turn off uninitialized variable usage warnings")

if (CMAKE_UNIT_LOG_COVERAGE)

    set (CMAKE_UNIT_COVERAGE_FILE
         "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.trace")

endif (CMAKE_UNIT_LOG_COVERAGE)

# bootstrap_cmake_unit
#
# Sets up the initial environment to use cmake-unit. Call this function
# before calling add_cmake_test or add_cmake_build_test.
#
# VARIABLES: A list of variables to "forward" on to the tests with the same
#            value that they have at the time of calling bootstrap_cmake_unit
# COVERAGE_FILES: A list of full absolute paths to files which should
#                 be tracked for code coverage.
function (bootstrap_cmake_unit)

    set (BOOTSTRAP_MULTIVAR_ARGS VARIABLES COVERAGE_FILES)

    cmake_parse_arguments (BOOTSTRAP
                           ""
                           ""
                           "${BOOTSTRAP_MULTIVAR_ARGS}"
                           ${ARGN})

    # Put variables we want to forward to the tests into their cache
    foreach (VAR ${BOOTSTRAP_VARIABLES})

        get_property (TYPE
                      CACHE ${VAR}
                      PROPERTY TYPE)

        if (NOT TYPE STREQUAL "STRING" OR
            NOT TYPE STREQUAL "BOOL" OR
            NOT TYPE STREQUAL "PATH" OR
            NOT TYPE STREQUAL "FILEPATH")

            # If the variable is not part of the "public" cache, then
            # we can still forward it, but we need to set a type of "STRING"
            set (TYPE STRING)

        endif (NOT TYPE STREQUAL "STRING" OR
               NOT TYPE STREQUAL "BOOL" OR
               NOT TYPE STREQUAL "PATH" OR
               NOT TYPE STREQUAL "FILEPATH")

        # This needs to be squeezed all on to one line so that we don't get
        # semicolonization from having multiple strings in the set () command
        set (ICC "${ICC}set (${VAR} \"${${VAR}}\" CACHE ${TYPE} \"\" FORCE)\n")

    endforeach ()

    # Escape semicolons
    string (REPLACE ";" "/;" ICC "${ICC}")
    set (_CMAKE_UNIT_INITIAL_CACHE_CONTENTS "${ICC}" PARENT_SCOPE)

    if (CMAKE_UNIT_LOG_COVERAGE)

        # Escape characters out of filenames that will cause problems when
        # attempting to regex match them later
        foreach (COVERAGE_FILE ${BOOTSTRAP_COVERAGE_FILES})

            string (REPLACE "\\" "/" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "(" "\\(" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE ")" "\\)" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "[" "\\[" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "]" "\\]" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "*" "\\*" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "+" "\\+" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "$" "\\$" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "^" "\\^" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "}" "\\}" COVERAGE_FILE "${COVERAGE_FILE}")
            string (REPLACE "{" "\\{" COVERAGE_FILE "${COVERAGE_FILE}")

            list (APPEND ESCAPED_COVERAGE_FILES "${COVERAGE_FILE}")

        endforeach ()

        set (_CMAKE_UNIT_COVERAGE_LOGGING_FILES
             ${ESCAPED_COVERAGE_FILES} PARENT_SCOPE)
{'fraction_non_alphanumeric': 0.0777127850065656, 'fraction_numerical': 0.0, 'mean_word_length': 2.809913597089586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3353900', 'n_tokens_mistral': 2529, 'n_tokens_neox': 2406, 'n_words': 894}