CTestUpdateCVS.cmake.in 4.7 KB

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