Skip to contentSkip to conversation

cmake: let `test-tool` run the unit tests, too

PATCH In review Johannes Schindelin via GitGitGadget 2 participants 2 messages Feb 15, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmake: let `test-tool` run the unit tests, too

From: Johannes Schindelin <[email protected]>

The test-tool recently learned to run the unit tests. To this end, it needs to link with test-lib.c, which was done in the Makefile, and this patch does it in the CMake definition, too.

This is a companion of 44400f58407e (t0080: turn t-basic unit test into a helper, 2024-02-02).

---
cmake: let test-tool run the unit tests, too

The test-tool recently learned to run the unit tests. To this end, it needs to link with test-lib.c, which was done in the Makefile, and this patch does it in the CMake definition, too.

This is a companion of 44400f58407e (t0080: turn t-basic unit test into a helper, 2024-02-02), and is based on js/unit-test-suite-runner.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1666%2Fgit-for-windows%2Fjs%2Funit-test-suite-runner-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1666/git-for-windows/js/unit-test-suite-runner-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1666

 contrib/buildsystems/CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
contrib/buildsystems/CMakeLists.txt +2 -1
index 804629c525b..2f9c33585c6 100644
@@ -1005,10 +1005,11 @@ endforeach()
 
 #test-tool
 parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
+add_library(test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
 
 list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
 add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES} ${test-reftable_SOURCES})
-target_link_libraries(test-tool common-main)
+target_link_libraries(test-tool test-lib common-main)
 
 set_target_properties(test-fake-ssh test-tool
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)

base-commit: b3b269c2d8931642c4b9f03b9ce9e81c20995eb8

Signature · 1 line
gitgitgadget
#1 lore raw

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 5 lines · writes:

From: Johannes Schindelin <[email protected]>

The test-tool recently learned to run the unit tests. To this end, it needs to link with test-lib.c, which was done in the Makefile, and this patch does it in the CMake definition, too.

Nice. Will queue. Thanks.

Quoted 6 lines
contrib/buildsystems/CMakeLists.txt +2 -1
+add_library(test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
 
 list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
 add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES} ${test-reftable_SOURCES})
-target_link_libraries(test-tool common-main)
+target_link_libraries(test-tool test-lib common-main)