CTestUpdateCVS.cmake.in 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # This script drives creation of a CVS 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}/@CTestUpdateCVS_DIR@")
  7. set(UPDATE_NOT_GLOBAL 1)
  8. # Include code common to all update tests.
  9. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake")
  10. #-----------------------------------------------------------------------------
  11. # Report CVS tools in use.
  12. message("Using CVS tools:")
  13. set(CVS "@CVS_EXECUTABLE@")
  14. message(" cvs = ${CVS}")
  15. set(REPO ${TOP}/repo)
  16. set(CVSCMD ${CVS} -d${REPO})
  17. # CVSNT requires an extra option to 'cvs init'.
  18. set(CVS_INIT_OPT)
  19. execute_process(
  20. COMMAND ${CVS} --version
  21. RESULT_VARIABLE RESULT
  22. OUTPUT_VARIABLE OUTPUT
  23. ERROR_VARIABLE OUTPUT
  24. )
  25. if("${RESULT}" STREQUAL "0" AND "${OUTPUT}" MATCHES "\\(CVSNT\\)")
  26. set(CVS_INIT_OPT -n)
  27. message(" cvs init needs -n")
  28. endif()
  29. #-----------------------------------------------------------------------------
  30. # Initialize the testing directory.
  31. message("Creating test directory...")
  32. init_testing()
  33. #-----------------------------------------------------------------------------
  34. # Create the repository.
  35. message("Creating repository...")
  36. file(MAKE_DIRECTORY ${TOP}/repo)
  37. run_child(
  38. COMMAND ${CVSCMD} init ${CVS_INIT_OPT}
  39. )
  40. #-----------------------------------------------------------------------------
  41. # Import initial content into the repository.
  42. message("Importing content...")
  43. create_content(import)
  44. # Import the content into the repository.
  45. run_child(
  46. WORKING_DIRECTORY ${TOP}/import
  47. COMMAND ${CVSCMD} import -m "Initial content" Project vendor-tag release-tag
  48. )
  49. #-----------------------------------------------------------------------------
  50. # Create a working tree.
  51. message("Checking out revision 1...")
  52. run_child(
  53. WORKING_DIRECTORY ${TOP}
  54. COMMAND ${CVSCMD} co -d user-source Project
  55. )
  56. run_child(
  57. WORKING_DIRECTORY ${TOP}/user-source
  58. COMMAND ${CVSCMD} tag Revision1
  59. )
  60. #-----------------------------------------------------------------------------
  61. # Make changes in the working tree.
  62. message("Changing content...")
  63. update_content(user-source files_added files_removed dirs_added)
  64. if(dirs_added)
  65. run_child(
  66. WORKING_DIRECTORY ${TOP}/user-source
  67. COMMAND ${CVSCMD} add ${dirs_added}
  68. )
  69. endif(dirs_added)
  70. run_child(
  71. WORKING_DIRECTORY ${TOP}/user-source
  72. COMMAND ${CVSCMD} add ${files_added}
  73. )
  74. run_child(
  75. WORKING_DIRECTORY ${TOP}/user-source
  76. COMMAND ${CVSCMD} rm ${files_removed}
  77. )
  78. #-----------------------------------------------------------------------------
  79. # Commit the changes to the repository.
  80. message("Committing revision 2...")
  81. run_child(
  82. WORKING_DIRECTORY ${TOP}/user-source
  83. COMMAND ${CVSCMD} commit -m "Changed content"
  84. )
  85. #-----------------------------------------------------------------------------
  86. # Make changes in the working tree.
  87. message("Changing content again...")
  88. change_content(user-source)
  89. #-----------------------------------------------------------------------------
  90. # Commit the changes to the repository.
  91. message("Committing revision 3...")
  92. run_child(
  93. WORKING_DIRECTORY ${TOP}/user-source
  94. COMMAND ${CVSCMD} commit -m "Changed content again"
  95. )
  96. #-----------------------------------------------------------------------------
  97. # Go back to before the changes so we can test updating.
  98. message("Backing up to revision 1...")
  99. run_child(
  100. WORKING_DIRECTORY ${TOP}/user-source
  101. COMMAND ${CVSCMD} up -rRevision1
  102. )
  103. # Delay 1 second so the modification produces a newer time stamp.
  104. find_program(SLEEP sleep)
  105. if(SLEEP)
  106. message("Delaying...")
  107. execute_process(COMMAND ${SLEEP} 1)
  108. endif()
  109. # Create a modified file.
  110. message("Modifying locally...")
  111. modify_content(user-source)
  112. #-----------------------------------------------------------------------------
  113. # Test updating the user work directory with the command-line interface.
  114. message("Running CTest Dashboard Command Line...")
  115. # Create the user build tree.
  116. create_build_tree(user-source user-binary)
  117. file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
  118. "# CVS command configuration
  119. CVSCommand: ${CVS}
  120. CVSUpdateOptions: -dAP
  121. ")
  122. # Run the dashboard command line interface.
  123. run_dashboard_command_line(user-binary)
  124. #-----------------------------------------------------------------------------
  125. # Test initial checkout and update with a dashboard script.
  126. message("Running CTest Dashboard Script...")
  127. create_dashboard_script(dashboard.cmake
  128. "# CVS command configuration
  129. set(CTEST_CVS_COMMAND \"${CVS}\")
  130. set(CTEST_CVS_UPDATE_OPTIONS -dAP)
  131. set(CTEST_CHECKOUT_COMMAND
  132. \"\\\"\${CTEST_CVS_COMMAND}\\\" -d \\\"${REPO}\\\" co -rRevision1 -d dash-source Project\")
  133. ")
  134. # Run the dashboard script with CTest.
  135. run_dashboard_script(dashboard.cmake)