CTestUpdateSVN.cmake.in 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. string(APPEND 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. run_child(
  38. COMMAND ${SVNADMIN} create --config-dir ${TOP}/config ${TOP}/repo
  39. )
  40. set(REPO file:///${TOP}/repo/trunk)
  41. #-----------------------------------------------------------------------------
  42. # Import initial content into the repository.
  43. message("Importing content...")
  44. create_content(import)
  45. # Import the content into the repository.
  46. run_child(
  47. WORKING_DIRECTORY ${TOP}/import
  48. COMMAND ${SVNCMD} import ${SVNUSER} -m "Initial content" . "${REPO}"
  49. )
  50. #-----------------------------------------------------------------------------
  51. # Create a working tree.
  52. message("Checking out revision 1...")
  53. run_child(
  54. WORKING_DIRECTORY ${TOP}
  55. COMMAND ${SVNCMD} co ${SVNUSER} ${REPO} user-source
  56. )
  57. #-----------------------------------------------------------------------------
  58. # Make changes in the working tree.
  59. message("Changing content...")
  60. update_content(user-source files_added files_removed dirs_added)
  61. if(dirs_added)
  62. run_child(
  63. WORKING_DIRECTORY ${TOP}/user-source
  64. COMMAND ${SVNCMD} add ${depth_empty} ${dirs_added}
  65. )
  66. endif()
  67. run_child(
  68. WORKING_DIRECTORY ${TOP}/user-source
  69. COMMAND ${SVNCMD} add ${files_added}
  70. )
  71. run_child(
  72. WORKING_DIRECTORY ${TOP}/user-source
  73. COMMAND ${SVNCMD} rm ${files_removed}
  74. )
  75. #-----------------------------------------------------------------------------
  76. # Commit the changes to the repository.
  77. message("Committing revision 2...")
  78. run_child(
  79. WORKING_DIRECTORY ${TOP}/user-source
  80. COMMAND ${SVNCMD} commit -m "Changed content"
  81. )
  82. #-----------------------------------------------------------------------------
  83. # Make changes in the working tree.
  84. message("Changing content again...")
  85. change_content(user-source)
  86. #-----------------------------------------------------------------------------
  87. # Commit the changes to the repository.
  88. message("Committing revision 3...")
  89. run_child(
  90. WORKING_DIRECTORY ${TOP}/user-source
  91. COMMAND ${SVNCMD} commit -m "Changed content again"
  92. )
  93. #-----------------------------------------------------------------------------
  94. # Go back to before the changes so we can test updating.
  95. message("Backing up to revision 1...")
  96. run_child(
  97. WORKING_DIRECTORY ${TOP}/user-source
  98. COMMAND ${SVNCMD} up -r1
  99. )
  100. # Create a modified file.
  101. message("Modifying locally...")
  102. modify_content(user-source)
  103. #-----------------------------------------------------------------------------
  104. # Test updating the user work directory with the command-line interface.
  105. message("Running CTest Dashboard Command Line...")
  106. # Create the user build tree.
  107. create_build_tree(user-source user-binary)
  108. file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
  109. "# SVN command configuration
  110. SVNCommand: ${SVN}
  111. SVNUpdateOptions: --config-dir \"${TOP}/config\"
  112. ")
  113. # Run the dashboard command line interface.
  114. run_dashboard_command_line(user-binary)
  115. #-----------------------------------------------------------------------------
  116. # Test initial checkout and update with a dashboard script.
  117. message("Running CTest Dashboard Script...")
  118. create_dashboard_script(dash-binary
  119. "# Subversion command configuration
  120. set(CTEST_SVN_COMMAND \"${SVN}\")
  121. set(CTEST_SVN_UPDATE_OPTIONS
  122. \"--config-dir \\\"\${CTEST_DASHBOARD_ROOT}/config\\\"\")
  123. set(CTEST_CHECKOUT_COMMAND
  124. \"\\\"\${CTEST_SVN_COMMAND}\\\" co -r1 \\\"${REPO}\\\" dash-source\")
  125. ")
  126. # Run the dashboard script with CTest.
  127. run_dashboard_script(dash-binary)
  128. #-----------------------------------------------------------------------------
  129. # Test ctest_update(RETURN_VALUE) on failure
  130. message("Running CTest Dashboard Script (fail to update)...")
  131. set(ctest_update_check [[
  132. if(NOT ret LESS 0)
  133. message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}")
  134. endif()
  135. ]])
  136. create_dashboard_script(dash-binary-fail
  137. "set(CTEST_SVN_COMMAND \"update-command-does-not-exist\")
  138. ")
  139. unset(ctest_update_check)
  140. # Run the dashboard script with CTest.
  141. set(FAIL_UPDATE 1)
  142. run_dashboard_script(dash-binary-fail)
  143. unset(FAIL_UPDATE)