summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-04 19:56:28 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-02-04 20:11:26 -0300
commitc306628bd2b06ec5a9a734e33a8d948be1811649 (patch)
tree4d2ffed47ccb72cc966072f00358125ba91dbb69
parent2456d853d7aa4254ca0ad63b48f667796fc51fe1 (diff)
Added a CMake script that sets some environment variables before calling the tests.
This is used as a workaround to a CMake 2.6 limitation that prevents environment variables to be set for tests. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Lauro Neto <lauro.neto@openbossa.org>
-rw-r--r--tests/CMakeLists.txt7
-rw-r--r--tests/test_generator/CMakeLists.txt15
-rw-r--r--tests/test_generator/run_test.cmake11
3 files changed, 25 insertions, 8 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b8facb00..82c4d3c7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,9 +1,4 @@
-if(CMAKE_VERSION VERSION_LESS 2.8)
- # Versions lesser than 2.8 can not set environment variables for tests.
- message("CMake version greater than 2.8 necessary to run certain tests.")
-else()
- add_subdirectory(test_generator)
-endif()
+add_subdirectory(test_generator)
if (NOT APIEXTRACTOR_DOCSTRINGS_DISABLED)
project(sphinxtabletest)
diff --git a/tests/test_generator/CMakeLists.txt b/tests/test_generator/CMakeLists.txt
index 180bba27..498d6624 100644
--- a/tests/test_generator/CMakeLists.txt
+++ b/tests/test_generator/CMakeLists.txt
@@ -31,13 +31,24 @@ if(WIN32)
string(REPLACE ";" "\\;" ENV_QT_PLUGIN_PATH "${ENV_QT_PLUGIN_PATH}")
endif()
+macro(m_add_test testname)
+ if(CMAKE_VERSION VERSION_LESS 2.8)
+ add_test(${testname} ${CMAKE_COMMAND} -DTEST=${testname}
+ -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}
+ -DENV_PATH=${ENV_PATH} -DENV_QT_PLUGIN_PATH=${ENV_QT_PLUGIN_PATH}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/run_test.cmake)
+ else()
+ add_test(${testname} ${testname})
+ set_property(TEST ${testname} PROPERTY ENVIRONMENT "PATH=${ENV_PATH}" "QT_PLUGIN_PATH=${ENV_QT_PLUGIN_PATH}")
+ endif()
+endmacro()
+
macro(declare_test testname)
qt4_automoc("${testname}.cpp")
add_executable(${testname} "${testname}.cpp")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(${testname} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY})
- add_test(${testname} ${testname})
- set_property(TEST ${testname} PROPERTY ENVIRONMENT "PATH=${ENV_PATH}" "QT_PLUGIN_PATH=${ENV_QT_PLUGIN_PATH}")
+ m_add_test(${testname})
endmacro(declare_test testname)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/test_global.h"
diff --git a/tests/test_generator/run_test.cmake b/tests/test_generator/run_test.cmake
new file mode 100644
index 00000000..34a821d8
--- /dev/null
+++ b/tests/test_generator/run_test.cmake
@@ -0,0 +1,11 @@
+# The tests are run through this script due to a limitation
+# on versions of CMake lesser than 2.8, that prevent setting
+# environment variables for tests from working.
+
+set(ENV{PATH} "${ENV_PATH}")
+set(ENV{QT_PLUGIN_PATH} "${ENV_QT_PLUGIN_PATH}")
+execute_process(COMMAND ${TEST} WORKING_DIRECTORY "${WORKDIR}" RESULT_VARIABLE OK)
+
+if(NOT OK EQUAL 0)
+ message(SEND_ERROR "${TEST} failed!")
+endif()