CTestUpdateHG.cmake.in 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # This script drives creation of a Mercurial 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 "/@CTestUpdateHG_DIR@")
  7. # Include code common to all update tests.
  8. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake")
  9. #-----------------------------------------------------------------------------
  10. # Report hg tools in use.
  11. message("Using HG tools:")
  12. set(HG "@HG_EXECUTABLE@")
  13. message(" hg = ${HG}")
  14. #-----------------------------------------------------------------------------
  15. # Initialize the testing directory.
  16. message("Creating test directory...")
  17. init_testing()
  18. #-----------------------------------------------------------------------------
  19. # Create the repository.
  20. message("Creating repository...")
  21. file(MAKE_DIRECTORY ${TOP}/repo.hg)
  22. run_child(
  23. WORKING_DIRECTORY ${TOP}/repo.hg
  24. COMMAND ${HG} init
  25. )
  26. if(NOT "${TOP}" MATCHES "^/")
  27. set(slash /)
  28. endif()
  29. set(REPO file://${slash}${TOP}/repo.hg)
  30. #-----------------------------------------------------------------------------
  31. # Import initial content into the repository.
  32. message("Importing content...")
  33. create_content(import)
  34. # Import the content into the repository.
  35. run_child(WORKING_DIRECTORY ${TOP}/import
  36. COMMAND ${HG} init
  37. )
  38. run_child(WORKING_DIRECTORY ${TOP}/import
  39. COMMAND ${HG} add .
  40. )
  41. run_child(WORKING_DIRECTORY ${TOP}/import
  42. COMMAND ${HG} commit -m "Initial content"
  43. -u "Test Author <testauthor@cmake.org>"
  44. )
  45. run_child(WORKING_DIRECTORY ${TOP}/import
  46. COMMAND ${HG} push "${REPO}"
  47. )
  48. #-----------------------------------------------------------------------------
  49. # Create a working tree.
  50. message("Checking out first revision...")
  51. run_child(
  52. WORKING_DIRECTORY ${TOP}
  53. COMMAND ${HG} clone ${REPO} user-source
  54. )
  55. #-----------------------------------------------------------------------------
  56. # Make changes in the working tree.
  57. message("Changing content...")
  58. update_content(user-source files_added files_removed dirs_added)
  59. if(dirs_added)
  60. run_child(
  61. WORKING_DIRECTORY ${TOP}/user-source
  62. COMMAND ${HG} add ${dirs_added}
  63. )
  64. endif()
  65. run_child(
  66. WORKING_DIRECTORY ${TOP}/user-source
  67. COMMAND ${HG} add ${files_added}
  68. )
  69. run_child(
  70. WORKING_DIRECTORY ${TOP}/user-source
  71. COMMAND ${HG} rm ${files_removed}
  72. )
  73. run_child(
  74. WORKING_DIRECTORY ${TOP}/user-source
  75. COMMAND ${HG} add
  76. )
  77. #-----------------------------------------------------------------------------
  78. # Commit the changes to the repository.
  79. message("Committing revision 2...")
  80. run_child(
  81. WORKING_DIRECTORY ${TOP}/user-source
  82. COMMAND ${HG} commit -m "Changed content"
  83. -u "Test Author <testauthor@cmake.org>"
  84. )
  85. run_child(
  86. WORKING_DIRECTORY ${TOP}/user-source
  87. COMMAND ${HG} push
  88. )
  89. #-----------------------------------------------------------------------------
  90. # Make changes in the working tree.
  91. message("Changing content again...")
  92. change_content(user-source)
  93. run_child(
  94. WORKING_DIRECTORY ${TOP}/user-source
  95. COMMAND ${HG} add
  96. )
  97. #-----------------------------------------------------------------------------
  98. # Commit the changes to the repository.
  99. message("Committing revision 3...")
  100. run_child(
  101. WORKING_DIRECTORY ${TOP}/user-source
  102. COMMAND ${HG} commit -m "Changed content again"
  103. -u "Test Author <testauthor@cmake.org>"
  104. )
  105. run_child(
  106. WORKING_DIRECTORY ${TOP}/user-source
  107. COMMAND ${HG} push
  108. )
  109. #-----------------------------------------------------------------------------
  110. # Go back to before the changes so we can test updating.
  111. message("Backing up to first revision...")
  112. run_child(
  113. WORKING_DIRECTORY ${TOP}/user-source
  114. COMMAND ${HG} update -C -r 0
  115. )
  116. # Create a modified file.
  117. modify_content(user-source)
  118. #-----------------------------------------------------------------------------
  119. # Test updating the user work directory with the command-line interface.
  120. message("Running CTest Dashboard Command Line...")
  121. # Create the user build tree.
  122. create_build_tree(user-source user-binary)
  123. file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
  124. "# HG command configuration
  125. UpdateCommand: ${HG}
  126. ")
  127. # Run the dashboard command line interface.
  128. run_dashboard_command_line(user-binary)
  129. #-----------------------------------------------------------------------------
  130. # Test initial checkout and update with a dashboard script.
  131. message("Running CTest Dashboard Script...")
  132. create_dashboard_script(dash-binary
  133. "# hg command configuration
  134. set(CTEST_HG_COMMAND \"${HG}\")
  135. set(CTEST_HG_UPDATE_OPTIONS)
  136. execute_process(
  137. WORKING_DIRECTORY \"${TOP}\"
  138. COMMAND \"${HG}\" clone \"${REPO}\" dash-source
  139. )
  140. execute_process(
  141. WORKING_DIRECTORY \"${TOP}/dash-source\"
  142. COMMAND \"${HG}\" update -C -r 0
  143. )
  144. ")
  145. # Run the dashboard script with CTest.
  146. run_dashboard_script(dash-binary)
  147. #-----------------------------------------------------------------------------
  148. # Test ctest_update(RETURN_VALUE) on failure
  149. message("Running CTest Dashboard Script (fail to update)...")
  150. set(ctest_update_check [[
  151. if(NOT ret LESS 0)
  152. message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}")
  153. endif()
  154. ]])
  155. create_dashboard_script(dash-binary-fail
  156. "set(CTEST_HG_COMMAND \"update-command-does-not-exist\")
  157. ")
  158. unset(ctest_update_check)
  159. # Run the dashboard script with CTest.
  160. set(FAIL_UPDATE 1)
  161. run_dashboard_script(dash-binary-fail)
  162. unset(FAIL_UPDATE)