<commit_before># Copyright (C) 2013 <NAME> <<EMAIL>>

include(ParseArguments)

macro(contain_test test_name)
    parse_arguments(ARGS "TEST" "" ${ARGN})
    set(TEST_ENV "")
    foreach(VARIABLE XDG_DATA_HOME XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_RUNTIME_DIR TMPDIR)
        set(CONTAINER "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-folders/${VARIABLE}")
        file(REMOVE_RECURSE ${CONTAINER})
        file(MAKE_DIRECTORY ${CONTAINER})
        set(TEST_ENV "${TEST_ENV}${VARIABLE}=${CONTAINER};")
    endforeach()
    set_tests_properties(${test_name} PROPERTIES
                         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
                         TIMEOUT 42
                         ENVIRONMENT "${TEST_ENV}"
                         )

    add_custom_target("gdb-${test_name}"
        COMMAND env ${TEST_ENV} gdb
        --batch -ex 'set print thread-events off'
        -ex 'run' -ex 'bt'
        ${CMAKE_BINARY_DIR}/tests/${UNIT}
        )

    add_custom_target("valgrind-${test_name}"
        COMMAND env ${TEST_ENV} valgrind
        -q --leak-check=no --num-callers=4
        --show-possibly-lost=no
        --undef-value-errors=yes
        --track-origins=yes
        ${CMAKE_BINARY_DIR}/tests/${UNIT}
        )

    add_custom_target("callgrind-${test_name}"
        COMMAND env ${TEST_ENV} valgrind
        --tool=callgrind
        --callgrind-out-file=${UNIT}.callgrind
        ${CMAKE_BINARY_DIR}/tests/${UNIT}
        )
endmacro(contain_test)<commit_msg>Use dependencies to clear test folders before execution<commit_after># Copyright (C) 2013 <NAME> <<EMAIL>>

include(ParseArguments)

macro(contain_test test_name)
    parse_arguments(ARGS "TEST" "" ${ARGN})
    set(TEST_ENV "")
    foreach(VARIABLE XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_RUNTIME_DIR TMPDIR)
        set(CONTAINER "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-folders/${VARIABLE}")
        set(TEST_ENV "${TEST_ENV}${VARIABLE}=${CONTAINER};")
    endforeach()

    add_dependencies(check contain-${test_name})

    set_tests_properties(${test_name} PROPERTIES
                         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
                         TIMEOUT 42
                         ENVIRONMENT "${TEST_ENV}"
                         )
    add_custom_target("contain-${test_name}"
        COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_name}-folders
        COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_name}-folders/XDG_CONFIG_HOME
        COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_name}-folders/XDG_CACHE_HOME
        COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_name}-folders/XDG_DATA_HOME
        COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_name}-folders/XDG_RUNTIME_DIR
        COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_name}-folders/TMPDIR
        )

    add_custom_target("gdb-${test_name}"
        COMMAND env ${TEST_ENV} gdb
        --batch -ex 'set print thread-events off'
        -ex 'run' -ex 'bt'
        ${CMAKE_BINARY_DIR}/tests/${UNIT}
        DEPENDS "contain-${test_name}"
        )

    add_custom_target("valgrind-${test_name}"
        COMMAND env ${TEST_ENV} valgrind
        -q --leak-check=no --num-callers=4
        --show-possibly-lost=no
        --undef-value-errors=yes
        --track-origins=yes
        ${CMAKE_BINARY_DIR}/tests/${UNIT}
        DEPENDS "contain-${test_name}"
        )

    add_custom_target("callgrind-${test_name}"
        COMMAND env ${TEST_ENV} valgrind
        --tool=callgrind
        --callgrind-out-file=${UNIT}.callgrind
        ${CMAKE_BINARY_DIR}/tests/${UNIT}
        DEPENDS "contain-${test_name}"
        )
endmacro(contain_test)
{'fraction_non_alphanumeric': 0.1275980005261773, 'fraction_numerical': 0.003683241252302026, 'mean_word_length': 2.805805805805806, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2062985', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1274, 'n_words': 188}