Use ctest to run all tests and print output.
Change-Id: Ib5a8513cc2d08adce49602b2590059b918b1ffda Reviewed-by: Alexander Neundorf <neundorf@kde.org> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
7e11fdd6e6
commit
3ea33062d4
@ -12,7 +12,5 @@ if (NOT \"$${CMAKE_ADD_FPIE_FLAGS}\" STREQUAL \"\")
|
|||||||
set(Qt5Core_COMPILE_FLAGS "-fPIE")
|
set(Qt5Core_COMPILE_FLAGS "-fPIE")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT \"$$QT_NAMESPACE\" STREQUAL \"\")
|
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
|
||||||
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
|
list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
|
||||||
list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
|
|
||||||
endif()
|
|
||||||
|
@ -1,33 +1,84 @@
|
|||||||
|
|
||||||
|
# This is an automatic test for the CMake configuration files.
|
||||||
|
# To run it,
|
||||||
|
# 1) mkdir build # Create a build directory
|
||||||
|
# 2) cd build
|
||||||
|
# 3) cmake .. # Run cmake on this directory.
|
||||||
|
# 4) ctest # Run ctest
|
||||||
|
#
|
||||||
|
# The expected output is something like:
|
||||||
|
#
|
||||||
|
# Start 1: pass1
|
||||||
|
# 1/7 Test #1: pass1 ............................ Passed 4.25 sec
|
||||||
|
# Start 2: pass2
|
||||||
|
# 2/7 Test #2: pass2 ............................ Passed 2.00 sec
|
||||||
|
# Start 3: pass3
|
||||||
|
# 3/7 Test #3: pass3 ............................ Passed 2.85 sec
|
||||||
|
# Start 4: fail4
|
||||||
|
# 4/7 Test #4: fail4 ............................ Passed 1.88 sec
|
||||||
|
# Start 5: fail5
|
||||||
|
# 5/7 Test #5: fail5 ............................ Passed 1.36 sec
|
||||||
|
# Start 6: pass_needsquoting_6
|
||||||
|
# 6/7 Test #6: pass_needsquoting_6 .............. Passed 2.88 sec
|
||||||
|
# Start 7: pass7
|
||||||
|
# 7/7 Test #7: pass7 ............................ Passed 0.93 sec
|
||||||
|
#
|
||||||
|
# Note that if Qt is not installed, or if it is installed to a
|
||||||
|
# non-standard prefix, the environment variable CMAKE_PREFIX_PATH
|
||||||
|
# needs to be set to the installation prefix or build prefix of Qt
|
||||||
|
# before running these tests.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
project(qmake_cmake_files)
|
project(qmake_cmake_files)
|
||||||
|
|
||||||
macro(_do_build _dir)
|
enable_testing()
|
||||||
try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${_dir}
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${_dir}
|
macro(expect_pass _dir)
|
||||||
${_dir}
|
string(REPLACE "(" "_" testname "${_dir}")
|
||||||
OUTPUT_VARIABLE Out
|
string(REPLACE ")" "_" testname "${testname}")
|
||||||
|
add_test(${testname} ${CMAKE_CTEST_COMMAND}
|
||||||
|
--build-and-test
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${_dir}"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${_dir}"
|
||||||
|
--build-generator ${CMAKE_GENERATOR}
|
||||||
|
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
||||||
)
|
)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(expect_pass _dir)
|
|
||||||
_do_build(${_dir})
|
|
||||||
if (NOT Result)
|
|
||||||
message(SEND_ERROR "Build failed: ${Out}")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(expect_fail _dir)
|
macro(expect_fail _dir)
|
||||||
_do_build(${_dir})
|
string(REPLACE "(" "_" testname "${_dir}")
|
||||||
|
string(REPLACE ")" "_" testname "${testname}")
|
||||||
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
|
||||||
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/CMakeLists.txt"
|
||||||
|
"
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
project(${_dir}_build)
|
||||||
|
|
||||||
|
try_compile(Result \${CMAKE_CURRENT_BINARY_DIR}/${_dir}
|
||||||
|
\${CMAKE_CURRENT_SOURCE_DIR}/${_dir}
|
||||||
|
${_dir}
|
||||||
|
)
|
||||||
if (Result)
|
if (Result)
|
||||||
message(SEND_ERROR "Build should fail, but did not: ${Out}")
|
message(SEND_ERROR \"Succeeded build which should fail\")
|
||||||
endif()
|
endif()
|
||||||
|
"
|
||||||
|
)
|
||||||
|
add_test(${testname} ${CMAKE_CTEST_COMMAND}
|
||||||
|
--build-and-test
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/build"
|
||||||
|
--build-generator ${CMAKE_GENERATOR}
|
||||||
|
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
||||||
|
)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_GREATER 2.8.7)
|
if(${CMAKE_VERSION} VERSION_GREATER 2.8.7)
|
||||||
# Requires CMAKE_AUTOMOC function in CMake 2.8.7
|
# Requires CMAKE_AUTOMOC function in CMake 2.8.7
|
||||||
expect_pass(pass1)
|
expect_pass(pass1)
|
||||||
|
else()
|
||||||
|
message("CMake version older than 2.8.7. Not running test \"pass1\"")
|
||||||
endif()
|
endif()
|
||||||
expect_pass(pass2)
|
expect_pass(pass2)
|
||||||
expect_pass(pass3)
|
expect_pass(pass3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user