]> git.proxmox.com Git - libgit2.git/blame - tests/libgit2/CMakeLists.txt
Merge https://salsa.debian.org/debian/libgit2 into proxmox/bullseye
[libgit2.git] / tests / libgit2 / CMakeLists.txt
CommitLineData
ad5611d8
TR
1# tests: the unit and integration tests for libgit2
2
3set(Python_ADDITIONAL_VERSIONS 3 2.7)
4find_package(PythonInterp)
5
6if(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")
9ENDIF()
10
11set(CLAR_PATH "${PROJECT_SOURCE_DIR}/tests/clar")
12set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
13set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
14add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
15add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
16add_definitions(-DCLAR_WIN32_LONGPATHS)
17add_definitions(-D_FILE_OFFSET_BITS=64)
18
19# Ensure that we do not use deprecated functions internally
20add_definitions(-DGIT_DEPRECATE_HARD)
21
22set(TEST_INCLUDES "${CLAR_PATH}" "${TEST_PATH}" "${CMAKE_CURRENT_BINARY_DIR}")
23file(GLOB_RECURSE SRC_TEST ${TEST_PATH}/*/*.c ${TEST_PATH}/*/*.h)
24file(GLOB_RECURSE SRC_CLAR ${CLAR_PATH}/*.c ${CLAR_PATH}/*.h)
25
26if(MSVC_IDE)
27 list(APPEND SRC_TEST "precompiled.c")
28endif()
29
30add_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
37set_source_files_properties(
38 ${CLAR_PATH}/clar.c
39 PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
40
41add_executable(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
42
43set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90)
44set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
45
46target_include_directories(libgit2_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
47target_include_directories(libgit2_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
48target_link_libraries(libgit2_tests ${LIBGIT2_SYSTEM_LIBS})
49
50ide_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#
56if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
57 target_compile_options(libgit2_tests PRIVATE -include "clar_suite.h")
58endif()
59
60if(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")
64endif()
65
66include(AddClarTest)
67add_clar_test(libgit2_tests offline -v -xonline)
68add_clar_test(libgit2_tests invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root)
69add_clar_test(libgit2_tests online -v -sonline -xonline::customcert)
70add_clar_test(libgit2_tests online_customcert -v -sonline::customcert)
71add_clar_test(libgit2_tests gitdaemon -v -sonline::push)
72add_clar_test(libgit2_tests ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
73add_clar_test(libgit2_tests proxy -v -sonline::clone::proxy)
74add_clar_test(libgit2_tests auth_clone -v -sonline::clone::cred)
75add_clar_test(libgit2_tests auth_clone_and_push -v -sonline::clone::push -sonline::push)