aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-02-27 13:09:24 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-02-27 13:09:24 +0000
commit13542ab52683edc6e7be897ec22a887daf12c5a5 (patch)
treefed30e595c6bc702d4b074d382c53d005475e65e /test
parentd5b7ac70ad285de57d439c260a32300c764a9b6f (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@176184 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt13
-rw-r--r--test/Makefile7
-rw-r--r--test/cpp11-migrate/CMakeLists.txt23
-rw-r--r--test/cpp11-migrate/Makefile34
-rw-r--r--test/cpp11-migrate/lit.site.cfg.in28
5 files changed, 83 insertions, 22 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 5c62cf03..7ccd5306 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -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")
diff --git a/test/Makefile b/test/Makefile
index 9a1b9986..41be4032 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -27,7 +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.
+# 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
diff --git a/test/cpp11-migrate/CMakeLists.txt b/test/cpp11-migrate/CMakeLists.txt
index 8990d3ef..000e0f7d 100644
--- a/test/cpp11-migrate/CMakeLists.txt
+++ b/test/cpp11-migrate/CMakeLists.txt
@@ -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
)
diff --git a/test/cpp11-migrate/Makefile b/test/cpp11-migrate/Makefile
index 4b574750..86943930 100644
--- a/test/cpp11-migrate/Makefile
+++ b/test/cpp11-migrate/Makefile
@@ -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), $(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
@@ -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
diff --git a/test/cpp11-migrate/lit.site.cfg.in b/test/cpp11-migrate/lit.site.cfg.in
new file mode 100644
index 00000000..89002f30
--- /dev/null
+++ b/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")