cmake: refactor `add_clar_test` into separate module
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
diff --git a/ci/test.sh b/ci/test.sh
index ec21519..0815522 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -156,10 +156,6 @@ fi
# Run the tests that do not require network connectivity.
-if [ -z "$SKIP_UTILITY_TESTS" ]; then
- run_test util
-fi
-
if [ -z "$SKIP_OFFLINE_TESTS" ]; then
echo ""
echo "##############################################################################"
diff --git a/cmake/AddClarTest.cmake b/cmake/AddClarTest.cmake
new file mode 100644
index 0000000..7439416
--- /dev/null
+++ b/cmake/AddClarTest.cmake
@@ -0,0 +1,7 @@
+function(ADD_CLAR_TEST project name)
+ if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
+ add_test(${name} "${PROJECT_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
+ else()
+ add_test(${name} "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
+ endif()
+endfunction(ADD_CLAR_TEST)
diff --git a/tests/libgit2/CMakeLists.txt b/tests/libgit2/CMakeLists.txt
index 90ae625..27f421a 100644
--- a/tests/libgit2/CMakeLists.txt
+++ b/tests/libgit2/CMakeLists.txt
@@ -63,20 +63,13 @@ if(MSVC_IDE)
set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
endif()
-function(ADD_CLAR_TEST name)
- if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
- add_test(${name} "${PROJECT_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${PROJECT_BINARY_DIR}/libgit2_tests" ${ARGN})
- else()
- add_test(${name} "${PROJECT_BINARY_DIR}/libgit2_tests" ${ARGN})
- endif()
-endfunction(ADD_CLAR_TEST)
-
-add_clar_test(offline -v -xonline)
-add_clar_test(invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root)
-add_clar_test(online -v -sonline -xonline::customcert)
-add_clar_test(online_customcert -v -sonline::customcert)
-add_clar_test(gitdaemon -v -sonline::push)
-add_clar_test(ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
-add_clar_test(proxy -v -sonline::clone::proxy)
-add_clar_test(auth_clone -v -sonline::clone::cred)
-add_clar_test(auth_clone_and_push -v -sonline::clone::push -sonline::push)
+include(AddClarTest)
+add_clar_test(libgit2_tests offline -v -xonline)
+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)
+add_clar_test(libgit2_tests online -v -sonline -xonline::customcert)
+add_clar_test(libgit2_tests online_customcert -v -sonline::customcert)
+add_clar_test(libgit2_tests gitdaemon -v -sonline::push)
+add_clar_test(libgit2_tests ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
+add_clar_test(libgit2_tests proxy -v -sonline::clone::proxy)
+add_clar_test(libgit2_tests auth_clone -v -sonline::clone::cred)
+add_clar_test(libgit2_tests auth_clone_and_push -v -sonline::clone::push -sonline::push)
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index 739eb58..232590f 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -62,14 +62,7 @@ if(MSVC_IDE)
set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
endif()
-function(ADD_CLAR_TEST name)
- if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
- add_test(${name} "${libgit2_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${libgit2_BINARY_DIR}/util_tests" ${ARGN})
- else()
- add_test(${name} "${libgit2_BINARY_DIR}/util_tests" ${ARGN})
- endif()
-endfunction(ADD_CLAR_TEST)
-
enable_testing()
-add_clar_test(util -v)
+include(AddClarTest)
+add_clar_test(util_tests util -v)