SquishTestScript.cmake 3.5 KB

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