CTestUpdateSVN.cmake.in 4.5 KB

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