|
1 | | -# tests: the unit and integration tests for libgit2 |
| 1 | +# The main libgit2 tests tree: this CMakeLists.txt includes the |
| 2 | +# subprojects that make up core libgit2 support. |
2 | 3 |
|
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_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/resources/") |
12 | | -set(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}") |
13 | | -add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\") |
14 | | -add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\") |
15 | | -add_definitions(-DCLAR_WIN32_LONGPATHS) |
16 | | -add_definitions(-D_FILE_OFFSET_BITS=64) |
17 | | - |
18 | | -# Ensure that we do not use deprecated functions internally |
19 | | -add_definitions(-DGIT_DEPRECATE_HARD) |
20 | | - |
21 | | -set(TEST_INCLUDES "${CLAR_PATH}" "${CMAKE_CURRENT_BINARY_DIR}") |
22 | | -file(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h) |
23 | | -set(SRC_CLAR "main.c" "clar_libgit2.c" "clar_libgit2_trace.c" "clar_libgit2_timer.c" "clar.c") |
24 | | - |
25 | | -if(MSVC_IDE) |
26 | | - list(APPEND SRC_CLAR "precompiled.c") |
27 | | -endif() |
28 | | - |
29 | | -add_custom_command( |
30 | | - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h |
31 | | - COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf . |
32 | | - DEPENDS ${SRC_TEST} |
33 | | - WORKING_DIRECTORY ${CLAR_PATH} |
34 | | -) |
35 | | - |
36 | | -set_source_files_properties( |
37 | | - ${CLAR_PATH}/clar.c |
38 | | - PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite) |
39 | | - |
40 | | -add_executable(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS}) |
41 | | - |
42 | | -set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90) |
43 | | -set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) |
44 | | - |
45 | | -target_include_directories(libgit2_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES}) |
46 | | -target_include_directories(libgit2_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES}) |
47 | | -target_link_libraries(libgit2_tests ${LIBGIT2_SYSTEM_LIBS}) |
48 | | - |
49 | | -ide_split_sources(libgit2_tests) |
50 | | - |
51 | | -# |
52 | | -# Old versions of gcc require us to declare our test functions; don't do |
53 | | -# this on newer compilers to avoid unnecessary recompilation. |
54 | | -# |
55 | | -if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) |
56 | | - target_compile_options(libgit2_tests PRIVATE -include "clar_suite.h") |
57 | | -endif() |
58 | | - |
59 | | -if(MSVC_IDE) |
60 | | - # Precompiled headers |
61 | | - set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") |
62 | | - set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h") |
63 | | -endif() |
64 | | - |
65 | | -function(ADD_CLAR_TEST name) |
66 | | - if(NOT USE_LEAK_CHECKER STREQUAL "OFF") |
67 | | - add_test(${name} "${PROJECT_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${PROJECT_BINARY_DIR}/libgit2_tests" ${ARGN}) |
68 | | - else() |
69 | | - add_test(${name} "${PROJECT_BINARY_DIR}/libgit2_tests" ${ARGN}) |
70 | | - endif() |
71 | | -endfunction(ADD_CLAR_TEST) |
72 | | - |
73 | | -add_clar_test(offline -v -xonline) |
74 | | -add_clar_test(invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root) |
75 | | -add_clar_test(online -v -sonline -xonline::customcert) |
76 | | -add_clar_test(online_customcert -v -sonline::customcert) |
77 | | -add_clar_test(gitdaemon -v -sonline::push) |
78 | | -add_clar_test(ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh) |
79 | | -add_clar_test(proxy -v -sonline::clone::proxy) |
80 | | -add_clar_test(auth_clone -v -sonline::clone::cred) |
81 | | -add_clar_test(auth_clone_and_push -v -sonline::clone::push -sonline::push) |
82 | | - |
83 | | -# |
84 | | -# Header file validation project: ensure that we do not publish any sloppy |
85 | | -# definitions in our headers and that a consumer can include <git2.dll> |
86 | | -# even when they have aggressive C90 warnings enabled. |
87 | | -# |
88 | | - |
89 | | -add_executable(headertest headertest.c) |
90 | | -set_target_properties(headertest PROPERTIES C_STANDARD 90) |
91 | | -set_target_properties(headertest PROPERTIES C_EXTENSIONS OFF) |
92 | | -target_include_directories(headertest PRIVATE ${LIBGIT2_INCLUDES}) |
93 | | - |
94 | | -if (MSVC) |
95 | | - target_compile_options(headertest PUBLIC /W4 /WX) |
96 | | -else() |
97 | | - target_compile_options(headertest PUBLIC -Wall -Wextra -pedantic -Werror) |
98 | | -endif() |
| 4 | +add_subdirectory(libgit2) |
0 commit comments