зеркало из https://github.com/microsoft/clang.git
First cut at regression testing Clang with CMake
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72945 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
99ba36de0d
Коммит
eb357b67b4
|
@ -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})
|
|
@ -0,0 +1 @@
|
|||
int dummy() { return 0; }
|
|
@ -54,3 +54,4 @@ add_subdirectory(lib)
|
|||
add_subdirectory(tools)
|
||||
|
||||
# TODO: docs.
|
||||
add_subdirectory(test)
|
|
@ -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)
|
Загрузка…
Ссылка в новой задаче