CTestUpdateSVN.cmake.in 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. #-----------------------------------------------------------------------------
  22. # Initialize the testing directory.
  23. message("Creating test directory...")
  24. init_testing()
  25. #-----------------------------------------------------------------------------
  26. # Create the repository.
  27. message("Creating repository...")
  28. file(MAKE_DIRECTORY ${TOP}/repo)
  29. run_child(
  30. COMMAND ${SVNADMIN} create --config-dir ${TOP}/config ${TOP}/repo
  31. )
  32. set(REPO file:///${TOP}/repo/trunk)
  33. #-----------------------------------------------------------------------------
  34. # Import initial content into the repository.
  35. message("Importing content...")
  36. create_content(import)
  37. # Import the content into the repository.
  38. run_child(
  39. WORKING_DIRECTORY ${TOP}/import
  40. COMMAND ${SVNCMD} import ${SVNUSER} -m "Initial content" . "${REPO}"
  41. )
  42. #-----------------------------------------------------------------------------
  43. # Create a working tree.
  44. message("Checking out revision 1...")
  45. run_child(
  46. WORKING_DIRECTORY ${TOP}
  47. COMMAND ${SVNCMD} co ${SVNUSER} ${REPO} user-source
  48. )
  49. #-----------------------------------------------------------------------------
  50. # Make changes in the working tree.
  51. message("Changing content...")
  52. update_content(user-source files_added files_removed dirs_added)
  53. if(dirs_added)
  54. run_child(
  55. WORKING_DIRECTORY ${TOP}/user-source
  56. COMMAND ${SVNCMD} add ${dirs_added}
  57. )
  58. endif(dirs_added)
  59. run_child(
  60. WORKING_DIRECTORY ${TOP}/user-source
  61. COMMAND ${SVNCMD} add ${files_added}
  62. )
  63. run_child(
  64. WORKING_DIRECTORY ${TOP}/user-source
  65. COMMAND ${SVNCMD} rm ${files_removed}
  66. )
  67. #-----------------------------------------------------------------------------
  68. # Commit the changes to the repository.
  69. message("Committing revision 2...")
  70. run_child(
  71. WORKING_DIRECTORY ${TOP}/user-source
  72. COMMAND ${SVNCMD} commit -m "Changed content"
  73. )
  74. #-----------------------------------------------------------------------------
  75. # Make changes in the working tree.
  76. message("Changing content again...")
  77. change_content(user-source)
  78. #-----------------------------------------------------------------------------
  79. # Commit the changes to the repository.
  80. message("Committing revision 3...")
  81. run_child(
  82. WORKING_DIRECTORY ${TOP}/user-source
  83. COMMAND ${SVNCMD} commit -m "Changed content again"
  84. )
  85. #-----------------------------------------------------------------------------
  86. # Go back to before the changes so we can test updating.
  87. message("Backing up to revision 1...")
  88. run_child(
  89. WORKING_DIRECTORY ${TOP}/user-source
  90. COMMAND ${SVNCMD} up -r1
  91. )
  92. # Create a modified file.
  93. message("Modifying locally...")
  94. modify_content(user-source)
  95. #-----------------------------------------------------------------------------
  96. # Test updating the user work directory with the command-line interface.
  97. message("Running CTest Dashboard Command Line...")
  98. # Create the user build tree.
  99. create_build_tree(user-source user-binary)
  100. file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
  101. "# SVN command configuration
  102. SVNCommand: ${SVN}
  103. SVNUpdateOptions: --config-dir \"${TOP}/config\"
  104. ")
  105. # Run the dashboard command line interface.
  106. run_dashboard_command_line(user-binary)
  107. #-----------------------------------------------------------------------------
  108. # Test initial checkout and update with a dashboard script.
  109. message("Running CTest Dashboard Script...")
  110. create_dashboard_script(dash-binary
  111. "# Subversion command configuration
  112. set(CTEST_SVN_COMMAND \"${SVN}\")
  113. set(CTEST_SVN_UPDATE_OPTIONS
  114. \"--config-dir \\\"\${CTEST_DASHBOARD_ROOT}/config\\\"\")
  115. set(CTEST_CHECKOUT_COMMAND
  116. \"\\\"\${CTEST_SVN_COMMAND}\\\" co -r1 \\\"${REPO}\\\" dash-source\")
  117. ")
  118. # Run the dashboard script with CTest.
  119. run_dashboard_script(dash-binary)