RunCMake: Allow specifying the directory to run tests in.

This commit is contained in:
Stephen Kelly 2015-02-09 08:39:18 +01:00
parent 1c3918ff02
commit 68d29f5190
1 changed files with 14 additions and 3 deletions

View File

@ -1,17 +1,28 @@
# See adjacent README.rst for documentation of this test infrastructure. # See adjacent README.rst for documentation of this test infrastructure.
macro(add_RunCMake_test test) macro(add_RunCMake_test test)
set(TEST_ARGS ${ARGN})
if ("${ARGV1}" STREQUAL "TEST_DIR")
if ("${ARGV2}" STREQUAL "")
message(FATAL_ERROR "Invalid args")
endif()
set(Test_Dir ${ARGV2})
list(REMOVE_AT TEST_ARGS 0)
list(REMOVE_AT TEST_ARGS 0)
else()
set(Test_Dir ${test})
endif()
add_test(NAME RunCMake.${test} COMMAND ${CMAKE_CMAKE_COMMAND} add_test(NAME RunCMake.${test} COMMAND ${CMAKE_CMAKE_COMMAND}
-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}
-DRunCMake_GENERATOR=${CMAKE_GENERATOR} -DRunCMake_GENERATOR=${CMAKE_GENERATOR}
-DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
-DRunCMake_MAKE_PROGRAM=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} -DRunCMake_MAKE_PROGRAM=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
-DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test} -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${Test_Dir}
-DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test} -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test}
${${test}_ARGS} ${${test}_ARGS}
${ARGN} ${TEST_ARGS}
-P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/RunCMakeTest.cmake" -P "${CMAKE_CURRENT_SOURCE_DIR}/${Test_Dir}/RunCMakeTest.cmake"
) )
endmacro() endmacro()