diff mbox series

[v2,7/7] cmake: handle also unit tests

Message ID 003d44e9f0d73efae887d6b61ebdffb3c4e0904f.1695070468.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series CMake(Visual C) support for js/doc-unit-tests | expand

Commit Message

Johannes Schindelin Sept. 18, 2023, 8:54 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
 contrib/buildsystems/CMakeLists.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Phillip Wood Sept. 22, 2023, 2:39 p.m. UTC | #1
Hi Johannes

On 18/09/2023 21:54, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> 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>

This looks good to me, it is nice to see it being careful not to run 
t-basic with the other unit tests.

Best Wishes

Phillip

> ---
>   contrib/buildsystems/CMakeLists.txt | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> index ff1a8cc348f..35d451856a0 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -981,6 +981,17 @@ foreach(unit_test ${unit_test_PROGRAMS})
>   			PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/unit-tests)
>   	endif()
>   	list(APPEND PROGRAMS_BUILT "${unit_test}")
> +
> +	# t-basic intentionally fails tests, to validate the unit-test infrastructure.
> +	# Therefore, it should only be run as part of t0080, which verifies that it
> +	# fails only in the expected ways.
> +	#
> +	# All other unit tests should be run.
> +	if(NOT ${unit_test} STREQUAL "t-basic")
> +		add_test(NAME "unit-tests.${unit_test}"
> +			COMMAND "./${unit_test}"
> +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t/unit-tests)
> +	endif()
>   endforeach()
>   
>   #test-tool
diff mbox series

Patch

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index ff1a8cc348f..35d451856a0 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -981,6 +981,17 @@  foreach(unit_test ${unit_test_PROGRAMS})
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/unit-tests)
 	endif()
 	list(APPEND PROGRAMS_BUILT "${unit_test}")
+
+	# t-basic intentionally fails tests, to validate the unit-test infrastructure.
+	# Therefore, it should only be run as part of t0080, which verifies that it
+	# fails only in the expected ways.
+	#
+	# All other unit tests should be run.
+	if(NOT ${unit_test} STREQUAL "t-basic")
+		add_test(NAME "unit-tests.${unit_test}"
+			COMMAND "./${unit_test}"
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t/unit-tests)
+	endif()
 endforeach()
 
 #test-tool