[cfe-commits] r72945 - in /cfe/trunk: CMake/ CMake/RunTests/ CMake/RunTests/CMakeLists.txt CMake/RunTests/dummy.c CMakeLists.txt test/CMakeLists.txt
Douglas Gregor
dgregor at apple.com
Fri Jun 5 09:00:31 PDT 2009
Author: dgregor
Date: Fri Jun 5 11:00:31 2009
New Revision: 72945
URL: http://llvm.org/viewvc/llvm-project?rev=72945&view=rev
Log:
First cut at regression testing Clang with CMake
Added:
cfe/trunk/CMake/
cfe/trunk/CMake/RunTests/
cfe/trunk/CMake/RunTests/CMakeLists.txt (with props)
cfe/trunk/CMake/RunTests/dummy.c (with props)
cfe/trunk/test/CMakeLists.txt (with props)
Modified:
cfe/trunk/CMakeLists.txt
Added: cfe/trunk/CMake/RunTests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMake/RunTests/CMakeLists.txt?rev=72945&view=auto
==============================================================================
--- cfe/trunk/CMake/RunTests/CMakeLists.txt (added)
+++ cfe/trunk/CMake/RunTests/CMakeLists.txt Fri Jun 5 11:00:31 2009
@@ -0,0 +1,44 @@
+# Project that runs the Clang regression tests for a given glob pattern.
+#
+# There are several CMake cache variabes that must be set for this
+# project to work:
+#
+# CLANG_TEST_RUNNER: The TestRunner.sh shell script, which is used to test
+# Clang.
+#
+# CLANG_TEST_GLOB_PATTERN: Set to a GLOB pattern to identify the kind of
+# tests, e.g., *.cpp for C++ tests.
+#
+# LLVM_TOOLS_PATH: The directory where the Clang and LLVM tool
+# executables (such as opt) are generated.
+#
+# LLVM_SCRIPTS_PATH: The directory where the LLVM test scripts are
+# located.
+cmake_minimum_required(VERSION 2.6)
+project(ClangTest)
+
+enable_testing()
+
+# Computes the normalized name of a test from its path name.
+macro(compute_test_name var filename)
+ get_filename_component(test_name ${filename} NAME_WE)
+ get_filename_component(test_path ${filename} PATH)
+ get_filename_component(test_lastpath ${test_path} NAME_WE)
+ set(${var} "${test_lastpath}-${test_name}")
+endmacro()
+
+# FIXME: Total hack!
+file(WRITE dummy.c "int dummy() { return 0; }")
+add_library(dummy dummy.c)
+
+set(PATH $ENV{PATH})
+set(PATH "${LLVM_TOOLS_PATH}:${LLVM_SCRIPTS_PATH}:${PATH}")
+message(STATUS "Globbing for tests with ${CLANG_TEST_GLOB_PATTERN}")
+file(GLOB_RECURSE tests ${CLANG_TEST_GLOB_PATTERN})
+foreach(test ${tests})
+ compute_test_name(testname ${test})
+ message(STATUS "Adding test ${testname} with file ${test}")
+ add_test(${testname} ${CLANG_TEST_RUNNER} ${test})
+ set_tests_properties(${testname} PROPERTIES
+ ENVIRONMENT "PATH=${PATH}")
+endforeach(test ${tests})
\ No newline at end of file
Propchange: cfe/trunk/CMake/RunTests/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/CMake/RunTests/CMakeLists.txt
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/CMake/RunTests/CMakeLists.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cfe/trunk/CMake/RunTests/dummy.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMake/RunTests/dummy.c?rev=72945&view=auto
==============================================================================
--- cfe/trunk/CMake/RunTests/dummy.c (added)
+++ cfe/trunk/CMake/RunTests/dummy.c Fri Jun 5 11:00:31 2009
@@ -0,0 +1 @@
+int dummy() { return 0; }
\ No newline at end of file
Propchange: cfe/trunk/CMake/RunTests/dummy.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/CMake/RunTests/dummy.c
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/CMake/RunTests/dummy.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cfe/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=72945&r1=72944&r2=72945&view=diff
==============================================================================
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Jun 5 11:00:31 2009
@@ -54,3 +54,4 @@
add_subdirectory(tools)
# TODO: docs.
+add_subdirectory(test)
\ No newline at end of file
Added: cfe/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=72945&view=auto
==============================================================================
--- cfe/trunk/test/CMakeLists.txt (added)
+++ cfe/trunk/test/CMakeLists.txt Fri Jun 5 11:00:31 2009
@@ -0,0 +1,33 @@
+find_file(CLANG_TEST_RUNNER TestRunner.sh PATHS ${CMAKE_CURRENT_SOURCE_DIR}
+ DOC "Clang's regression testing script")
+mark_as_advanced(CLANG_TEST_RUNNER)
+
+get_target_property(LLVM_TOOLS_PATH clang RUNTIME_OUTPUT_DIRECTORY)
+
+add_custom_target(clang-test COMMENT "Running Clang regression tests")
+
+macro(add_clang_test_suite language target extension)
+add_custom_target(${target}
+ ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ ${LLVM_SOURCE_DIR}/tools/clang/CMake/RunTests
+ ${CMAKE_CURRENT_BINARY_DIR}/${target}
+ --build-generator ${CMAKE_GENERATOR}
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-project ClangTest
+ --build-target test
+ --build-options
+ "-DCLANG_TEST_RUNNER=${CLANG_TEST_RUNNER}"
+ "-DCLANG_TEST_GLOB_PATTERN=${CMAKE_CURRENT_SOURCE_DIR}/*.${extension}"
+ "-DLLVM_TOOLS_PATH=${LLVM_TOOLS_PATH}"
+ "-DLLVM_SCRIPTS_PATH=${LLVM_SOURCE_DIR}/test/Scripts"
+ COMMENT "Running Clang ${language} regression tests")
+
+ add_dependencies(clang-test ${target})
+endmacro(add_clang_test_suite)
+
+add_clang_test_suite(C clang-test-c c)
+add_clang_test_suite(Objective-C clang-test-objc m)
+add_clang_test_suite(C++ clang-test-cxx cpp)
+add_clang_test_suite(Objective-C++ clang-test-objcxx mm)
+add_clang_test_suite(Assembler clang-test-asm S)
Propchange: cfe/trunk/test/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CMakeLists.txt
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/CMakeLists.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list