From 0b0690ca53ae3a98a8648c8ff168e3d7d2405c79 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Thu, 5 Mar 2020 11:57:33 -0500 Subject: [PATCH] ARROW-8014: [C++] Provide Cmake targets exercising tests with a label --- cpp/cmake_modules/BuildUtils.cmake | 15 +++++++++++++++ cpp/src/arrow/CMakeLists.txt | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index dc441faf9f494..e4f835586ab68 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -657,6 +657,21 @@ function(ADD_TEST_CASE REL_TEST_NAME) set(ARG_LABELS unittest) endif() + foreach(LABEL ${ARG_LABELS}) + # ensure there is a cmake target which exercises tests with this LABEL + set(LABEL_TEST_NAME "test-label-${LABEL}") + if(NOT TARGET ${LABEL_TEST_NAME}) + add_custom_target(${LABEL_TEST_NAME} + ctest + -L + "${LABEL}" + --output-on-failure + USES_TERMINAL) + endif() + # ensure the test is (re)built before the LABEL test runs + add_dependencies(${LABEL_TEST_NAME} ${TEST_NAME}) + endforeach() + set_property(TEST ${TEST_NAME} APPEND PROPERTY LABELS ${ARG_LABELS}) endfunction() diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 743c93cadf132..70a67d29fd9cb 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -45,8 +45,6 @@ function(ADD_ARROW_TEST REL_TEST_NAME) if(ARG_LABELS) set(LABELS ${ARG_LABELS}) - else() - set(LABELS "arrow-tests") endif() # Because of https://gitlab.kitware.com/cmake/cmake/issues/20289,