OSDN Git Service

CMake: generate check targets for lit suites without their own lit.cfgs
authorJustin Bogner <mail@justinbogner.com>
Fri, 6 May 2016 21:57:30 +0000 (21:57 +0000)
committerJustin Bogner <mail@justinbogner.com>
Fri, 6 May 2016 21:57:30 +0000 (21:57 +0000)
Currently our cmake generates targets like check-llvm-unit and
check-llvm-transforms-loopunroll-x86, but not check-llvm-transforms or
check-llvm-transforms-adce. This is because the search for test suites
only lists the ones with a custom lit.cfg or lit.local.cfg.

Instead, we can do something a little smarter - any directory under
test that isn't called Inputs or inside a directory called Inputs is a
test suite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268806 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/AddLLVM.cmake

index f04081b..6bdb762 100644 (file)
@@ -1050,13 +1050,28 @@ endfunction()
 function(add_lit_testsuites project directory)
   if (NOT CMAKE_CONFIGURATION_TYPES)
     cmake_parse_arguments(ARG "" "" "PARAMS;DEPENDS;ARGS" ${ARGN})
-    file(GLOB_RECURSE litCfg ${directory}/lit*.cfg)
+
+    # Search recursively for test directories by assuming anything not
+    # in a directory called Inputs contains tests.
     set(lit_suites)
-    foreach(f ${litCfg})
-      get_filename_component(dir ${f} DIRECTORY)
-      set(lit_suites ${lit_suites} ${dir})
-    endforeach()
-    list(REMOVE_DUPLICATES lit_suites)
+    file(GLOB to_process ${directory}/*)
+    while(to_process)
+      set(cur_to_process ${to_process})
+      set(to_process)
+      foreach(lit_suite ${cur_to_process})
+        if(NOT IS_DIRECTORY ${lit_suite})
+          continue()
+        endif()
+        string(FIND ${lit_suite} Inputs is_inputs)
+        if (is_inputs EQUAL -1)
+          list(APPEND lit_suites "${lit_suite}")
+          file(GLOB subdirs ${lit_suite}/*)
+          list(APPEND to_process ${subdirs})
+        endif()
+      endforeach()
+    endwhile()
+
+    # Now create a check- target for each test directory.
     foreach(dir ${lit_suites})
       string(REPLACE ${directory} "" name_slash ${dir})
       if (name_slash)