Add support for auto-generating LIT tests by the build
authorEdwin Vane <edwin.vane@intel.com>
Tue, 19 Feb 2013 19:08:10 +0000 (19:08 +0000)
committerEdwin Vane <edwin.vane@intel.com>
Tue, 19 Feb 2013 19:08:10 +0000 (19:08 +0000)
autoconf and CMake flavours both updated to auto-generate files for use
in cpp11-migrate's LIT tests.

Auto-generated files are placed in the build directory under
test/cpp11-migrate/autogen. The directory structure past this point
mirrors the structure in the source directory under test/cpp11-migrate.
A lit.site.cfg is generated in test/cpp11-migrate/autogen to describe
the new test suite. When LIT runs, it runs the standard testsuite and
now also the auto-generated testsuite.

llvm-svn: 175544

clang-tools-extra/test/CMakeLists.txt
clang-tools-extra/test/Makefile
clang-tools-extra/test/lit.cfg
clang-tools-extra/test/lit.site.cfg.in

index 195852d..9782638 100644 (file)
@@ -7,28 +7,36 @@
 set(CLANG_TOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
 set(CLANG_TOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-  )
-
 option(CLANG_TOOLS_TEST_USE_VG "Run Clang tools' tests under Valgrind" OFF)
 if(CLANG_TOOLS_TEST_USE_VG)
   set(CLANG_TOOLS_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
 endif()
 
+add_subdirectory(cpp11-migrate)
+
+set(TEST_SOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
+set(TEST_EXEC_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+set(TESTSUITE_NAME "Clang Tools")
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  )
+
 set(CLANG_TOOLS_TEST_DEPS
   # Base line deps.
   clang clang-headers FileCheck count not
 
+  # cpp11-migrate auto-generated tests. See cpp11-migrate/CMakeLists.txt.
+  cpp11-migrate-autogen
+
   # Individual tools we test.
   remove-cstr-calls cpp11-migrate clang-format
   )
 
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_CURRENT_BINARY_DIR}/cpp11-migrate/autogen
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   ARGS ${CLANG_TOOLS_TEST_EXTRA_ARGS}
   )
 set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")
-
index e75b68f..da5e81f 100644 (file)
@@ -8,6 +8,10 @@
 ##===----------------------------------------------------------------------===##
 
 CLANG_LEVEL := ../../..
+include $(CLANG_LEVEL)/../../Makefile.config
+
+# Recurse into any subdirectories that have their own Makefiles.
+DIRS := cpp11-migrate
 include $(CLANG_LEVEL)/Makefile
 
 # Test in all immediate subdirectories if unset.
@@ -23,6 +27,9 @@ TESTDIRS := $(TESTDIRS:$(PROJ_SRC_DIR)%=$(PROJ_OBJ_DIR)%)
 # Allow EXTRA_TESTDIRS to provide additional test directories.
 TESTDIRS += $(EXTRA_TESTDIRS)
 
+# List of roots for auto-generated tests.
+TESTDIRS += $(PROJ_OBJ_DIR)/cpp11-migrate/autogen
+
 ifndef TESTARGS
 ifdef VERBOSE
 TESTARGS = -v
@@ -54,6 +61,9 @@ lit.site.cfg: FORCE
        @$(ECHOPATH) s=@CLANG_TOOLS_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> lit.tmp
        @$(ECHOPATH) s=@CLANG_TOOLS_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> lit.tmp
        @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp
+       @$(ECHOPATH) s=@TEST_SOURCE_ROOT@=$(PROJ_SRC_DIR)=g >> lit.tmp
+       @$(ECHOPATH) s=@TEST_EXEC_ROOT@=$(PROJ_OBJ_DIR)=g >> lit.tmp
+       @$(ECHOPATH) s=@TESTSUITE_NAME@=Clang Tools=g >> lit.tmp
        @sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
        @-rm -f lit.tmp
 
index 0d50e1b..acaef94 100644 (file)
@@ -8,12 +8,9 @@ import subprocess
 
 # Configuration file for the 'lit' test runner.
 
-# name: The name of this test suite.
-config.name = 'Clang Tools'
-
-# Tweak PATH for Win32
+# weak PATH for Win32
 if platform.system() == 'Windows':
-    # Seek sane tools in directories and set to $PATH.
+   # Seek sane tools in directories and set to $PATH.
     path = getattr(config, 'lit_tools_dir', None)
     path = lit.getToolsPath(path,
                             config.environment['PATH'],
@@ -34,14 +31,6 @@ config.test_format = lit.formats.ShTest(execute_external)
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s']
 
-# test_source_root: The root path where tests are located.
-config.test_source_root = os.path.dirname(__file__)
-
-# test_exec_root: The root path where tests should be run.
-clang_tools_binary_dir = getattr(config, 'clang_tools_binary_dir', None)
-if clang_tools_binary_dir is not None:
-    config.test_exec_root = os.path.join(clang_tools_binary_dir, 'test')
-
 # Clear some environment variables that might affect Clang.
 #
 # This first set of vars are read by Clang, but shouldn't affect tests
@@ -72,7 +61,7 @@ for name in possibly_dangerous_env_vars:
     del config.environment[name]
 
 # Tweak the PATH to include the tools dir and the scripts dir.
-if clang_tools_binary_dir is not None:
+if hasattr(config, 'clang_tools_binary_dir'):
     llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
     if not llvm_tools_dir:
         lit.fatal('No LLVM tools dir set!')
index 88aaa6c..6ecdf2d 100644 (file)
@@ -8,6 +8,10 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 
+config.name = "@TESTSUITE_NAME@"
+config.test_source_root = "@TEST_SOURCE_ROOT@"
+config.test_exec_root = "@TEST_EXEC_ROOT@"
+
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
 try: