[PATCH] Custom lit.site.cfg configuration for cpp11-migrate
Edwin Vane
edwin.vane at intel.com
Tue Feb 26 10:29:46 PST 2013
Hi klimek, chandlerc, echristo,
To afford cpp11-migrate 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.
Removed use of --param clang_site_config. Not necessary when running
tests using the build system.
http://llvm-reviews.chandlerc.com/D467
Files:
test/CMakeLists.txt
test/Makefile
test/cpp11-migrate/CMakeLists.txt
test/cpp11-migrate/Makefile
test/cpp11-migrate/lit.site.cfg.in
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -26,17 +26,18 @@
# 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")
Index: test/Makefile
===================================================================
--- test/Makefile
+++ test/Makefile
@@ -27,7 +27,9 @@
# 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 @@
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
Index: test/cpp11-migrate/CMakeLists.txt
===================================================================
--- test/cpp11-migrate/CMakeLists.txt
+++ test/cpp11-migrate/CMakeLists.txt
@@ -44,17 +44,28 @@
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
)
Index: test/cpp11-migrate/Makefile
===================================================================
--- test/cpp11-migrate/Makefile
+++ test/cpp11-migrate/Makefile
@@ -34,31 +34,53 @@
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
$(foreach script, $(GENERATOR_SCRIPTS), $(eval $(call autogenerate-file,$(script))))
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
@$(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_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
Index: test/cpp11-migrate/lit.site.cfg.in
===================================================================
--- /dev/null
+++ test/cpp11-migrate/lit.site.cfg.in
@@ -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")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D467.1.patch
Type: text/x-patch
Size: 8027 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130226/046e2e4c/attachment.bin>
More information about the cfe-commits
mailing list