From: Chandler Carruth Date: Thu, 7 Mar 2013 10:09:47 +0000 (+0000) Subject: Switch from autogenerating tests to using the preprocessor. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=074a3568fca118fd59fdc8d1729580d5ad295654;p=platform%2Fupstream%2Fllvm.git Switch from autogenerating tests to using the preprocessor. NOTE: You may need to run 'make clean' or 'ninja -t clean' etc!!! This is due to really nasty bug/interactions between CMake/configure/make/Ninja/LIT... This commit tries to back out the support for generating test cases as part of the build system due to the issues I brought up in post-commit review: 1) It adds a *lot* of complexity and fragility to the build system. See the number of commits required to try to get all the bots happy. 2) It isn't really necessary -- we can already run scripts to generate things with the RUN lines of a test. 3) It makes the tests somewhat harder to debug as they cross between more domains. 4) In almost all cases it isn't really needed or it can be done directly using the preprocessor. I should have been more proactive reviewing this, and I'm really sorry about the churn here. =/ To help keep track of what commits are going where, this backs out most of the non-test-changes from these revisions: r176397 r176373 r176293 r176184 r175744 r175624 r175545 r175544 There were several trivial or cleanup changes to the lit files or other files. Some of these looked ok, but I didn't try to tease them apart... Edwin, if you know what to look for, please carry on with the cleanups there, and sorry for hosing stuff here but I'm not much of a Python person, and so I was erring on the side of cautiously backing out the change. I've tried to preserve the test changes everywhere I could, but review is appreciated here in case I missed some. I then re-wrote the tests to use the preprocessor rather than python to expand to the various bits of code. The nicest part of this is that now all the files are just C++ code. They edit and behave like C++ code, etc. RUN lines with different -D flags are used to run the same test over multiple different configurations, and includes bracketed in special defines are used to flesh out a collection of standard interface stubs to test interactions between pieces. These probably aren't perfect yet, but I think its an improvement (at least in terms of build system complexity) and will hopefully be a useful demonstration of the technique I prefer for these types of tests. llvm-svn: 176627 --- diff --git a/clang-tools-extra/Makefile b/clang-tools-extra/Makefile index 602f146..dfbca69 100644 --- a/clang-tools-extra/Makefile +++ b/clang-tools-extra/Makefile @@ -12,15 +12,29 @@ CLANG_LEVEL := ../.. include $(CLANG_LEVEL)/../../Makefile.config PARALLEL_DIRS := remove-cstr-calls tool-template clang-format cpp11-migrate -DIRS := test include $(CLANG_LEVEL)/Makefile -# Custom target. Pass request to test/Makefile that knows what to do. To access -# this target you'd issue: -# -# make -C /tools/clang/tools/extra test +### +# Handle the nested test suite. + +ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT)) +$(RecursiveTargets):: + $(Verb) for dir in test; do \ + if [ -f $(PROJ_SRC_DIR)/$${dir}/Makefile ] && [ ! -f $${dir}/Makefile ]; then \ + $(MKDIR) $${dir}; \ + $(CP) $(PROJ_SRC_DIR)/$${dir}/Makefile $${dir}/Makefile; \ + fi \ + done +endif + test:: - @ $(MAKE) -C test test + @ $(MAKE) -C test + +report:: + @ $(MAKE) -C test report + +clean:: + @ $(MAKE) -C test clean -.PHONY: test +.PHONY: test report clean diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt index 7ccd530..195852d 100644 --- a/clang-tools-extra/test/CMakeLists.txt +++ b/clang-tools-extra/test/CMakeLists.txt @@ -7,37 +7,28 @@ set(CLANG_TOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") set(CLANG_TOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") -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 ) +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() + set(CLANG_TOOLS_TEST_DEPS # Base line deps. clang clang-headers FileCheck count not - remove-cstr-calls clang-format - - cpp11-migrate cpp11-migrate-autogen + # Individual tools we test. + remove-cstr-calls cpp11-migrate clang-format ) -add_lit_testsuite(check-clang-tools "Running regression tests for Clang extra tools" +add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests" ${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/clang-tools-extra/test/Makefile b/clang-tools-extra/test/Makefile index 3c8ba45..e75b68f 100644 --- a/clang-tools-extra/test/Makefile +++ b/clang-tools-extra/test/Makefile @@ -8,8 +8,6 @@ ##===----------------------------------------------------------------------===## CLANG_LEVEL := ../../.. -include $(CLANG_LEVEL)/../../Makefile.config -DIRS := cpp11-migrate include $(CLANG_LEVEL)/Makefile # Test in all immediate subdirectories if unset. @@ -25,11 +23,6 @@ TESTDIRS := $(TESTDIRS:$(PROJ_SRC_DIR)%=$(PROJ_OBJ_DIR)%) # Allow EXTRA_TESTDIRS to provide additional test directories. TESTDIRS += $(EXTRA_TESTDIRS) -# 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 ifdef VERBOSE TESTARGS = -v @@ -38,16 +31,14 @@ 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 all:: lit.site.cfg - -# Run just the Clang extra tools tests. This target assumes 'make (all)' has -# been run previously as that target is responsible for generating lit config -# files and auto-generated tests. -test:: @ echo '--- Running the Clang extra tools tests for $(TARGET_TRIPLE) ---' @ $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py \ $(LIT_ARGS) $(TESTARGS) $(TESTDIRS) @@ -55,7 +46,7 @@ test:: FORCE: lit.site.cfg: FORCE - @echo "Making lit.site.cfg for Clang extra tools..." + @echo "Making Clang extra tools' 'lit.site.cfg' file..." @$(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 @@ -63,13 +54,10 @@ 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 clean:: @ find . -name Output | xargs rm -fr -.PHONY: all test clean +.PHONY: all report clean diff --git a/clang-tools-extra/test/cpp11-migrate/CMakeLists.txt b/clang-tools-extra/test/cpp11-migrate/CMakeLists.txt deleted file mode 100644 index 000e0f7..0000000 --- a/clang-tools-extra/test/cpp11-migrate/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ - -# List of generator scripts. Generator scripts must: -# * Be written in python -# * Output their result to standard out. -# * Be named as gen_X.py where X will be the name of the auto-generated file. -set(generator_scripts - UseAuto/gen_basic_std_iterator_tests.cpp.py - UseAuto/Inputs/gen_my_std.h.py - ) - -# macro that runs a generator script to produce an auto-generated file. -# Generator scripts must follow scheme above. The resulting file is placed in: -# ${CMAKE_CURRENT_BINARY_DIR})/generated_tests/dirname(