[llvm] r309602 - [lit] Avoid copying llvm/utils/lit/tests/Inputs with lit site configs

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 11:45:44 PDT 2017


Author: rnk
Date: Mon Jul 31 11:45:44 2017
New Revision: 309602

URL: http://llvm.org/viewvc/llvm-project?rev=309602&view=rev
Log:
[lit] Avoid copying llvm/utils/lit/tests/Inputs with lit site configs

Summary:
This is an alternative solution to running the lit test suite on bots
without polluting the source directory. Each input test suite gets an
auto-generated site config in the build directory that points back to
the test input source directory.

This adds some cmake comlexity, but now we don't need to remove and
re-copy the test input directory before every test.

Reviewers: delcypher, modocache

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D36026

Added:
    llvm/trunk/utils/lit/tests/CMakeLists.txt
    llvm/trunk/utils/lit/tests/Inputs/lit.site.cfg.in
Removed:
    llvm/trunk/utils/lit/CMakeLists.txt
Modified:
    llvm/trunk/CMakeLists.txt
    llvm/trunk/utils/lit/tests/lit.site.cfg.in

Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=309602&r1=309601&r2=309602&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Mon Jul 31 11:45:44 2017
@@ -897,7 +897,7 @@ if( LLVM_INCLUDE_TESTS )
       NO_INSTALL
       ALWAYS_CLEAN)
   endif()
-  add_subdirectory(utils/lit)
+  add_subdirectory(utils/lit/tests)
   add_subdirectory(test)
   add_subdirectory(unittests)
   if( LLVM_INCLUDE_UTILS )

Removed: llvm/trunk/utils/lit/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/CMakeLists.txt?rev=309601&view=auto
==============================================================================
--- llvm/trunk/utils/lit/CMakeLists.txt (original)
+++ llvm/trunk/utils/lit/CMakeLists.txt (removed)
@@ -1,27 +0,0 @@
-# The configured file is not placed in the correct location
-# until the tests are run as we need to copy it into
-# a copy of the tests folder
-configure_file("tests/lit.site.cfg.in" "lit.site.cfg" @ONLY)
-
-# Lit's test suite creates output files next to the sources which makes the
-# source tree dirty. This is undesirable because we do out of source builds.
-# To work around this the tests and the configuration file are copied into the
-# build directory just before running them. The tests are not copied over at
-# configure time (i.e. `file(COPY ...)`) because this could lead to stale
-# tests being run.
-add_custom_target(prepare-check-lit
-  COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/tests"
-  COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/tests" "${CMAKE_CURRENT_BINARY_DIR}/tests"
-  COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg" "${CMAKE_CURRENT_BINARY_DIR}/tests"
-  COMMENT "Preparing lit tests"
-)
-
-# Add rules for lit's own test suite
-add_lit_testsuite(check-lit "Running lit's tests"
-  ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS "FileCheck" "not" "prepare-check-lit"
-)
-
-# For IDEs
-set_target_properties(check-lit PROPERTIES FOLDER "Tests")
-set_target_properties(prepare-check-lit PROPERTIES FOLDER "Tests")

Added: llvm/trunk/utils/lit/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/CMakeLists.txt?rev=309602&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/CMakeLists.txt (added)
+++ llvm/trunk/utils/lit/tests/CMakeLists.txt Mon Jul 31 11:45:44 2017
@@ -0,0 +1,24 @@
+# The configured file is not placed in the correct location
+# until the tests are run as we need to copy it into
+# a copy of the tests folder
+configure_file("lit.site.cfg.in" "lit.site.cfg" @ONLY)
+
+# For every lit.cfg in the Inputs tree, create a lit.site.cfg that points at
+# the tests back in the source directory. Running the tests this way keeps the
+# temporary output files in the build directory.
+file(GLOB inputs_suites "Inputs/*/lit.cfg")
+foreach(lit_cfg ${inputs_suites})
+  get_filename_component(LIT_TEST_SRC_DIR "${lit_cfg}" DIRECTORY)
+  file(RELATIVE_PATH LIT_TEST_BIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}" "${LIT_TEST_SRC_DIR}")
+  set(LIT_TEST_BIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/${LIT_TEST_BIN_DIR}")
+  configure_file("Inputs/lit.site.cfg.in" "${LIT_TEST_BIN_DIR}/lit.site.cfg" @ONLY)
+endforeach()
+
+# Add rules for lit's own test suite
+add_lit_testsuite(check-lit "Running lit's tests"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  DEPENDS "FileCheck" "not"
+)
+
+# For IDEs
+set_target_properties(check-lit PROPERTIES FOLDER "Tests")

Added: llvm/trunk/utils/lit/tests/Inputs/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/lit.site.cfg.in?rev=309602&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/lit.site.cfg.in (added)
+++ llvm/trunk/utils/lit/tests/Inputs/lit.site.cfg.in Mon Jul 31 11:45:44 2017
@@ -0,0 +1,3 @@
+lit_config.load_config(config, "@LIT_TEST_SRC_DIR@/lit.cfg")
+config.test_source_root = "@LIT_TEST_SRC_DIR@"
+config.test_exec_root = "@LIT_TEST_BIN_DIR@"

Modified: llvm/trunk/utils/lit/tests/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/lit.site.cfg.in?rev=309602&r1=309601&r2=309602&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/lit.site.cfg.in (original)
+++ llvm/trunk/utils/lit/tests/lit.site.cfg.in Mon Jul 31 11:45:44 2017
@@ -5,4 +5,6 @@ config.llvm_obj_root = "@LLVM_BINARY_DIR
 config.llvm_tools_dir = "@LLVM_TOOLS_BINARY_DIR@"
 
 # Let the main config do the real work.
-lit_config.load_config(config, "@LLVM_BINARY_DIR@/utils/lit/tests/lit.cfg")
+lit_config.load_config(config, "@LLVM_SOURCE_DIR@/utils/lit/tests/lit.cfg")
+config.test_source_root = "@CMAKE_CURRENT_SOURCE_DIR@"
+config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"




More information about the llvm-commits mailing list