1 # This script drives creation of a Mercurial 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 string(APPEND TOP "/@CTestUpdateHG_DIR@")
9 # Include code common to all update tests.
10 include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake")
12 #-----------------------------------------------------------------------------
13 # Report hg tools in use.
14 message("Using HG tools:")
15 set(HG "@HG_EXECUTABLE@")
16 message(" hg = ${HG}")
18 #-----------------------------------------------------------------------------
19 # Initialize the testing directory.
20 message("Creating test directory...")
23 #-----------------------------------------------------------------------------
24 # Create the repository.
25 message("Creating repository...")
26 file(MAKE_DIRECTORY ${TOP}/repo.hg)
28 WORKING_DIRECTORY ${TOP}/repo.hg
31 if(NOT "${TOP}" MATCHES "^/")
34 set(REPO file://${slash}${TOP}/repo.hg)
36 #-----------------------------------------------------------------------------
37 # Import initial content into the repository.
38 message("Importing content...")
39 create_content(import)
41 # Import the content into the repository.
42 run_child(WORKING_DIRECTORY ${TOP}/import
45 run_child(WORKING_DIRECTORY ${TOP}/import
48 run_child(WORKING_DIRECTORY ${TOP}/import
49 COMMAND ${HG} commit -m "Initial content"
50 -u "Test Author <testauthor@cmake.org>"
52 run_child(WORKING_DIRECTORY ${TOP}/import
53 COMMAND ${HG} push "${REPO}"
56 #-----------------------------------------------------------------------------
57 # Create a working tree.
58 message("Checking out first revision...")
60 WORKING_DIRECTORY ${TOP}
61 COMMAND ${HG} clone ${REPO} user-source
64 #-----------------------------------------------------------------------------
65 # Make changes in the working tree.
66 message("Changing content...")
67 update_content(user-source files_added files_removed dirs_added)
70 WORKING_DIRECTORY ${TOP}/user-source
71 COMMAND ${HG} add ${dirs_added}
75 WORKING_DIRECTORY ${TOP}/user-source
76 COMMAND ${HG} add ${files_added}
79 WORKING_DIRECTORY ${TOP}/user-source
80 COMMAND ${HG} rm ${files_removed}
83 WORKING_DIRECTORY ${TOP}/user-source
87 #-----------------------------------------------------------------------------
88 # Commit the changes to the repository.
89 message("Committing revision 2...")
91 WORKING_DIRECTORY ${TOP}/user-source
92 COMMAND ${HG} commit -m "Changed content"
93 -u "Test Author <testauthor@cmake.org>"
96 WORKING_DIRECTORY ${TOP}/user-source
100 #-----------------------------------------------------------------------------
101 # Make changes in the working tree.
102 message("Changing content again...")
103 change_content(user-source)
105 WORKING_DIRECTORY ${TOP}/user-source
109 #-----------------------------------------------------------------------------
110 # Commit the changes to the repository.
111 message("Committing revision 3...")
113 WORKING_DIRECTORY ${TOP}/user-source
114 COMMAND ${HG} commit -m "Changed content again"
115 -u "Test Author <testauthor@cmake.org>"
118 WORKING_DIRECTORY ${TOP}/user-source
122 #-----------------------------------------------------------------------------
123 # Go back to before the changes so we can test updating.
124 message("Backing up to first revision...")
126 WORKING_DIRECTORY ${TOP}/user-source
127 COMMAND ${HG} update -C -r 0
130 # Create a modified file.
131 modify_content(user-source)
133 #-----------------------------------------------------------------------------
134 # Test updating the user work directory with the command-line interface.
135 message("Running CTest Dashboard Command Line...")
137 # Create the user build tree.
138 create_build_tree(user-source user-binary)
139 file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
140 "# HG command configuration
144 # Run the dashboard command line interface.
145 run_dashboard_command_line(user-binary)
147 #-----------------------------------------------------------------------------
148 # Test initial checkout and update with a dashboard script.
149 message("Running CTest Dashboard Script...")
151 create_dashboard_script(dash-binary
152 "# hg command configuration
153 set(CTEST_HG_COMMAND \"${HG}\")
154 set(CTEST_HG_UPDATE_OPTIONS)
156 WORKING_DIRECTORY \"${TOP}\"
157 COMMAND \"${HG}\" clone \"${REPO}\" dash-source
160 WORKING_DIRECTORY \"${TOP}/dash-source\"
161 COMMAND \"${HG}\" update -C -r 0
165 # Run the dashboard script with CTest.
166 run_dashboard_script(dash-binary)
168 #-----------------------------------------------------------------------------
169 # Test ctest_update(RETURN_VALUE) on failure
170 message("Running CTest Dashboard Script (fail to update)...")
172 set(ctest_update_check [[
174 message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}")
177 create_dashboard_script(dash-binary-fail
178 "set(CTEST_HG_COMMAND \"update-command-does-not-exist\")
180 unset(ctest_update_check)
182 # Run the dashboard script with CTest.
184 run_dashboard_script(dash-binary-fail)