CTestUpdateSVN.cmake.in 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # This script drives creation of a Subversion 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}/@CTestUpdateSVN_DIR@")
  7. set(UPDATE_GLOBAL_ELEMENTS SVNPath)
  8. # Include code common to all update tests.
  9. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake")
  10. #-----------------------------------------------------------------------------
  11. # Report subversion tools in use.
  12. message("Using subversion tools:")
  13. set(SVN "@Subversion_SVN_EXECUTABLE@")
  14. set(SVNADMIN "@Subversion_SVNADMIN_EXECUTABLE@")
  15. message(" svn = ${SVN}")
  16. message(" svnadmin = ${SVNADMIN}")
  17. # Isolate svn test operations from the user configuration.
  18. file(MAKE_DIRECTORY ${TOP}/config)
  19. set(SVNCMD ${SVN} --config-dir ${TOP}/config)
  20. set(SVNUSER --username "test author" --non-interactive)
  21. # Configure for this svn version.
  22. execute_process(
  23. COMMAND ${SVN} help add OUTPUT_VARIABLE help_add ERROR_VARIABLE help_add
  24. )
  25. if("${help_add}" MATCHES "--depth")
  26. set(depth_empty "--depth=empty")
  27. else()
  28. set(depth_empty "")
  29. endif()
  30. #-----------------------------------------------------------------------------
  31. # Initialize the testing directory.
  32. message("Creating test directory...")
  33. init_testing()
  34. #-----------------------------------------------------------------------------
  35. # Create the repository.
  36. message("Creating repository...")
  37. file(MAKE_DIRECTORY ${TOP}/repo)
  38. run_child(
  39. COMMAND ${SVNADMIN} create --config-dir ${TOP}/config ${TOP}/repo
  40. )
  41. set(REPO file:///${TOP}/repo/trunk)
  42. #-----------------------------------------------------------------------------
  43. # Import initial content into the repository.
  44. message("Importing content...")
  45. create_content(import)
  46. # Import the content into the repository.
  47. run_child(
  48. WORKING_DIRECTORY ${TOP}/import
  49. COMMAND ${SVNCMD} import ${SVNUSER} -m "Initial content" . "${REPO}"
  50. )
  51. #-----------------------------------------------------------------------------
  52. # Create a working tree.
  53. message("Checking out revision 1...")
  54. run_child(
  55. WORKING_DIRECTORY ${TOP}
  56. COMMAND ${SVNCMD} co ${SVNUSER} ${REPO} user-source
  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 ${SVNCMD} add ${depth_empty} ${dirs_added}
  66. )
  67. endif(dirs_added)
  68. run_child(
  69. WORKING_DIRECTORY ${TOP}/user-source
  70. COMMAND ${SVNCMD} add ${files_added}
  71. )
  72. run_child(
  73. WORKING_DIRECTORY ${TOP}/user-source
  74. COMMAND ${SVNCMD} 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 ${SVNCMD} commit -m "Changed content"
  82. )
  83. #-----------------------------------------------------------------------------
  84. # Make changes in the working tree.
  85. message("Changing content again...")
  86. change_content(user-source)
  87. #-----------------------------------------------------------------------------
  88. # Commit the changes to the repository.
  89. message("Committing revision 3...")
  90. run_child(
  91. WORKING_DIRECTORY ${TOP}/user-source
  92. COMMAND ${SVNCMD} commit -m "Changed content again"
  93. )
  94. #-----------------------------------------------------------------------------
  95. # Go back to before the changes so we can test updating.
  96. message("Backing up to revision 1...")
  97. run_child(
  98. WORKING_DIRECTORY ${TOP}/user-source
  99. COMMAND ${SVNCMD} up -r1
  100. )
  101. # Create a modified file.
  102. message("Modifying locally...")
  103. modify_content(user-source)
  104. #-----------------------------------------------------------------------------
  105. # Test updating the user work directory with the command-line interface.
  106. message("Running CTest Dashboard Command Line...")
  107. # Create the user build tree.
  108. create_build_tree(user-source user-binary)
  109. file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
  110. "# SVN command configuration
  111. SVNCommand: ${SVN}
  112. SVNUpdateOptions: --config-dir \"${TOP}/config\"
  113. ")
  114. # Run the dashboard command line interface.
  115. run_dashboard_command_line(user-binary)
  116. #-----------------------------------------------------------------------------
  117. # Test initial checkout and update with a dashboard script.
  118. message("Running CTest Dashboard Script...")
  119. create_dashboard_script(dash-binary
  120. "# Subversion command configuration
  121. set(CTEST_SVN_COMMAND \"${SVN}\")
  122. set(CTEST_SVN_UPDATE_OPTIONS
  123. \"--config-dir \\\"\${CTEST_DASHBOARD_ROOT}/config\\\"\")
  124. set(CTEST_CHECKOUT_COMMAND
  125. \"\\\"\${CTEST_SVN_COMMAND}\\\" co -r1 \\\"${REPO}\\\" dash-source\")
  126. ")
  127. # Run the dashboard script with CTest.
  128. run_dashboard_script(dash-binary)