SquishTestScript.cmake 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. # Copyright 2008-2009 Kitware, Inc.
  13. #
  14. # Distributed under the OSI-approved BSD License (the "License");
  15. # see accompanying file Copyright.txt for details.
  16. #
  17. # This software is distributed WITHOUT ANY WARRANTY; without even the
  18. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  19. # See the License for more information.
  20. #=============================================================================
  21. # (To distribute this file outside of CMake, substitute the full
  22. # License text for the above reference.)
  23. # print out the variable that we are using
  24. message(STATUS "squish_aut='${squish_aut}'")
  25. message(STATUS "squish_aut_dir='${squish_aut_dir}'")
  26. message(STATUS "squish_version='${squish_version}'")
  27. message(STATUS "squish_server_executable='${squish_server_executable}'")
  28. message(STATUS "squish_client_executable='${squish_client_executable}'")
  29. message(STATUS "squish_libqtdir ='${squish_libqtdir}'")
  30. message(STATUS "squish_test_suite='${squish_test_suite}'")
  31. message(STATUS "squish_test_case='${squish_test_case}'")
  32. message(STATUS "squish_wrapper='${squish_wrapper}'")
  33. message(STATUS "squish_env_vars='${squish_env_vars}'")
  34. message(STATUS "squish_module_dir='${squish_module_dir}'")
  35. message(STATUS "squish_settingsgroup='${squish_settingsgroup}'")
  36. message(STATUS "squish_pre_command='${squish_pre_command}'")
  37. message(STATUS "squish_post_command='${squish_post_command}'")
  38. # parse enviornment variables
  39. foreach(i ${squish_env_vars})
  40. message(STATUS "parsing env var key/value pair ${i}")
  41. string(REGEX MATCH "([^=]*)=(.*)" squish_env_name ${i})
  42. message(STATUS "key=${CMAKE_MATCH_1}")
  43. message(STATUS "value=${CMAKE_MATCH_2}")
  44. set ( ENV{${CMAKE_MATCH_1}} ${CMAKE_MATCH_2} )
  45. endforeach()
  46. if (QT4_INSTALLED)
  47. # record Qt lib directory
  48. set ( ENV{${SQUISH_LIBQTDIR}} ${squish_libqtdir} )
  49. endif ()
  50. if(squish_pre_command)
  51. message(STATUS "Executing pre command: ${squish_pre_command}")
  52. execute_process(COMMAND "${squish_pre_command}")
  53. endif()
  54. # run the test
  55. if("${squish_version}" STREQUAL "4")
  56. if (WIN32)
  57. 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}
  58. RESULT_VARIABLE test_rv )
  59. elseif(UNIX)
  60. 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}
  61. RESULT_VARIABLE test_rv )
  62. endif ()
  63. else()
  64. if (WIN32)
  65. execute_process(COMMAND ${squish_module_dir}/SquishRunTestCase.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut}
  66. RESULT_VARIABLE test_rv )
  67. elseif(UNIX)
  68. execute_process(COMMAND ${squish_module_dir}/SquishRunTestCase.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut}
  69. RESULT_VARIABLE test_rv )
  70. endif ()
  71. endif()
  72. if(squish_post_command)
  73. message(STATUS "Executing post command: ${squish_post_command}")
  74. execute_process(COMMAND "${squish_post_command}")
  75. endif()
  76. # check for an error with running the test
  77. if(NOT "${test_rv}" STREQUAL "0")
  78. message(FATAL_ERROR "Error running Squish test")
  79. endif()