[Lldb-commits] [lldb] 0c798aa - [CMake] Split logic across test suite subdirectories (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 24 10:58:31 PDT 2019


Author: Jonas Devlieghere
Date: 2019-10-24T10:58:22-07:00
New Revision: 0c798aa4483e103e67231c279aed00cd16154e33

URL: https://github.com/llvm/llvm-project/commit/0c798aa4483e103e67231c279aed00cd16154e33
DIFF: https://github.com/llvm/llvm-project/commit/0c798aa4483e103e67231c279aed00cd16154e33.diff

LOG: [CMake] Split logic across test suite subdirectories (NFC)

The top-level CMake file in the test directory can be simplified by
moving relevant configuration options into the corresponding
subdirectories. Doing so makes it easier to understand what CMake
options are needed by the different test suites.

Differential revision: https://reviews.llvm.org/D69394

Added: 
    lldb/test/Shell/CMakeLists.txt
    lldb/test/Unit/CMakeLists.txt

Modified: 
    lldb/test/API/CMakeLists.txt
    lldb/test/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 4f787d21fd3e..0708e804f49c 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -125,9 +125,38 @@ if(CMAKE_HOST_APPLE)
   endif()
 endif()
 
-set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
-set_property(GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY ${LLDB_DOTEST_ARGS})
+set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS} CACHE INTERNAL STRING)
+set(dotest_args_replacement ${LLVM_BUILD_MODE})
+
+if(LLDB_BUILT_STANDALONE)
+  # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder.
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
+  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
+
+  # Remaining ones must be paths to the provided LLVM build-tree.
+  if(LLVM_CONFIGURATION_TYPES)
+    # LLDB uses single-config; LLVM multi-config; pick one and prefer Release types.
+    # Otherwise, if both use multi-config the default is fine.
+    if(NOT CMAKE_CONFIGURATION_TYPES)
+      if(RelWithDebInfo IN_LIST LLVM_CONFIGURATION_TYPES)
+        set(dotest_args_replacement RelWithDebInfo)
+      elseif(Release IN_LIST LLVM_CONFIGURATION_TYPES)
+        set(dotest_args_replacement Release)
+      else()
+        list(GET LLVM_CONFIGURATION_TYPES 0 dotest_args_replacement)
+      endif()
+    endif()
+  else()
+    # Common case: LLVM used a single-configuration generator like Ninja.
+    set(dotest_args_replacement ".")
+  endif()
+endif()
+
+string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
 
-# This will add LLDB's test dependencies to the dependencies for check-all and
-# include them in the test-depends target.
-set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS})
+# Configure the API test suite.
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)

diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 4bee6ca2d676..d44880e56c42 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -1,8 +1,6 @@
 # Test runner infrastructure for LLDB. This configures the LLDB test trees
 # for use by Lit, and delegates to LLVM's lit test handlers.
 
-add_subdirectory(API)
-
 # Configure and create module cache directories.
 set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.")
 set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.")
@@ -16,39 +14,6 @@ else ()
   set(LLVM_BUILD_MODE "%(build_mode)s")
 endif ()
 
-if (CMAKE_SIZEOF_VOID_P EQUAL 8)
-  set(LLDB_IS_64_BITS 1)
-endif()
-
-get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
-set(dotest_args_replacement ${LLVM_BUILD_MODE})
-
-
-if(LLDB_BUILT_STANDALONE)
-  # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder.
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
-  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
-
-  # Remaining ones must be paths to the provided LLVM build-tree.
-  if(LLVM_CONFIGURATION_TYPES)
-    # LLDB uses single-config; LLVM multi-config; pick one and prefer Release types.
-    # Otherwise, if both use multi-config the default is fine.
-    if(NOT CMAKE_CONFIGURATION_TYPES)
-      if(RelWithDebInfo IN_LIST LLVM_CONFIGURATION_TYPES)
-        set(dotest_args_replacement RelWithDebInfo)
-      elseif(Release IN_LIST LLVM_CONFIGURATION_TYPES)
-        set(dotest_args_replacement Release)
-      else()
-        list(GET LLVM_CONFIGURATION_TYPES 0 dotest_args_replacement)
-      endif()
-    endif()
-  else()
-    # Common case: LLVM used a single-configuration generator like Ninja.
-    set(dotest_args_replacement ".")
-  endif()
-endif()
-
-string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
 
@@ -64,10 +29,15 @@ add_lldb_test_dependency(
   llvm-readobj
   )
 
-# Since llvm-strip is a symlink created by add_custom_target, it
-# doesn't expose an export target when building standalone.
 if(NOT LLDB_BUILT_STANDALONE)
-  add_lldb_test_dependency(llvm-strip)
+  # Since llvm-strip is a symlink created by add_custom_target, it doesn't
+  # expose an export target when building standalone.
+  add_lldb_test_dependency(
+    llvm-strip
+    FileCheck
+    count
+    not
+  )
 endif()
 
 if(TARGET lld)
@@ -79,12 +49,8 @@ else()
   endif()
 endif()
 
-if(NOT LLDB_BUILT_STANDALONE)
-  add_lldb_test_dependency(
-    FileCheck
-    count
-    not
-  )
+if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+  set(LLDB_IS_64_BITS 1)
 endif()
 
 # These values are not canonicalized within LLVM.
@@ -94,6 +60,11 @@ llvm_canonicalize_cmake_booleans(
   LLVM_ENABLE_SHARED_LIBS
   LLDB_IS_64_BITS)
 
+# Configure the individual test suites.
+add_subdirectory(API)
+add_subdirectory(Shell)
+add_subdirectory(Unit)
+
 # Configure the top level test suite.
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
@@ -101,41 +72,13 @@ configure_lit_site_cfg(
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-# Configure the Shell test suite.
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/Shell/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Shell/lit.site.cfg.py
-  MAIN_CONFIG
-  ${CMAKE_CURRENT_SOURCE_DIR}/Shell/lit.cfg.py)
-
-# Configure the Unit test suite.
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
-  MAIN_CONFIG
-  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py)
-
-# Configure the API test suite.
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/API/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/API/lit.site.cfg.py
-  MAIN_CONFIG
-  ${CMAKE_CURRENT_SOURCE_DIR}/API/lit.cfg.py)
-configure_file(
-  ${CMAKE_CURRENT_SOURCE_DIR}/Shell/lit-lldb-init.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Shell/lit-lldb-init)
-
-
 add_lit_testsuites(LLDB
   ${CMAKE_CURRENT_SOURCE_DIR}
-  DEPENDS lldb-test-deps
-  )
+  DEPENDS lldb-test-deps)
 
 add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS lldb-test-deps
-  )
-
+  DEPENDS lldb-test-deps)
 set_target_properties(check-lldb-lit PROPERTIES FOLDER "lldb tests")
 
 add_custom_target(check-lldb)

diff  --git a/lldb/test/Shell/CMakeLists.txt b/lldb/test/Shell/CMakeLists.txt
new file mode 100644
index 000000000000..91b4e282204b
--- /dev/null
+++ b/lldb/test/Shell/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Configure the Shell test suite.
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit-lldb-init.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit-lldb-init)

diff  --git a/lldb/test/Unit/CMakeLists.txt b/lldb/test/Unit/CMakeLists.txt
new file mode 100644
index 000000000000..e9b3d9e35d74
--- /dev/null
+++ b/lldb/test/Unit/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Configure the Unit test suite.
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
+


        


More information about the lldb-commits mailing list