Merge branch 'release-4.0'
[kiteware-cmake.git] / Modules / SquishTestScript.cmake
blobd3f8ebf9bdf119639d773ccde9388f5ccf430002
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
5 SquishTestScript
6 ----------------
7 .. deprecated:: 3.0
9 This script launches a GUI test using Squish.  You should not call the
10 script directly; instead, you should access it via the SQUISH_ADD_TEST
11 macro that is defined in FindSquish.cmake.
13 This script starts the Squish server, launches the test on the client,
14 and finally stops the squish server.  If any of these steps fail
15 (including if the tests do not pass) then a fatal error is raised.
16 #]=======================================================================]
18 # print out the variable that we are using
19 message(STATUS "squish_aut='${squish_aut}'")
20 message(STATUS "squish_aut_dir='${squish_aut_dir}'")
22 message(STATUS "squish_version='${squish_version}'")
23 message(STATUS "squish_server_executable='${squish_server_executable}'")
24 message(STATUS "squish_client_executable='${squish_client_executable}'")
25 message(STATUS "squish_libqtdir ='${squish_libqtdir}'")
26 message(STATUS "squish_test_suite='${squish_test_suite}'")
27 message(STATUS "squish_test_case='${squish_test_case}'")
28 message(STATUS "squish_wrapper='${squish_wrapper}'")
29 message(STATUS "squish_env_vars='${squish_env_vars}'")
30 message(STATUS "squish_module_dir='${squish_module_dir}'")
31 message(STATUS "squish_pre_command='${squish_pre_command}'")
32 message(STATUS "squish_post_command='${squish_post_command}'")
34 # parse environment variables
35 foreach(i ${squish_env_vars})
36   message(STATUS "parsing env var key/value pair ${i}")
37   string(REGEX MATCH "([^=]*)=(.*)" squish_env_name ${i})
38   message(STATUS "key=${CMAKE_MATCH_1}")
39   message(STATUS "value=${CMAKE_MATCH_2}")
40   set ( ENV{${CMAKE_MATCH_1}} ${CMAKE_MATCH_2} )
41 endforeach()
43 if (QT4_INSTALLED)
44   # record Qt lib directory
45   set ( ENV{${SQUISH_LIBQTDIR}} ${squish_libqtdir} )
46 endif ()
48 if(squish_pre_command)
49   message(STATUS "Executing pre command: ${squish_pre_command}")
50   execute_process(COMMAND "${squish_pre_command}")
51 endif()
53 # run the test
54 if("${squish_version}" STREQUAL "4")
55   if (WIN32)
56     execute_process(COMMAND ${squish_module_dir}/Squish4RunTestCase.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_suite} ${squish_test_case} ${squish_aut} ${squish_aut_dir}
57                     RESULT_VARIABLE test_rv )
58   elseif(UNIX)
59     execute_process(COMMAND ${squish_module_dir}/Squish4RunTestCase.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_suite} ${squish_test_case} ${squish_aut} ${squish_aut_dir}
60                     RESULT_VARIABLE test_rv )
61   endif ()
63 else()
65   if (WIN32)
66     execute_process(COMMAND ${squish_module_dir}/SquishRunTestCase.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut}
67                     RESULT_VARIABLE test_rv )
68   elseif(UNIX)
69     execute_process(COMMAND ${squish_module_dir}/SquishRunTestCase.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut}
70                     RESULT_VARIABLE test_rv )
71   endif ()
72 endif()
74 if(squish_post_command)
75   message(STATUS "Executing post command: ${squish_post_command}")
76   execute_process(COMMAND "${squish_post_command}")
77 endif()
79 # check for an error with running the test
80 if(NOT "${test_rv}" STREQUAL "0")
81   message(FATAL_ERROR "Error running Squish test")
82 endif()