CTestUpdateHG.cmake.in 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. set(TOP "${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. set(REPO file://${TOP}/repo.hg)
  27. #-----------------------------------------------------------------------------
  28. # Import initial content into the repository.
  29. message("Importing content...")
  30. create_content(import)
  31. # Import the content into the repository.
  32. run_child(WORKING_DIRECTORY ${TOP}/import
  33. COMMAND ${HG} init
  34. )
  35. run_child(WORKING_DIRECTORY ${TOP}/import
  36. COMMAND ${HG} add .
  37. )
  38. run_child(WORKING_DIRECTORY ${TOP}/import
  39. COMMAND ${HG} commit -m "Initial content"
  40. -u "Test Author <[email protected]>"
  41. )
  42. run_child(WORKING_DIRECTORY ${TOP}/import
  43. COMMAND ${HG} push "${REPO}"
  44. )
  45. #-----------------------------------------------------------------------------
  46. # Create a working tree.
  47. message("Checking out first revision...")
  48. run_child(
  49. WORKING_DIRECTORY ${TOP}
  50. COMMAND ${HG} clone ${REPO} user-source
  51. )
  52. #-----------------------------------------------------------------------------
  53. # Make changes in the working tree.
  54. message("Changing content...")
  55. update_content(user-source files_added files_removed dirs_added)
  56. if(dirs_added)
  57. run_child(
  58. WORKING_DIRECTORY ${TOP}/user-source
  59. COMMAND ${HG} add ${dirs_added}
  60. )
  61. endif(dirs_added)
  62. run_child(
  63. WORKING_DIRECTORY ${TOP}/user-source
  64. COMMAND ${HG} add ${files_added}
  65. )
  66. run_child(
  67. WORKING_DIRECTORY ${TOP}/user-source
  68. COMMAND ${HG} rm ${files_removed}
  69. )
  70. run_child(
  71. WORKING_DIRECTORY ${TOP}/user-source
  72. COMMAND ${HG} add
  73. )
  74. #-----------------------------------------------------------------------------
  75. # Commit the changes to the repository.
  76. message("Committing revision 2...")
  77. run_child(
  78. WORKING_DIRECTORY ${TOP}/user-source
  79. COMMAND ${HG} commit -m "Changed content"
  80. -u "Test Author <[email protected]>"
  81. )
  82. run_child(
  83. WORKING_DIRECTORY ${TOP}/user-source
  84. COMMAND ${HG} push
  85. )
  86. #-----------------------------------------------------------------------------
  87. # Make changes in the working tree.
  88. message("Changing content again...")
  89. change_content(user-source)
  90. run_child(
  91. WORKING_DIRECTORY ${TOP}/user-source
  92. COMMAND ${HG} add
  93. )
  94. #-----------------------------------------------------------------------------
  95. # Commit the changes to the repository.
  96. message("Committing revision 3...")
  97. run_child(
  98. WORKING_DIRECTORY ${TOP}/user-source
  99. COMMAND ${HG} commit -m "Changed content again"
  100. -u "Test Author <[email protected]>"
  101. )
  102. run_child(
  103. WORKING_DIRECTORY ${TOP}/user-source
  104. COMMAND ${HG} push
  105. )
  106. #-----------------------------------------------------------------------------
  107. # Go back to before the changes so we can test updating.
  108. message("Backing up to first revision...")
  109. run_child(
  110. WORKING_DIRECTORY ${TOP}/user-source
  111. COMMAND ${HG} update -C -r 0
  112. )
  113. # Create a modified file.
  114. modify_content(user-source)
  115. #-----------------------------------------------------------------------------
  116. # Test updating the user work directory with the command-line interface.
  117. message("Running CTest Dashboard Command Line...")
  118. # Create the user build tree.
  119. create_build_tree(user-source user-binary)
  120. file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
  121. "# HG command configuration
  122. UpdateCommand: ${HG}
  123. ")
  124. # Run the dashboard command line interface.
  125. run_dashboard_command_line(user-binary)
  126. #-----------------------------------------------------------------------------
  127. # Test initial checkout and update with a dashboard script.
  128. message("Running CTest Dashboard Script...")
  129. create_dashboard_script(dashboard.cmake
  130. "# hg command configuration
  131. set(CTEST_HG_COMMAND \"${HG}\")
  132. set(CTEST_HG_UPDATE_OPTIONS)
  133. execute_process(
  134. WORKING_DIRECTORY \"${TOP}\"
  135. COMMAND \"${HG}\" clone \"${REPO}\" dash-source
  136. )
  137. execute_process(
  138. WORKING_DIRECTORY \"${TOP}/dash-source\"
  139. COMMAND \"${HG}\" update -C -r 0
  140. )
  141. ")
  142. # Run the dashboard script with CTest.
  143. run_dashboard_script(dashboard.cmake)