[PATCH] D34053: [Polly][CMake] Skip unit-tests in lit if gtest is not available

Philip Pfaffe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 05:25:42 PDT 2017


philip.pfaffe created this revision.
philip.pfaffe added a project: Polly.
Herald added subscribers: bollu, mgorny.

There is a bug in the current lit configurations for the unittests. If gtest is not available, the site-config for the unit tests won't be generated. Because lit recurses through the test directory, the lit configuration for the unit tests will be discovered nevertheless, leading to a fatal error in lit.

This patch semi-gracefully skips the unittests if gtest is not available. As a result, running lit now prints this: `warning: test suite 'Polly-Unit' contained no test`.

If people think that this is too annoying, the alternative would be to pick apart the test directory, so that the lit testsuite discovery will always only find one configuration. In fact, both of these things could be combined. While it's certainly nice that running a single lit command runs all the tests, I suppose people use the `check-polly` make target over lit most of the time, so the difference might not be noticed.


Repository:
  rL LLVM

https://reviews.llvm.org/D34053

Files:
  CMakeLists.txt
  test/CMakeLists.txt
  test/Unit/lit.cfg
  test/Unit/lit.site.cfg.in


Index: test/Unit/lit.site.cfg.in
===================================================================
--- test/Unit/lit.site.cfg.in
+++ test/Unit/lit.site.cfg.in
@@ -14,6 +14,7 @@
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
 config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.has_unittests = @POLLY_GTEST_AVAIL@
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
 # parameters. This is used when we can't determine the tool dir at
Index: test/Unit/lit.cfg
===================================================================
--- test/Unit/lit.cfg
+++ test/Unit/lit.cfg
@@ -11,6 +11,9 @@
 # name: The name of this test suite.
 config.name = 'Polly-Unit'
 
+if not config.has_unittests:
+    raise SystemExit
+
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = []
 
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -62,12 +62,12 @@
 set_target_properties(check-polly-tests PROPERTIES FOLDER "Polly")
 add_dependencies(check-polly check-polly-tests)
 
-if (POLLY_GTEST_AVAIL)
-  configure_lit_site_cfg(
-    ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
-    ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
-    )
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+  )
 
+if (POLLY_GTEST_AVAIL)
   # Run only unit tests
   add_lit_testsuite(check-polly-unittests "Running polly unit tests only"
     ${CMAKE_CURRENT_BINARY_DIR}/Unit
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -24,6 +24,7 @@
   endif()
 
   # Enable unit tests if available.
+  set(POLLY_GTEST_AVAIL 0)
   set(UNITTEST_DIR ${LLVM_SOURCE_ROOT}/utils/unittest)
   if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
     # The build tree already exports the gtest target, which we can reuse


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34053.102017.patch
Type: text/x-patch
Size: 2040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170609/ccde512b/attachment.bin>


More information about the llvm-commits mailing list