Merge topic 'curl-tls-verify'
[kiteware-cmake.git] / Tests / CTestUpdateHG.cmake.in
blob055d309e69e25ea79857947679233e1fcb77bf65
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...")
21 init_testing()
23 #-----------------------------------------------------------------------------
24 # Create the repository.
25 message("Creating repository...")
26 file(MAKE_DIRECTORY ${TOP}/repo.hg)
27 run_child(
28   WORKING_DIRECTORY ${TOP}/repo.hg
29   COMMAND ${HG} init
30   )
31 if(NOT "${TOP}" MATCHES "^/")
32   set(slash /)
33 endif()
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
43   COMMAND ${HG} init
44   )
45 run_child(WORKING_DIRECTORY ${TOP}/import
46   COMMAND ${HG} add .
47   )
48 run_child(WORKING_DIRECTORY ${TOP}/import
49   COMMAND ${HG} commit -m "Initial content"
50                        -u "Test Author <testauthor@cmake.org>"
51   )
52 run_child(WORKING_DIRECTORY ${TOP}/import
53   COMMAND ${HG} push "${REPO}"
54   )
56 #-----------------------------------------------------------------------------
57 # Create a working tree.
58 message("Checking out first revision...")
59 run_child(
60   WORKING_DIRECTORY ${TOP}
61   COMMAND ${HG} clone ${REPO} user-source
62   )
64 #-----------------------------------------------------------------------------
65 # Make changes in the working tree.
66 message("Changing content...")
67 update_content(user-source files_added files_removed dirs_added)
68 if(dirs_added)
69   run_child(
70     WORKING_DIRECTORY ${TOP}/user-source
71     COMMAND ${HG} add ${dirs_added}
72     )
73 endif()
74 run_child(
75   WORKING_DIRECTORY ${TOP}/user-source
76   COMMAND ${HG} add ${files_added}
77   )
78 run_child(
79   WORKING_DIRECTORY ${TOP}/user-source
80   COMMAND ${HG} rm ${files_removed}
81   )
82 run_child(
83   WORKING_DIRECTORY ${TOP}/user-source
84   COMMAND ${HG} add
85   )
87 #-----------------------------------------------------------------------------
88 # Commit the changes to the repository.
89 message("Committing revision 2...")
90 run_child(
91   WORKING_DIRECTORY ${TOP}/user-source
92   COMMAND ${HG} commit -m "Changed content"
93                        -u "Test Author <testauthor@cmake.org>"
94   )
95 run_child(
96   WORKING_DIRECTORY ${TOP}/user-source
97   COMMAND ${HG} push
98   )
100 #-----------------------------------------------------------------------------
101 # Make changes in the working tree.
102 message("Changing content again...")
103 change_content(user-source)
104 run_child(
105   WORKING_DIRECTORY ${TOP}/user-source
106   COMMAND ${HG} add
107   )
109 #-----------------------------------------------------------------------------
110 # Commit the changes to the repository.
111 message("Committing revision 3...")
112 run_child(
113   WORKING_DIRECTORY ${TOP}/user-source
114   COMMAND ${HG} commit -m "Changed content again"
115                        -u "Test Author <testauthor@cmake.org>"
116   )
117 run_child(
118   WORKING_DIRECTORY ${TOP}/user-source
119   COMMAND ${HG} push
120   )
122 #-----------------------------------------------------------------------------
123 # Go back to before the changes so we can test updating.
124 message("Backing up to first revision...")
125 run_child(
126   WORKING_DIRECTORY ${TOP}/user-source
127   COMMAND ${HG} update -C -r 0
128   )
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
141 UpdateCommand: ${HG}
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)
155 execute_process(
156   WORKING_DIRECTORY \"${TOP}\"
157   COMMAND \"${HG}\" clone \"${REPO}\" dash-source
158   )
159 execute_process(
160   WORKING_DIRECTORY \"${TOP}/dash-source\"
161   COMMAND \"${HG}\" update -C -r 0
162   )
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 [[
173 if(NOT ret LESS 0)
174   message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}")
175 endif()
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.
183 set(FAIL_UPDATE 1)
184 run_dashboard_script(dash-binary-fail)
185 unset(FAIL_UPDATE)