CTestUpdateBZR.cmake.in 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # This script drives creation of a bzr 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 "/@CTestUpdateBZR_DIR@")
  7. # Include code common to all update tests.
  8. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake")
  9. #-----------------------------------------------------------------------------
  10. # Report bzr tools in use.
  11. message("Using BZR tools:")
  12. set(BZR "@BZR_EXECUTABLE@")
  13. message(" bzr = ${BZR}")
  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.bzr)
  22. run_child(
  23. WORKING_DIRECTORY ${TOP}/repo.bzr
  24. COMMAND ${BZR} init
  25. )
  26. set(REPO file://${TOP}/repo.bzr)
  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 ${BZR} init
  34. )
  35. run_child(WORKING_DIRECTORY ${TOP}/import
  36. COMMAND ${BZR} whoami --branch "Test Author <testauthor@cmake.org>"
  37. )
  38. run_child(WORKING_DIRECTORY ${TOP}/import
  39. COMMAND ${BZR} add .
  40. )
  41. run_child(WORKING_DIRECTORY ${TOP}/import
  42. COMMAND ${BZR} commit -m "Initial content"
  43. )
  44. run_child(WORKING_DIRECTORY ${TOP}/import
  45. COMMAND ${BZR} push --create-prefix "${REPO}"
  46. )
  47. #-----------------------------------------------------------------------------
  48. # Create a working tree.
  49. message("Checking out revision 1...")
  50. run_child(
  51. WORKING_DIRECTORY ${TOP}
  52. COMMAND ${BZR} branch "${REPO}" user-source
  53. )
  54. run_child(
  55. WORKING_DIRECTORY ${TOP}/user-source
  56. COMMAND ${BZR} whoami --branch "Test Author <testauthor@cmake.org>"
  57. )
  58. #-----------------------------------------------------------------------------
  59. # Make changes in the working tree.
  60. message("Changing content...")
  61. update_content(user-source files_added files_removed dirs_added)
  62. if(dirs_added)
  63. run_child(
  64. WORKING_DIRECTORY ${TOP}/user-source
  65. COMMAND ${BZR} add ${dirs_added}
  66. )
  67. endif()
  68. run_child(
  69. WORKING_DIRECTORY ${TOP}/user-source
  70. COMMAND ${BZR} add ${files_added}
  71. )
  72. run_child(
  73. WORKING_DIRECTORY ${TOP}/user-source
  74. COMMAND ${BZR} rm ${files_removed}
  75. )
  76. #-----------------------------------------------------------------------------
  77. # Commit the changes to the repository.
  78. message("Committing revision 2...")
  79. run_child(
  80. WORKING_DIRECTORY ${TOP}/user-source
  81. COMMAND ${BZR} commit -m "Changed content"
  82. )
  83. run_child(
  84. WORKING_DIRECTORY ${TOP}/user-source
  85. COMMAND ${BZR} push "${REPO}"
  86. )
  87. #-----------------------------------------------------------------------------
  88. # Make changes in the working tree.
  89. message("Changing content again...")
  90. change_content(user-source)
  91. #-----------------------------------------------------------------------------
  92. # Commit the changes to the repository.
  93. message("Committing revision 3...")
  94. run_child(
  95. WORKING_DIRECTORY ${TOP}/user-source
  96. COMMAND ${BZR} commit -m "Changed content again"
  97. )
  98. run_child(
  99. WORKING_DIRECTORY ${TOP}/user-source
  100. COMMAND ${BZR} push "${REPO}"
  101. )
  102. #-----------------------------------------------------------------------------
  103. # Go back to before the changes so we can test updating.
  104. message("Backing up to revision 1...")
  105. run_child(
  106. WORKING_DIRECTORY ${TOP}/user-source
  107. COMMAND ${BZR} pull --overwrite -r1
  108. )
  109. # Create a modified file.
  110. modify_content(user-source)
  111. #-----------------------------------------------------------------------------
  112. # Test updating the user work directory with the command-line interface.
  113. message("Running CTest Dashboard Command Line...")
  114. # Create the user build tree.
  115. create_build_tree(user-source user-binary)
  116. file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
  117. "# BZR command configuration
  118. UpdateCommand: ${BZR}
  119. ")
  120. # Run the dashboard command line interface.
  121. run_dashboard_command_line(user-binary)
  122. #-----------------------------------------------------------------------------
  123. # Test initial checkout and update with a dashboard script.
  124. message("Running CTest Dashboard Script...")
  125. create_dashboard_script(dash-binary
  126. "# bzr command configuration
  127. set(CTEST_BZR_COMMAND \"${BZR}\")
  128. set(CTEST_CHECKOUT_COMMAND
  129. \"\\\"\${CTEST_BZR_COMMAND}\\\" branch -r1 \\\"${REPO}\\\" dash-source\")
  130. ")
  131. # Run the dashboard script with CTest.
  132. run_dashboard_script(dash-binary)