Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / SquishTestScript.cmake
1 #
2 # This script launches a GUI test using Squish.  You should not call
3 # the script directly; instead, you should access it via the
4 # SQUISH_ADD_TEST macro that is defined in FindSquish.cmake.
5 #
6 # This script starts the Squish server, launches the test on the
7 # client, and finally stops the squish server.  If any of these steps
8 # fail (including if the tests do not pass) then a fatal error is
9 # raised.
10 #
11
12 #=============================================================================
13 # Copyright 2008-2009 Kitware, Inc.
14 #
15 # Distributed under the OSI-approved BSD License (the "License");
16 # see accompanying file Copyright.txt for details.
17 #
18 # This software is distributed WITHOUT ANY WARRANTY; without even the
19 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 # See the License for more information.
21 #=============================================================================
22 # (To distribute this file outside of CMake, substitute the full
23 #  License text for the above reference.)
24
25 cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
26
27 # print out the variable that we are using
28 message(STATUS "squish_aut='${squish_aut}'")
29
30 message(STATUS "squish_server_executable='${squish_server_executable}'")
31 message(STATUS "squish_client_executable='${squish_client_executable}'")
32 message(STATUS "squish_libqtdir ='${squish_libqtdir}'")
33 message(STATUS "squish_test_case='${squish_test_case}'")
34 message(STATUS "squish_wrapper='${squish_wrapper}'")
35 message(STATUS "squish_env_vars='${squish_env_vars}'")
36
37 # parse enviornment variables
38 foreach(i ${squish_env_vars})
39   message(STATUS "parsing env var key/value pair ${i}")
40   string(REGEX MATCH "([^=]*)=(.*)" squish_env_name ${i})
41   message(STATUS "key=${CMAKE_MATCH_1}")
42   message(STATUS "value=${CMAKE_MATCH_2}")
43   set ( ENV{${CMAKE_MATCH_1}} ${CMAKE_MATCH_2} )
44 endforeach()
45
46 if (QT4_INSTALLED)
47   # record Qt lib directory
48   set ( ENV{${SQUISH_LIBQTDIR}} ${squish_libqtdir} )
49 endif ()
50
51 # run the test
52 if (WIN32)
53   execute_process(
54     COMMAND ${CMAKE_ROOT}/Modules/SquishRunTestCase.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut}
55     RESULT_VARIABLE test_rv
56     )
57 endif ()
58
59 if (UNIX)
60   execute_process(
61     COMMAND ${CMAKE_ROOT}/Modules/SquishRunTestCase.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut}
62     RESULT_VARIABLE test_rv
63     )
64 endif ()
65
66 # check for an error with running the test
67 if(NOT "${test_rv}" STREQUAL "0")
68   message(FATAL_ERROR "Error running Squish test")
69 endif()
70
71
72