CTestUpdateCVS.cmake.in 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. # This script drives creation of a CVS repository and checks
  2. # that CTest can update from it.
  3. #-----------------------------------------------------------------------------
  4. # Test in a directory next to this script.
  5. get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH)
  6. string(APPEND TOP "/@CTestUpdateCVS_DIR@")
  7. set(UPDATE_NOT_GLOBAL 1)
  8. set(UPDATE_MAYBE Updated{CTestConfig.cmake})
  9. # Include code common to all update tests.
  10. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake")
  11. #-----------------------------------------------------------------------------
  12. # Report CVS tools in use.
  13. message("Using CVS tools:")
  14. set(CVS "@CVS_EXECUTABLE@")
  15. message(" cvs = ${CVS}")
  16. set(REPO ${TOP}/repo)
  17. # The MSYS cvs tool interprets "c:/" as a "machine:" name for SSH.
  18. # Detect the MSYS cvs and convert the repo path to an MSYS path.
  19. if(WIN32)
  20. if(EXISTS "${CVS}")
  21. file(STRINGS "${CVS}" cvs_is_msys LIMIT_COUNT 1 REGEX "[Mm][Ss][Yy][Ss]")
  22. if(cvs_is_msys)
  23. message(" '${CVS}' is from MSYS (contains '${cvs_is_msys}')")
  24. string(REGEX REPLACE "^([A-Za-z]):" "/\\1" REPO "${REPO}")
  25. endif()
  26. endif()
  27. endif()
  28. set(CVSCMD ${CVS} -d${REPO})
  29. # CVSNT requires an extra option to 'cvs init'.
  30. set(CVS_INIT_OPT)
  31. execute_process(
  32. COMMAND ${CVS} --version
  33. RESULT_VARIABLE RESULT
  34. OUTPUT_VARIABLE OUTPUT
  35. ERROR_VARIABLE OUTPUT
  36. )
  37. if("${RESULT}" STREQUAL "0" AND "${OUTPUT}" MATCHES "\\(CVSNT\\)")
  38. set(CVS_INIT_OPT -n)
  39. message(" cvs init needs -n")
  40. endif()
  41. #-----------------------------------------------------------------------------
  42. # Initialize the testing directory.
  43. message("Creating test directory...")
  44. init_testing()
  45. #-----------------------------------------------------------------------------
  46. # Create the repository.
  47. message("Creating repository...")
  48. file(MAKE_DIRECTORY ${TOP}/repo)
  49. run_child(
  50. COMMAND ${CVSCMD} init ${CVS_INIT_OPT}
  51. )
  52. #-----------------------------------------------------------------------------
  53. # Import initial content into the repository.
  54. message("Importing content...")
  55. create_content(import)
  56. # Import the content into the repository.
  57. run_child(
  58. WORKING_DIRECTORY ${TOP}/import
  59. COMMAND ${CVSCMD} import -m "Initial content" Project vendor-tag release-tag
  60. )
  61. #-----------------------------------------------------------------------------
  62. # Create a working tree.
  63. message("Checking out revision 1...")
  64. run_child(
  65. WORKING_DIRECTORY ${TOP}
  66. COMMAND ${CVSCMD} co -d user-source Project
  67. )
  68. run_child(
  69. WORKING_DIRECTORY ${TOP}/user-source
  70. COMMAND ${CVSCMD} tag Revision1
  71. )
  72. #-----------------------------------------------------------------------------
  73. # Make changes in the working tree.
  74. message("Changing content...")
  75. update_content(user-source files_added files_removed dirs_added)
  76. if(dirs_added)
  77. run_child(
  78. WORKING_DIRECTORY ${TOP}/user-source
  79. COMMAND ${CVSCMD} add ${dirs_added}
  80. )
  81. endif()
  82. run_child(
  83. WORKING_DIRECTORY ${TOP}/user-source
  84. COMMAND ${CVSCMD} add ${files_added}
  85. )
  86. run_child(
  87. WORKING_DIRECTORY ${TOP}/user-source
  88. COMMAND ${CVSCMD} rm ${files_removed}
  89. )
  90. #-----------------------------------------------------------------------------
  91. # Commit the changes to the repository.
  92. message("Committing revision 2...")
  93. run_child(
  94. WORKING_DIRECTORY ${TOP}/user-source
  95. COMMAND ${CVSCMD} commit -m "Changed content"
  96. )
  97. #-----------------------------------------------------------------------------
  98. # Make changes in the working tree.
  99. message("Changing content again...")
  100. change_content(user-source)
  101. #-----------------------------------------------------------------------------
  102. # Commit the changes to the repository.
  103. message("Committing revision 3...")
  104. run_child(
  105. WORKING_DIRECTORY ${TOP}/user-source
  106. COMMAND ${CVSCMD} commit -m "Changed content again"
  107. )
  108. #-----------------------------------------------------------------------------
  109. # Go back to before the changes so we can test updating.
  110. message("Backing up to revision 1...")
  111. run_child(
  112. WORKING_DIRECTORY ${TOP}/user-source
  113. COMMAND ${CVSCMD} up -rRevision1
  114. )
  115. # Delay 1 second so the modification produces a newer time stamp.
  116. find_program(SLEEP sleep)
  117. if(SLEEP)
  118. message("Delaying...")
  119. execute_process(COMMAND ${SLEEP} 1)
  120. endif()
  121. # Create a modified file.
  122. message("Modifying locally...")
  123. modify_content(user-source)
  124. #-----------------------------------------------------------------------------
  125. # Test updating the user work directory with the command-line interface.
  126. message("Running CTest Dashboard Command Line...")
  127. # Create the user build tree.
  128. create_build_tree(user-source user-binary)
  129. file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
  130. "# CVS command configuration
  131. CVSCommand: ${CVS}
  132. CVSUpdateOptions: -dAP
  133. ")
  134. # Run the dashboard command line interface.
  135. run_dashboard_command_line(user-binary)
  136. #-----------------------------------------------------------------------------
  137. # Test initial checkout and update with a dashboard script.
  138. message("Running CTest Dashboard Script...")
  139. create_dashboard_script(dash-binary
  140. "# CVS command configuration
  141. set(CTEST_CVS_COMMAND \"${CVS}\")
  142. set(CTEST_CVS_UPDATE_OPTIONS -dAP)
  143. set(CTEST_CHECKOUT_COMMAND
  144. \"\\\"\${CTEST_CVS_COMMAND}\\\" -d \\\"${REPO}\\\" co -rRevision1 -d dash-source Project\")
  145. ")
  146. # Run the dashboard script with CTest.
  147. run_dashboard_script(dash-binary)
  148. #-----------------------------------------------------------------------------
  149. # Test ctest_update(RETURN_VALUE) on failure
  150. message("Running CTest Dashboard Script (fail to update)...")
  151. set(ctest_update_check [[
  152. if(NOT ret LESS 0)
  153. message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}")
  154. endif()
  155. ]])
  156. create_dashboard_script(dash-binary-fail
  157. "set(CTEST_CVS_COMMAND \"update-command-does-not-exist\")
  158. ")
  159. unset(ctest_update_check)
  160. # Run the dashboard script with CTest.
  161. set(FAIL_UPDATE 1)
  162. run_dashboard_script(dash-binary-fail)
  163. unset(FAIL_UPDATE)