[PATCH] D14722: Teach CMake how to run lit's testsuite as part of check-all

Jonathan Roelofs via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 22:57:00 PST 2015


jroelofs updated this revision to Diff 40472.
jroelofs added a comment.

Copy the lit tests over to the build directory because they make the src dir dirty when they get run.


http://reviews.llvm.org/D14722

Files:
  CMakeLists.txt
  tests/lit.cfg
  tests/lit.site.cfg.in
  tests/progress-bar.py

Index: tests/progress-bar.py
===================================================================
--- tests/progress-bar.py
+++ tests/progress-bar.py
@@ -11,3 +11,5 @@
 # CHECK: FAIL: shtest-shell :: test-3.txt (3 of 4)
 # CHECK: Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
 # CHECK: FAIL: shtest-shell :: test-4.txt (4 of 4)
+
+# foo bar baz
Index: tests/lit.site.cfg.in
===================================================================
--- tests/lit.site.cfg.in
+++ tests/lit.site.cfg.in
@@ -0,0 +1,7 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@LLVM_BINARY_DIR@/utils/lit/tests/lit.cfg")
Index: tests/lit.cfg
===================================================================
--- tests/lit.cfg
+++ tests/lit.cfg
@@ -21,8 +21,20 @@
 
 # test_source_root: The root path where tests are located.
 config.test_source_root = os.path.dirname(__file__)
-config.test_exec_root = config.test_source_root
 
+llvm_src_root = getattr(config, 'llvm_src_root', None)
+if llvm_src_root is not None:
+    lit_path = os.path.join(llvm_src_root, 'utils/lit/lit.py')
+else:
+    lit_path = os.path.join(config.test_source_root, '../lit.py')
+
+# test_exec_root: The root path where tests should be run.
+llvm_obj_root = getattr(config, 'llvm_obj_root', None)
+if llvm_obj_root is not None:
+    config.test_exec_root = os.path.join(llvm_obj_root, 'utils/lit/tests')
+else:
+    config.test_exec_root = config.test_source_root
+
 config.target_triple = '(unused)'
 
 src_root = os.path.join(config.test_source_root, '..')
@@ -30,8 +42,8 @@
 config.substitutions.append(('%{src_root}', src_root))
 config.substitutions.append(('%{inputs}', os.path.join(
             src_root, 'tests', 'Inputs')))
-config.substitutions.append(('%{lit}', "%%{python} %s" % (
-            os.path.join(src_root, 'lit.py'),)))
+config.substitutions.append(('%{lit}', "%%{python} %s --param test_exec_root='%s'" %
+                            (lit_path,config.test_exec_root)))
 config.substitutions.append(('%{python}', sys.executable))
 
 # Enable coverage.py reporting, assuming the coverage module has been installed
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -0,0 +1,20 @@
+# LIT's self tests write out temporary files relative to themselves,
+# which dirties the source dir. To avoid this, we copy them to the build
+# directory, and run them from there.
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/tests
+     DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/tests/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/tests/lit.site.cfg
+  )
+
+add_custom_command(TARGET check-lit
+                   COMMAND ${CMAKE_COMMAND} -E copy_directory
+                     ${CMAKE_CURRENT_SOURCE_DIR}/tests
+                     ${CMAKE_CURRENT_BINARY_DIR}/tests)
+
+add_lit_testsuite(check-lit "Running lit's self tests"
+    ${CMAKE_CURRENT_BINARY_DIR}/tests
+    DEPENDS FileCheck not)
+set_target_properties(check-lit PROPERTIES FOLDER "Tests")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14722.40472.patch
Type: text/x-patch
Size: 3242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151118/ac3dce6e/attachment.bin>


More information about the llvm-commits mailing list