cmake: handle also unit tests

The unit tests should also be available e.g. in Visual Studio's Test Explorer when configuring Git's source code via CMake. Suggested-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Sep 25, 2023 at 11:20 UTC 694e89baeb824a173b655507b7b62174d2d15688
1 file changed +11
contrib/buildsystems/CMakeLists.txt
+11
@@ -981,6 +981,17 @@ foreach(unit_test ${unit_test_PROGRAMS})
981 PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
982 endif()
983 list(APPEND PROGRAMS_BUILT "${unit_test}")
984 +
985 + # t-basic intentionally fails tests, to validate the unit-test infrastructure.
986 + # Therefore, it should only be run as part of t0080, which verifies that it
987 + # fails only in the expected ways.
988 + #
989 + # All other unit tests should be run.
990 + if(NOT ${unit_test} STREQUAL "t-basic")
991 + add_test(NAME "t.unit-tests.${unit_test}"
992 + COMMAND "./${unit_test}"
993 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t/unit-tests/bin)
994 + endif()
995 endforeach()
996
997 #test-tool