From 8b526f22c6f28866ad7612786d453160aedc6564 Mon Sep 17 00:00:00 2001 From: Edwin Vane Date: Tue, 19 Feb 2013 19:08:10 +0000 Subject: [PATCH] Add support for auto-generating LIT tests by the build 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 | 20 ++++++++++++++------ clang-tools-extra/test/Makefile | 10 ++++++++++ clang-tools-extra/test/lit.cfg | 17 +++-------------- clang-tools-extra/test/lit.site.cfg.in | 4 ++++ 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt index 195852d449d6..9782638fe091 100644 --- a/clang-tools-extra/test/CMakeLists.txt +++ b/clang-tools-extra/test/CMakeLists.txt @@ -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") - diff --git a/clang-tools-extra/test/Makefile b/clang-tools-extra/test/Makefile index e75b68fe79c3..da5e81f50300 100644 --- a/clang-tools-extra/test/Makefile +++ b/clang-tools-extra/test/Makefile @@ -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 diff --git a/clang-tools-extra/test/lit.cfg b/clang-tools-extra/test/lit.cfg index 0d50e1b8e7ee..acaef944d9f2 100644 --- a/clang-tools-extra/test/lit.cfg +++ b/clang-tools-extra/test/lit.cfg @@ -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!') diff --git a/clang-tools-extra/test/lit.site.cfg.in b/clang-tools-extra/test/lit.site.cfg.in index 88aaa6c421c8..6ecdf2db0d05 100644 --- a/clang-tools-extra/test/lit.site.cfg.in +++ b/clang-tools-extra/test/lit.site.cfg.in @@ -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: