diff options
author | Alex Neundorf <neundorf@kde.org> | 2011-12-18 21:24:11 +0100 |
---|---|---|
committer | Alex Neundorf <neundorf@kde.org> | 2011-12-18 21:24:11 +0100 |
commit | fe76108ad56f0481c80afbf42791a106d7b038ca (patch) | |
tree | 4d3367c1e20d4215559321ccbdf340ecc3da622d /tests | |
parent | 9e2e47d30d7a566423a91f1a12e832be0b3948fd (diff) | |
download | extra-cmake-modules-fe76108ad56f0481c80afbf42791a106d7b038ca.tar.gz extra-cmake-modules-fe76108ad56f0481c80afbf42791a106d7b038ca.tar.bz2 |
-enable testing
-add test ExecuteAllModules, which is the same as FindModulesExecuteAll in CMake: include (and execute) all *cmake files, to make sure they are not completely broken
Alex
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 20 | ||||
-rw-r--r-- | tests/ExecuteAllModules/CMakeLists.txt | 31 | ||||
-rw-r--r-- | tests/ExecuteAllModules/main.c | 4 |
3 files changed, 55 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..4347a92d --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,20 @@ +# a macro for tests that have a simple format where the name matches the +# directory and project +macro(ADD_TEST_MACRO NAME COMMAND) + string(REPLACE "." "/" dir "${NAME}") + string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}") + add_test(${NAME} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMAKE_SOURCE_DIR}/tests/${dir}" + "${CMAKE_BINARY_DIR}/tests/${dir}" + --build-two-config + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-project ${proj} + ${${NAME}_EXTRA_OPTIONS} + --test-command ${COMMAND} ${ARGN}) +# list(APPEND TEST_BUILD_DIRS "${CMAKE_BINARY_DIR}/tests/${dir}") +endmacro(ADD_TEST_MACRO) + + +add_test_macro(ExecuteAllModules ExecuteAllModules) diff --git a/tests/ExecuteAllModules/CMakeLists.txt b/tests/ExecuteAllModules/CMakeLists.txt new file mode 100644 index 00000000..43aa1ba5 --- /dev/null +++ b/tests/ExecuteAllModules/CMakeLists.txt @@ -0,0 +1,31 @@ +# This file includes all *.cmake files, so they are all executed. +# As it is it doesn't test a lot. +# It makes sure that the modules don't contain basic syntax errors. +# It also makes sure that modules don't fail with an error if something +# wasn't found but REQUIRED was not given. +# +# I guess more things could be added, like checking whether variables are +# defined after running the modules (e.g. FOO_FOUND etc.). +project(ExecuteAllModules) +cmake_minimum_required(VERSION 2.8) + +file(GLOB all_find_modules "${CMAKE_CURRENT_SOURCE_DIR}/../../find-modules/Find*cmake") +file(GLOB all_other_modules "${CMAKE_CURRENT_SOURCE_DIR}/../../modules/*cmake") + +foreach(module ${all_find_modules} ${all_other_modules}) + message(STATUS "module: ${module}") + include("${module}") + + # get the "basename" of the package, so the existence of variables like + # FOO_FOUND could be tested later on, Alex + string(REGEX REPLACE ".+Find([^\\.]+)\\.cmake" "\\1" packageName "${module}") + string(TOUPPER "${packageName}" packageNameUpper) + +# disabled for now, since too many modules break: +# if(NOT DEFINED ${packageNameUpper}_FOUND) +# message(SEND_ERROR "${packageNameUpper}_FOUND not defined !") +# endif(NOT DEFINED ${packageNameUpper}_FOUND) + +endforeach(module ${all_modules}) + +add_executable(ExecuteAllModules main.c) diff --git a/tests/ExecuteAllModules/main.c b/tests/ExecuteAllModules/main.c new file mode 100644 index 00000000..c13815ce --- /dev/null +++ b/tests/ExecuteAllModules/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} |