CTestUpdateCVS.cmake.in 4.8 KB

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