if (NOT MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_DEFAULT} -std=c99 -Wall -Wextra -pedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEFAULT} -std=c++11 -Wall -Wextra -pedantic") endif () include_directories(../include) set(SAMPLES signal.c report.c suites.c fixtures.c asserts.c more-suites.c description.c simple.c theories.c timeout.c redirect.c parameterized.c ) if (CMAKE_CXX_COMPILER_WORKS) set(SAMPLES ${SAMPLES} signal.cc report.cc suites.cc fixtures.cc asserts.cc more-suites.cc description.cc simple.cc theories.cc redirect.cc parameterized.cc ) endif () set(SCRIPTS tap_test xml_test json_test early_exit verbose list fail_fast help ) if (HAVE_PCRE) set(SCRIPTS ${SCRIPTS} pattern) endif () add_custom_target(criterion_samples) add_dependencies(criterion_tests criterion_samples) macro(add_samples DIR_ SAMPLES_) foreach(sample ${SAMPLES_}) add_executable(${sample}.bin EXCLUDE_FROM_ALL ${sample}) add_dependencies(criterion_samples ${sample}.bin) target_link_libraries(${sample}.bin criterion) add_test(${sample} ${sample}.bin) set_property(TEST ${sample} PROPERTY ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ENVIRONMENT "CRITERION_NO_EARLY_EXIT=1" # for coverage ) if (NOT MSVC) # we disable the scripted tests when building with MSVC add_test(${sample}_compare sh ${DIR_}/run_test.sh "${CMAKE_CURRENT_LIST_DIR}/outputs" . . ${sample}.bin) set_property(TEST ${sample}_compare PROPERTY ENVIRONMENT "LC_ALL=en_US.utf8" ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ENVIRONMENT "CRITERION_SHORT_FILENAME=1" ENVIRONMENT "CRITERION_NO_EARLY_EXIT=1" # for coverage ENVIRONMENT "CRITERION_JOBS=1" # for output ordering ENVIRONMENT "CRITERION_DISABLE_TIME_MEASUREMENTS=1" # do not compare timings ) endif () endforeach() endmacro() add_samples("${CMAKE_CURRENT_LIST_DIR}/tests" "${SAMPLES}") if (NOT MSVC) # we disable the scripted tests when building with MSVC foreach(script ${SCRIPTS}) add_test(${script} sh "${CMAKE_CURRENT_LIST_DIR}/tests/${script}.sh") set_property(TEST ${script} PROPERTY ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ENVIRONMENT "CRITERION_NO_EARLY_EXIT=1" # for coverage ) add_test(${script}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . "${CMAKE_CURRENT_LIST_DIR}" "tests/${script}.sh") set_property(TEST ${script}_compare PROPERTY ENVIRONMENT "LC_ALL=en_US.utf8" ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ENVIRONMENT "CRITERION_SHORT_FILENAME=1" ENVIRONMENT "CRITERION_NO_EARLY_EXIT=1" # for coverage ENVIRONMENT "CRITERION_JOBS=1" # for output ordering ) endforeach() endif() add_subdirectory(tests)