diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-02-27 18:16:23 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-28 19:46:57 +0100 |
commit | 60b432ae2b4248c9bc7b72cdd8f6c948ce6c4f2d (patch) | |
tree | 2f3d056b5dd6f199ee9ec0d494f01222b2fd9af6 /tests/manual | |
parent | e5e42259643ee8fca019c2f46cdda8603a9cb733 (diff) | |
download | qttools-60b432ae2b4248c9bc7b72cdd8f6c948ce6c4f2d.tar.gz |
Port the tests in qttools to ctest.
Change-Id: I30bcbe2e38d47a390906c01efee5025bb868ca04
Reviewed-by: Alexander Neundorf <neundorf@kde.org>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/cmake/CMakeLists.txt | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt index c866630a2..28019680b 100644 --- a/tests/manual/cmake/CMakeLists.txt +++ b/tests/manual/cmake/CMakeLists.txt @@ -1,28 +1,69 @@ +# 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/2 Test #1: pass1 ............................ Passed 1.88 sec +# Start 2: pass2 +# 2/2 Test #2: pass2 ............................ Passed 0.60 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) project(qmake_cmake_files) -macro(_do_build _dir) - try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${_dir} - ${CMAKE_CURRENT_SOURCE_DIR}/${_dir} - ${_dir} - OUTPUT_VARIABLE Out - ) -endmacro() +enable_testing() macro(expect_pass _dir) - _do_build(${_dir}) - if (NOT Result) - message(SEND_ERROR "Build failed: ${Out}") - endif() + string(REPLACE "(" "_" testname "${_dir}") + 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() macro(expect_fail _dir) - _do_build(${_dir}) - if (Result) - message(SEND_ERROR "Build should fail, but did not: ${Out}") - endif() + 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} + OUTPUT_VARIABLE Out + ) + message(\"\${Out}\") + if (Result) + message(SEND_ERROR \"Succeeded build which should fail\") + 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() expect_pass(pass1) |