1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
# To get verbose output: cmake --build build --target "test" -- ARGS='-V'
# By default, we run the spec tests only if python3 is available.
# To require the spec tests, compile with -DSPEC_TESTS=1
if(SPEC_TESTS)
set(PYTHON_REQUIRED REQUIRED)
else()
set(PYTHON_REQUIRED)
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
find_package(Python3 ${PYTHON_REQUIRED} COMPONENTS Interpreter)
else()
find_package(PythonInterp 3 ${PYTHON_REQUIRED})
set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND})
add_executable(Python3::Interpreter IMPORTED)
set_target_properties(Python3::Interpreter PROPERTIES
IMPORTED_LOCATION ${PYTHON_EXECUTABLE})
endif()
if(Python3_Interpreter_FOUND)
add_test(NAME html_normalization
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "-m" "doctest" "${CMAKE_CURRENT_SOURCE_DIR}/normalize.py")
if(BUILD_SHARED_LIBS)
add_test(NAME spectest_library
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py"
--no-normalize
--spec "${CMAKE_CURRENT_SOURCE_DIR}/spec.txt"
--library-dir "$<TARGET_FILE_DIR:libcmark-gfm>")
add_test(NAME pathological_tests_library
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/pathological_tests.py"
--library-dir "$<TARGET_FILE_DIR:libcmark-gfm>")
add_test(NAME roundtriptest_library
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/roundtrip_tests.py"
--spec "${CMAKE_CURRENT_SOURCE_DIR}/spec.txt"
--library-dir "$<TARGET_FILE_DIR:libcmark-gfm>")
add_test(NAME entity_library
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/entity_tests.py"
--library-dir "$<TARGET_FILE_DIR:libcmark-gfm>")
endif()
add_test(NAME spectest_executable
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py"
--no-normalize
--spec "${CMAKE_CURRENT_SOURCE_DIR}/spec.txt"
--program "$<TARGET_FILE:cmark-gfm>")
add_test(NAME smartpuncttest_executable
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py"
--no-normalize
--spec "${CMAKE_CURRENT_SOURCE_DIR}/smart_punct.txt"
--program "$<TARGET_FILE:cmark-gfm> --smart")
add_test(NAME extensions_executable
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py"
--no-normalize
--spec "${CMAKE_CURRENT_SOURCE_DIR}/extensions.txt"
--program "$<TARGET_FILE:cmark-gfm>"
--extensions "table strikethrough autolink tagfilter footnotes tasklist")
add_test(NAME roundtrip_extensions_executable
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/roundtrip_tests.py"
--spec "${CMAKE_CURRENT_SOURCE_DIR}/extensions.txt"
--program "$<TARGET_FILE:cmark-gfm>"
--extensions "table strikethrough autolink tagfilter footnotes tasklist")
add_test(NAME option_table_prefer_style_attributes
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/roundtrip_tests.py"
--spec "${CMAKE_CURRENT_SOURCE_DIR}/extensions-table-prefer-style-attributes.txt"
--program "$<TARGET_FILE:cmark-gfm> --table-prefer-style-attributes"
--extensions "table strikethrough autolink tagfilter footnotes tasklist")
add_test(NAME option_full_info_string
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/roundtrip_tests.py"
--spec "${CMAKE_CURRENT_SOURCE_DIR}/extensions-full-info-string.txt"
--program "$<TARGET_FILE:cmark-gfm> --full-info-string")
add_test(NAME regressiontest_executable
COMMAND "$<TARGET_FILE:Python3::Interpreter>" "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py"
--no-normalize
--spec "${CMAKE_CURRENT_SOURCE_DIR}/regression.txt"
--program "$<TARGET_FILE:cmark-gfm>")
else(Python3_Interpreter_FOUND)
message(WARNING "A python 3 interpreter is required to run the spec tests")
endif(Python3_Interpreter_FOUND)
if(CMARK_LIB_FUZZER)
add_executable(cmark-fuzz cmark-fuzz.c)
target_link_libraries(cmark-fuzz PRIVATE
libcmark-gfm_static
"${CMAKE_LIB_FUZZER_PATH}")
# cmark is written in C but the libFuzzer runtime is written in C++ which
# needs to link against the C++ runtime.
set_target_properties(cmark-fuzz PROPERTIES
LINKER_LANGUAGE CXX)
endif()
|