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