[clang-tools-extra] r176184 - Custom lit.site.cfg configuration for cpp11-migrate

Edwin Vane edwin.vane at intel.com
Wed Feb 27 05:09:24 PST 2013


Author: revane
Date: Wed Feb 27 07:09:24 2013
New Revision: 176184

URL: http://llvm.org/viewvc/llvm-project?rev=176184&view=rev
Log:
Custom lit.site.cfg configuration for cpp11-migrate

To afford hand-written tests access to any auto-generated headers, a
lit.site.cfg is now created for cpp11-migrate's test directory providing a new
config.substition. Tests can refer to %gen_root in the LIT script.

Removed use of --param clang_site_config. Not necessary when running
tests using the build system.

Added:
    clang-tools-extra/trunk/test/cpp11-migrate/lit.site.cfg.in
Modified:
    clang-tools-extra/trunk/test/CMakeLists.txt
    clang-tools-extra/trunk/test/Makefile
    clang-tools-extra/trunk/test/cpp11-migrate/CMakeLists.txt
    clang-tools-extra/trunk/test/cpp11-migrate/Makefile

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=176184&r1=176183&r2=176184&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Wed Feb 27 07:09:24 2013
@@ -26,17 +26,18 @@ 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
+  remove-cstr-calls clang-format
 
-  # Individual tools we test.
-  remove-cstr-calls cpp11-migrate clang-format
+  cpp11-migrate cpp11-migrate-autogen
   )
 
-add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
+add_lit_testsuite(check-clang-tools "Running regression tests for Clang extra tools"
   ${CMAKE_CURRENT_BINARY_DIR}
+  # cpp11-migrate's auto-generated tests need to be mentioned explicitly since
+  # the sources live in ${CMAKE_CURRENT_BINARY_DIR} and won't get discovered
+  # otherwise.
   ${CMAKE_CURRENT_BINARY_DIR}/cpp11-migrate/generated_tests
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   ARGS ${CLANG_TOOLS_TEST_EXTRA_ARGS}
   )
-set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")
+set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools tests")

Modified: clang-tools-extra/trunk/test/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/Makefile?rev=176184&r1=176183&r2=176184&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/Makefile (original)
+++ clang-tools-extra/trunk/test/Makefile Wed Feb 27 07:09:24 2013
@@ -27,7 +27,9 @@ TESTDIRS := $(TESTDIRS:$(PROJ_SRC_DIR)%=
 # Allow EXTRA_TESTDIRS to provide additional test directories.
 TESTDIRS += $(EXTRA_TESTDIRS)
 
-# List of roots for auto-generated tests.
+# We'd like cpp11-migrate's auto-generated tests to be included in the LIT run
+# below. Since the auto-generated test sources live in PROJ_OBJ_DIR they won't
+# get discovered without specifying them explicitly.
 TESTDIRS += $(PROJ_OBJ_DIR)/cpp11-migrate/generated_tests
 
 ifndef TESTARGS
@@ -38,9 +40,6 @@ TESTARGS = -s -v
 endif
 endif
 
-# Make sure any extra test suites can find the main site config.
-LIT_ARGS := --param clang_site_config=$(PROJ_OBJ_DIR)/lit.site.cfg
-
 ifdef VG
   LIT_ARGS += "--vg"
 endif

Modified: clang-tools-extra/trunk/test/cpp11-migrate/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/cpp11-migrate/CMakeLists.txt?rev=176184&r1=176183&r2=176184&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/cpp11-migrate/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/cpp11-migrate/CMakeLists.txt Wed Feb 27 07:09:24 2013
@@ -44,17 +44,28 @@ foreach(script ${generator_scripts})
   list(APPEND depends ${output})
 endforeach()
 
-# This custom target will be used by parent CMakeLists.txt to ensure all
-# auto-generated files are created before lit is run.
+# Target to perform all generation.
 add_custom_target(cpp11-migrate-autogen
   DEPENDS ${depends}
   )
 
-set(TEST_SOURCE_ROOT ${CMAKE_CURRENT_BINARY_DIR}/generated_tests)
+# Create lit.site.cfg for regular regression tests. Provide access to location
+# of generated tests so regular tests can use headers.
+set(TEST_SOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
+set(TEST_EXEC_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+set(TESTSUITE_NAME "cpp11-migrate Tests")
+set(GENERATED_TESTS_ROOT ${CMAKE_CURRENT_BINARY_DIR}/generated_tests)
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  )
+
+# Create lit.site.cfg for auto-generated tests. Sources for these tests live
+# in the build directory.
+set(TEST_SOURCE_ROOT ${GENERATED_TESTS_ROOT})
 set(TEST_EXEC_ROOT ${CMAKE_CURRENT_BINARY_DIR})
 set(TESTSUITE_NAME "cpp11-migrate Auto-Generated Tests")
-get_filename_component(INPUT_LIT_CFG ${CMAKE_CURRENT_SOURCE_DIR}/../lit.site.cfg.in REALPATH)
 configure_lit_site_cfg(
-  ${INPUT_LIT_CFG}
-  ${CMAKE_CURRENT_BINARY_DIR}/generated_tests/lit.site.cfg
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+  ${GENERATED_TESTS_ROOT}/lit.site.cfg
   )

Modified: clang-tools-extra/trunk/test/cpp11-migrate/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/cpp11-migrate/Makefile?rev=176184&r1=176183&r2=176184&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/cpp11-migrate/Makefile (original)
+++ clang-tools-extra/trunk/test/cpp11-migrate/Makefile Wed Feb 27 07:09:24 2013
@@ -34,7 +34,7 @@ define autogenerate-file
 OUTFILE := $(addprefix generated_tests/$(dir $1), $(patsubst gen_%.py,%,$(notdir $1)))
 GENERATED_FILES := $$(GENERATED_FILES) $$(OUTFILE)
 $$(OUTFILE): $1
-	@echo "Autogenerating $$<"
+	@echo "Autogenerating $$@"
 	@$(MKDIR) $(addprefix generated_tests/, $(dir $1))
 	@$(PYTHON) $$< > $$@
 endef
@@ -42,9 +42,13 @@ $(foreach script, $(GENERATOR_SCRIPTS),
 
 FORCE:
 
+GENERATED_TESTS_ROOT := $(PROJ_OBJ_DIR)/generated_tests
+
+# Recipe to create lit.site.cfg for the auto-generated tests suite. Sources
+# for these tests are auto-generated into the build directory.
 generated_tests/lit.site.cfg: FORCE
-	@$(MKDIR) $(PROJ_OBJ_DIR)/generated_tests
-	@echo "Making cpp11-migrate Auto-Generated Tests' 'lit.site.cfg' file..."
+	@$(MKDIR) $(GENERATED_TESTS_ROOT)
+	@echo "Making lit.site.cfg for cpp11-migrate Auto-Generated Tests..."
 	@$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g > lit.tmp
 	@$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> lit.tmp
 	@$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp
@@ -52,13 +56,31 @@ generated_tests/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_OBJ_DIR)/generated_tests=g >> lit.tmp
+	@$(ECHOPATH) s=@TEST_SOURCE_ROOT@=$(GENERATED_TESTS_ROOT)=g >> lit.tmp
 	@$(ECHOPATH) s=@TEST_EXEC_ROOT@=$(PROJ_OBJ_DIR)=g >> lit.tmp
 	@$(ECHOPATH) s=@TESTSUITE_NAME@=cpp11-migrate Auto-Generated Tests=g >> lit.tmp
-	@sed -f lit.tmp $(PROJ_SRC_DIR)/../lit.site.cfg.in > $@
+	@$(ECHOPATH) s=@GENERATED_TESTS_ROOT@=$(GENERATED_TESTS_ROOT)=g >> lit.tmp
+	@sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
+	@-rm -f lit.tmp
+
+# Recipe to create the lit.site.cfg for the regular cpp11-migrate test suite.
+lit.site.cfg: FORCE
+	@echo "Making lit.site.cfg for cpp11-migrate Tests..."
+	@$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g > lit.tmp
+	@$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> lit.tmp
+	@$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp
+	@$(ECHOPATH) s=@LLVM_LIBS_DIR@=$(LibDir)=g >> lit.tmp
+	@$(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@=cpp11-migrate Tests=g >> lit.tmp
+	@$(ECHOPATH) s=@GENERATED_TESTS_ROOT@=$(GENERATED_TESTS_ROOT)=g >> lit.tmp
+	@sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
 	@-rm -f lit.tmp
 
-all:: $(GENERATED_FILES) generated_tests/lit.site.cfg
+all:: $(GENERATED_FILES) lit.site.cfg generated_tests/lit.site.cfg
 
 clean::
 	@-rm -r generated_tests

Added: clang-tools-extra/trunk/test/cpp11-migrate/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/cpp11-migrate/lit.site.cfg.in?rev=176184&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/cpp11-migrate/lit.site.cfg.in (added)
+++ clang-tools-extra/trunk/test/cpp11-migrate/lit.site.cfg.in Wed Feb 27 07:09:24 2013
@@ -0,0 +1,28 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+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@"
+
+config.generated_tests_root = "@GENERATED_TESTS_ROOT@"
+config.substitutions.append(('%gen_root', config.generated_tests_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:
+    config.llvm_tools_dir = config.llvm_tools_dir % lit.params
+    config.llvm_libs_dir = config.llvm_libs_dir % lit.params
+except KeyError,e:
+    key, = e.args
+    lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
+
+# Let the main config do the real work.
+lit.load_config(config, "@CLANG_TOOLS_SOURCE_DIR@/test/lit.cfg")





More information about the cfe-commits mailing list