From: Daniel Dunbar Date: Thu, 17 Sep 2009 19:55:53 +0000 (+0000) Subject: Tweak clang testing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7af18d359f6eff022a7a55335705b018a3c191d7;p=clang Tweak clang testing. - Move CMake to using the new test runner. - Switch Makefiles to use the lit.site.cfg.in template. - Remove explicit --path arguments, instead this gets written into the site configuration. This means running lit from the command line should use the exact same configuration as is used in 'make test', assuming it can find the site configuration file. You still need to run 'make test' (or the cmake build target equivalent) at least once. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82160 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e154c0c4d5..e6cd13cc2d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -28,39 +28,32 @@ if(PYTHONINTERP_FOUND) if (MSVC OR XCODE) set(CLANG_TEST_EXTRA_ARGS "--no-progress-bar") endif() - set(all_testdirs) - foreach(testdir ${CLANG_TEST_DIRECTORIES}) - add_custom_target(clang-test-${testdir} - ${PYTHON_EXECUTABLE} - ${LLVM_SOURCE_DIR}/tools/clang/utils/test/MultiTestRunner.py - "--root=${LLVM_SOURCE_DIR}/tools/clang/test" - "--path=${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}" - "--path=${LLVM_SOURCE_DIR}/test/Scripts" - -s ${CLANG_TEST_EXTRA_ARGS} - --clang=${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}/clang - --clang-cc=${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}/clang-cc - ${CMAKE_CURRENT_SOURCE_DIR}/${testdir}/ - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Running Clang regression tests in ${testdir}") - list(APPEND all_testdirs ${CMAKE_CURRENT_SOURCE_DIR}/${testdir}/) + foreach(testdir ${CLANG_TEST_DIRECTORIES}) + add_custom_target(clang-test-${testdir} + COMMAND sed -e "s#\@CLANG_SOURCE_DIR\@#${CMAKE_CURRENT_SOURCE_DIR}/..#" + -e "s#\@CLANG_BINARY_DIR\@#${CMAKE_CURRENT_BINARY_DIR}/..#" + -e "s#\@LLVM_TOOLS_DIR\@#${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}#" + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in > + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + COMMAND ${PYTHON_EXECUTABLE} + ${LLVM_SOURCE_DIR}/utils/lit/lit.py + -s ${CLANG_TEST_EXTRA_ARGS} + ${CMAKE_CURRENT_BINARY_DIR}/${testdir} + DEPENDS clang clang-cc index-test + COMMENT "Running Clang regression tests in ${testdir}") endforeach() add_custom_target(clang-test - ${PYTHON_EXECUTABLE} - ${LLVM_SOURCE_DIR}/tools/clang/utils/test/MultiTestRunner.py - "--root=${LLVM_SOURCE_DIR}/tools/clang/test" - "--path=${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}" - "--path=${LLVM_SOURCE_DIR}/test/Scripts" - -s ${CLANG_TEST_EXTRA_ARGS} - --clang=${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}/clang - --clang-cc=${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}/clang-cc - ${all_testdirs} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS clang clang-cc index-test - COMMENT "Running Clang regression tests") + COMMAND sed -e "s#\@CLANG_SOURCE_DIR\@#${CMAKE_CURRENT_SOURCE_DIR}/..#" + -e "s#\@CLANG_BINARY_DIR\@#${CMAKE_CURRENT_BINARY_DIR}/..#" + -e "s#\@LLVM_TOOLS_DIR\@#${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}#" + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in > + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + COMMAND ${PYTHON_EXECUTABLE} + ${LLVM_SOURCE_DIR}/utils/lit/lit.py + -s ${CLANG_TEST_EXTRA_ARGS} + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS clang clang-cc index-test + COMMENT "Running Clang regression tests") endif() - -# Produce LIT site configuration file. -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) diff --git a/test/Makefile b/test/Makefile index 1a109758ba..223fd8380b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -29,8 +29,6 @@ ifdef LIT2 all:: lit.site.cfg @ echo '--- Running clang tests for $(TARGET_TRIPLE) ---' @ $(LLVM_SRC_ROOT)/utils/lit/lit.py \ - --path $(ToolDir) \ - --path $(LLVM_SRC_ROOT)/test/Scripts \ $(TESTARGS) $(LIT2_TESTDIRS) $(VGARG) else all:: @@ -46,14 +44,10 @@ FORCE: lit.site.cfg: FORCE @echo "Making 'lit.site.cfg' file..." - @echo "## Autogenerated by Makefile ##" > $@ - @echo "# Do not edit!" >> $@ - @echo >> $@ - @echo "# Preserve some key paths for use by main LLVM test suite config." >> $@ - @echo "config.clang_obj_root = \"\"\"$(PROJ_OBJ_DIR)/..\"\"\"" >> $@ - @echo >> $@ - @echo "# Let the main config do the real work." >> $@ - @echo "lit.load_config(config, \"\"\"$(PROJ_SRC_DIR)/lit.cfg\"\"\")" >> $@ + @sed -e "s#@CLANG_SOURCE_DIR@#$(PROJ_SRC_DIR)/..#g" \ + -e "s#@CLANG_BINARY_DIR@#$(PROJ_OBJ_DIR)/..#g" \ + -e "s#@LLVM_TOOLS_DIR@#$(ToolDir)#g" \ + $(PROJ_SRC_DIR)/lit.site.cfg.in > $@ clean:: @ rm -rf Output/ diff --git a/test/lit.cfg b/test/lit.cfg index 46164f94b1..bca4d5190a 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -33,6 +33,17 @@ def config_new(): config.llvm_obj_root = os.path.join(clang_obj_root, '..', '..') + # Tweak the PATH to include the tools dir and the scripts dir. + if clang_obj_root is not None: + llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) + if not llvm_tools_dir: + lit.fatal('No LLVM tools dir set!') + path = os.path.pathsep.join((llvm_tools_dir, + os.path.join(config.llvm_src_root, + 'test', 'Scripts'), + config.environment['PATH'])) + config.environment['PATH'] = path + ### # Check that the object root is known. diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 21b75994ae..e91fbed590 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -1,6 +1,7 @@ -## Autogenerated by LLVM/Clang configuration. +## Autogenerated by LLVM/Clang configuration. # Do not edit! config.clang_obj_root = "@CLANG_BINARY_DIR@" +config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" # Let the main config do the real work. lit.load_config(config, "@CLANG_SOURCE_DIR@/test/lit.cfg")