SquishTestScript.cmake 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #
  7. #
  8. #
  9. #
  10. #
  11. # This script launches a GUI test using Squish. You should not call the
  12. # script directly; instead, you should access it via the SQUISH_ADD_TEST
  13. # macro that is defined in FindSquish.cmake.
  14. #
  15. # This script starts the Squish server, launches the test on the client,
  16. # and finally stops the squish server. If any of these steps fail
  17. # (including if the tests do not pass) then a fatal error is raised.
  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}'")
  21. message(STATUS "squish_version='${squish_version}'")
  22. message(STATUS "squish_server_executable='${squish_server_executable}'")
  23. message(STATUS "squish_client_executable='${squish_client_executable}'")
  24. message(STATUS "squish_libqtdir ='${squish_libqtdir}'")
  25. message(STATUS "squish_test_suite='${squish_test_suite}'")
  26. message(STATUS "squish_test_case='${squish_test_case}'")
  27. message(STATUS "squish_wrapper='${squish_wrapper}'")
  28. message(STATUS "squish_env_vars='${squish_env_vars}'")
  29. message(STATUS "squish_module_dir='${squish_module_dir}'")
  30. message(STATUS "squish_settingsgroup='${squish_settingsgroup}'")
  31. message(STATUS "squish_pre_command='${squish_pre_command}'")
  32. message(STATUS "squish_post_command='${squish_post_command}'")
  33. # parse environment variables
  34. foreach(i ${squish_env_vars})
  35. message(STATUS "parsing env var key/value pair ${i}")
  36. string(REGEX MATCH "([^=]*)=(.*)" squish_env_name ${i})
  37. message(STATUS "key=${CMAKE_MATCH_1}")
  38. message(STATUS "value=${CMAKE_MATCH_2}")
  39. set ( ENV{${CMAKE_MATCH_1}} ${CMAKE_MATCH_2} )
  40. endforeach()
  41. if (QT4_INSTALLED)
  42. # record Qt lib directory
  43. set ( ENV{${SQUISH_LIBQTDIR}} ${squish_libqtdir} )
  44. endif ()
  45. if(squish_pre_command)
  46. message(STATUS "Executing pre command: ${squish_pre_command}")
  47. execute_process(COMMAND "${squish_pre_command}")
  48. endif()
  49. # run the test
  50. if("${squish_version}" STREQUAL "4")
  51. if (WIN32)
  52. 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}
  53. RESULT_VARIABLE test_rv )
  54. elseif(UNIX)
  55. 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}
  56. RESULT_VARIABLE test_rv )
  57. endif ()
  58. else()
  59. if (WIN32)
  60. execute_process(COMMAND ${squish_module_dir}/SquishRunTestCase.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut}
  61. RESULT_VARIABLE test_rv )
  62. elseif(UNIX)
  63. execute_process(COMMAND ${squish_module_dir}/SquishRunTestCase.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut}
  64. RESULT_VARIABLE test_rv )
  65. endif ()
  66. endif()
  67. if(squish_post_command)
  68. message(STATUS "Executing post command: ${squish_post_command}")
  69. execute_process(COMMAND "${squish_post_command}")
  70. endif()
  71. # check for an error with running the test
  72. if(NOT "${test_rv}" STREQUAL "0")
  73. message(FATAL_ERROR "Error running Squish test")
  74. endif()