From 9824d4d81228baa11d37ee2560bb3b8138726779 Mon Sep 17 00:00:00 2001 From: Mogball Date: Thu, 14 Nov 2024 12:54:20 -0800 Subject: [PATCH 1/2] Create an aggregate `check-triton-unit` target This adds a CMake target `check-triton-unit` that builds an runs all Triton unittests written in gtest. This makes it more conveninent to rebuild and run all unittests at once with finer granularity (instead of `ninja; ctest`). --- CMakeLists.txt | 9 +++++++++ cmake/AddTritonUnitTest.cmake | 3 +++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6db40118c491..0d27b66e1933 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,9 @@ if(NOT WIN32) endif() if(TRITON_BUILD_UT) + # This is an aggregate target for all unit tests. + add_custom_target(TritonUnitTests) + set_target_properties(TritonUnitTests PROPERTIES FOLDER "Triton/Tests") include(AddTritonUnitTest) endif() @@ -340,4 +343,10 @@ add_subdirectory(test) if(TRITON_BUILD_UT) add_subdirectory(unittest) + # This target runs all the unit tests. + add_custom_target(check-triton-unit + COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure + DEPENDS TritonUnitTests + USES_TERMINAL + ) endif() diff --git a/cmake/AddTritonUnitTest.cmake b/cmake/AddTritonUnitTest.cmake index 2eda7df3723e..a9efb9ad1ad8 100644 --- a/cmake/AddTritonUnitTest.cmake +++ b/cmake/AddTritonUnitTest.cmake @@ -36,4 +36,7 @@ function(add_triton_ut) # laptop. I think the issue may be that the very first time you run a program # it's a bit slow. gtest_discover_tests(${__NAME} DISCOVERY_TIMEOUT 60) + + # Add the unit test to the top-level unit test target. + add_dependencies(TritonUnitTests ${__NAME}) endfunction() From aac660b0619851201596d33226e041ad208db0aa Mon Sep 17 00:00:00 2001 From: Mogball Date: Tue, 26 Nov 2024 13:26:13 -0800 Subject: [PATCH 2/2] rename to check-triton-unit-tests --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d27b66e1933..cecb7e80624f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,7 +344,7 @@ add_subdirectory(test) if(TRITON_BUILD_UT) add_subdirectory(unittest) # This target runs all the unit tests. - add_custom_target(check-triton-unit + add_custom_target(check-triton-unit-tests COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure DEPENDS TritonUnitTests USES_TERMINAL