]>
Commit | Line | Data |
---|---|---|
ad5611d8 TR |
1 | # tests: the unit and integration tests for libgit2 |
2 | ||
3 | set(Python_ADDITIONAL_VERSIONS 3 2.7) | |
4 | find_package(PythonInterp) | |
5 | ||
6 | if(NOT PYTHONINTERP_FOUND) | |
7 | message(FATAL_ERROR "Could not find a python interpreter, which is needed to build the tests. " | |
8 | "Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests") | |
9 | ENDIF() | |
10 | ||
11 | set(CLAR_PATH "${PROJECT_SOURCE_DIR}/tests/clar") | |
12 | set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/") | |
13 | set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}") | |
14 | add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\") | |
15 | add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\") | |
16 | add_definitions(-DCLAR_WIN32_LONGPATHS) | |
17 | add_definitions(-D_FILE_OFFSET_BITS=64) | |
18 | ||
19 | # Ensure that we do not use deprecated functions internally | |
20 | add_definitions(-DGIT_DEPRECATE_HARD) | |
21 | ||
22 | set(TEST_INCLUDES "${CLAR_PATH}" "${TEST_PATH}" "${CMAKE_CURRENT_BINARY_DIR}") | |
23 | file(GLOB_RECURSE SRC_TEST ${TEST_PATH}/*/*.c ${TEST_PATH}/*/*.h) | |
24 | file(GLOB_RECURSE SRC_CLAR ${CLAR_PATH}/*.c ${CLAR_PATH}/*.h) | |
25 | ||
26 | if(MSVC_IDE) | |
27 | list(APPEND SRC_TEST "precompiled.c") | |
28 | endif() | |
29 | ||
30 | add_custom_command( | |
31 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h | |
32 | COMMAND ${PYTHON_EXECUTABLE} ${CLAR_PATH}/generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf . | |
33 | DEPENDS ${SRC_TEST} | |
34 | WORKING_DIRECTORY ${TEST_PATH} | |
35 | ) | |
36 | ||
37 | set_source_files_properties( | |
38 | ${CLAR_PATH}/clar.c | |
39 | PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite) | |
40 | ||
41 | add_executable(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS}) | |
42 | ||
43 | set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90) | |
44 | set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) | |
45 | ||
46 | target_include_directories(libgit2_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES}) | |
47 | target_include_directories(libgit2_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES}) | |
48 | target_link_libraries(libgit2_tests ${LIBGIT2_SYSTEM_LIBS}) | |
49 | ||
50 | ide_split_sources(libgit2_tests) | |
51 | ||
52 | # | |
53 | # Old versions of gcc require us to declare our test functions; don't do | |
54 | # this on newer compilers to avoid unnecessary recompilation. | |
55 | # | |
56 | if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) | |
57 | target_compile_options(libgit2_tests PRIVATE -include "clar_suite.h") | |
58 | endif() | |
59 | ||
60 | if(MSVC_IDE) | |
61 | # Precompiled headers | |
62 | set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") | |
63 | set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h") | |
64 | endif() | |
65 | ||
66 | include(AddClarTest) | |
67 | add_clar_test(libgit2_tests offline -v -xonline) | |
68 | add_clar_test(libgit2_tests invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root) | |
69 | add_clar_test(libgit2_tests online -v -sonline -xonline::customcert) | |
70 | add_clar_test(libgit2_tests online_customcert -v -sonline::customcert) | |
71 | add_clar_test(libgit2_tests gitdaemon -v -sonline::push) | |
72 | add_clar_test(libgit2_tests ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh) | |
73 | add_clar_test(libgit2_tests proxy -v -sonline::clone::proxy) | |
74 | add_clar_test(libgit2_tests auth_clone -v -sonline::clone::cred) | |
75 | add_clar_test(libgit2_tests auth_clone_and_push -v -sonline::clone::push -sonline::push) |