git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/4] cmake: also build unit tests

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Sep 11, 2023, 13:23 UTC
Message-ID
<d7d1505c-8d65-4b64-8814-3e3b1e46f8ac@gmail.com>
In-Reply-To
<2cc1c03d85153356edd55fc0747a957db3c94ab0.1693462532.git.gitgitgadget@gmail.com>
Hi Johannes
On 31/08/2023 07:15, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> A new, better way to run unit tests was just added to Git. This adds
> support for building those unit tests via CMake.

This patch builds the unit tests but does not add them to the list of tests run by CTest - how are the tests typically run on the CMake build?

Best Wishes
Phillip
Show 34 quoted lines
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>   contrib/buildsystems/CMakeLists.txt | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
> 
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> index 2f6e0197ffa..45016213358 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -965,6 +965,24 @@ target_link_libraries(test-fake-ssh common-main)
>   parse_makefile_for_sources(test-reftable_SOURCES "REFTABLE_TEST_OBJS")
>   list(TRANSFORM test-reftable_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
>   
> +#unit-tests
> +add_library(unit-test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
> +
> +parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "")
> +foreach(unit_test ${unit_test_PROGRAMS})
> +	add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c")
> +	target_link_libraries("${unit_test}" unit-test-lib common-main)
> +	set_target_properties("${unit_test}"
> +		PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests)
> +	if(MSVC)
> +		set_target_properties("${unit_test}"
> +			PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/unit-tests)
> +		set_target_properties("${unit_test}"
> +			PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/unit-tests)
> +	endif()
> +	list(APPEND PROGRAMS_BUILT "${unit_test}")
> +endforeach()
> +
>   #test-tool
>   parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
>   
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin
Message 3 of 30 in “CMake(Visual C) support for js/doc-unit-tests”
  1. 0/4 CMake(Visual C) support for js/doc-unit-testsJohannes Schindelin via GitGitGadget, Aug 31, 2023
  2. 1/4 cmake: also build unit testsJohannes Schindelin via GitGitGadget, Aug 31, 2023
  3. Phillip WoodSep 11, 2023
  4. Johannes SchindelinSep 18, 2023
  5. 3/4 unit-tests: do show relative file pathsJohannes Schindelin via GitGitGadget, Aug 31, 2023
  6. Phillip WoodSep 11, 2023
  7. Johannes SchindelinSep 18, 2023
  8. 2/4 unit-tests: do not mistake `.pdb` files for being executableJohannes Schindelin via GitGitGadget, Aug 31, 2023
  9. 4/4 artifacts-tar: when including `.dll` files, don't forget the unit-testsJohannes Schindelin via GitGitGadget, Aug 31, 2023
  10. 0/7 CMake(Visual C) support for js/doc-unit-testsJohannes Schindelin via GitGitGadget, Sep 18, 2023
  11. 1/7 cmake: also build unit testsJohannes Schindelin via GitGitGadget, Sep 18, 2023
  12. 2/7 unit-tests: do not mistake `.pdb` files for being executableJohannes Schindelin via GitGitGadget, Sep 18, 2023
  13. 3/7 unit-tests: do show relative file pathsJohannes Schindelin via GitGitGadget, Sep 18, 2023
  14. Phillip WoodSep 22, 2023
  15. 4/7 artifacts-tar: when including `.dll` files, don't forget the unit-testsJohannes Schindelin via GitGitGadget, Sep 18, 2023
  16. 5/7 cmake: fix typo in variable nameJohannes Schindelin via GitGitGadget, Sep 18, 2023
  17. 6/7 cmake: use test names instead of full pathsJohannes Schindelin via GitGitGadget, Sep 18, 2023
  18. Phillip WoodSep 22, 2023
  19. Johannes SchindelinSep 25, 2023
  20. 7/7 cmake: handle also unit testsJohannes Schindelin via GitGitGadget, Sep 18, 2023
  21. Phillip WoodSep 22, 2023
  22. 0/7 CMake(Visual C) support for js/doc-unit-testsJohannes Schindelin via GitGitGadget, Sep 25, 2023
  23. 2/7 unit-tests: do not mistake `.pdb` files for being executableJohannes Schindelin via GitGitGadget, Sep 25, 2023
  24. 1/7 cmake: also build unit testsJohannes Schindelin via GitGitGadget, Sep 25, 2023
  25. 3/7 unit-tests: do show relative file pathsJohannes Schindelin via GitGitGadget, Sep 25, 2023
  26. 4/7 artifacts-tar: when including `.dll` files, don't forget the unit-testsJohannes Schindelin via GitGitGadget, Sep 25, 2023
  27. 5/7 cmake: fix typo in variable nameJohannes Schindelin via GitGitGadget, Sep 25, 2023
  28. 7/7 cmake: handle also unit testsJohannes Schindelin via GitGitGadget, Sep 25, 2023
  29. 6/7 cmake: use test names instead of full pathsJohannes Schindelin via GitGitGadget, Sep 25, 2023
  30. Junio C HamanoSep 25, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.