Debian Codegraph @

cmake/tribits/dashboard_driver/TribitsDriverSupport.cmake

raw
1 # @HEADER
2 # *****************************************************************************
3 # TriBITS: Tribal Build, Integrate, and Test System
4 #
5 # Copyright 2013-2016 NTESS and the TriBITS contributors.
6 # SPDX-License-Identifier: BSD-3-Clause
7 # *****************************************************************************
8 # @HEADER
9
10 include(GetCurrentListDir)
11 include(CMakeParseArguments)
12 include(SetDefaultAndFromEnv)
13
14 # Set if the inner CMake installs are performed or not
15 set_default_and_from_env(TDD_FORCE_INNER_CMAKE_INSTALL 1)
16
17 # Set if the inner CMake installs are performed or not
18 set_default_and_from_env(TRIBITS_TDD_USE_SYSTEM_CTEST 0)
19
20 # Get this value outside of any functions so it will be the path to
21 # *this* file and not the path to the file calling any of these
22 # functions.
23 get_current_list_dir(THIS_SCRIPT_DIR)
24
25 #
26 # Placeholder for any global setup necessary on all machines...
27 #
28 # Call this function first at the top of any drivers/MACHINE/CMakeLists.txt
29 # file.
30 #
31 function(tribits_driver_setup)
32 #
33 # But right now... no global setup required...
34 #
35 endfunction()
36
37
38 #
39 # Add a test to download and install a single "flavor" of CMake.
40 #
41 # Known values of cmake_type are 'min', 'release', 'rc' and 'dev'.
42 #
43 # This function should be called automatically by
44 # TRIBITS_ADD_REQUIRED_CMAKE_INSTALLS after many calls to
45 # TRIBITS_DRIVER_ADD_DASHBOARD have collected a list of which flavors
46 # of CMake are required to run all the dashboards on this machine.
47 #
48 function(tribits_driver_add_test_that_installs_cmake cmake_type)
49
50 set(known 0)
51 if("${cmake_type}" STREQUAL "min" OR
52 "${cmake_type}" STREQUAL "release" OR
53 "${cmake_type}" STREQUAL "rc" OR
54 "${cmake_type}" STREQUAL "dev")
55 set(known 1)
56 endif()
57 if(NOT known)
58 message("error: unknown --installer-type '${cmake_type}' -- no test added")
59 return()
60 endif()
61
62 if(NOT TD_BASE_DIR)
63 message(FATAL_ERROR "TD_BASE_DIR must be defined before calling this function")
64 endif()
65
66 if(NOT TRIBITS_PYTHON_UTILS_DIR)
67 message(FATAL_ERROR "TRIBITS_PYTHON_UTILS_DIR must be defined before calling this function")
68 endif()
69
70 find_program(PYTHON_EXE python)
71
72 set_default_and_from_env( TDD_HTTP_PROXY "" )
73 if (TDD_HTTP_PROXY)
74 set(TDD_HTTP_PROXY_ARG "--http-proxy=${TDD_HTTP_PROXY}")
75 else()
76 set(TDD_HTTP_PROXY_ARG "")
77 endif()
78
79 add_test(uninstall-cmake-${cmake_type} ${CMAKE_COMMAND}
80 -E remove_directory "${TD_BASE_DIR}/tools/cmake-${cmake_type}"
81 )
82
83 add_test(install-cmake-${cmake_type} ${PYTHON_EXE}
84 "${TRIBITS_PYTHON_UTILS_DIR}/download-cmake.py"
85 "--skip-detect"
86 "--install-dir=${TD_BASE_DIR}/tools/cmake-${cmake_type}"
87 "--installer-type=${cmake_type}"
88 "${TDD_HTTP_PROXY_ARG}"
89 )
90
91 set_property(TEST install-cmake-${cmake_type}
92 PROPERTY DEPENDS "uninstall-cmake-${cmake_type}")
93
94 endfunction()
95
96
97 #
98 # Add a test that runs a dashboard script using a known flavor of ctest.
99 #
100 # Required arguments:
101 # testname - name of the test as it appears on the driver dashboard
102 #
103 # scriptname - name of the file in CMAKE_CURRENT_SOURCE_DIR to run as
104 # ctest -S script
105 #
106 # Optional arguments:
107 #
108 # [CTEST_INSTALLER_TYPE min|release|rc|dev]
109 # [ENVIRONMENT var1=value1;var2=value2;var3=value3;...]
110 # [PROCESSORS 1]
111 # [RUN_SERIAL]
112 # [TIMEOUT_MINUTES 180]
113 #
114 function(tribits_driver_add_dashboard testname scriptname)
115
116 message("TRIBITS_DRIVER_ADD_DASHBOARD: '${testname}' '${scriptname}' [${ARGN}]")
117
118 cmake_parse_arguments(
119 # prefix
120 PARSE
121 # options
122 "RUN_SERIAL"
123 # one_value_keywords
124 ""
125 # multi_value_keywords
126 "CTEST_INSTALLER_TYPE;ENVIRONMENT;TIMEOUT_MINUTES;DEPENDS;REQUIRED_FILES"
127 # the stuff to parse:
128 ${ARGN}
129 )
130
131 if(NOT "${PARSE_DEFAULT_ARGS}" STREQUAL "")
132 message("warning: unrecognized arguments '${PARSE_DEFAULT_ARGS}' to TRIBITS_DRIVER_ADD_DASHBOARD")
133 endif()
134
135 if(PARSE_CTEST_INSTALLER_TYPE)
136 set(ctest_type ${PARSE_CTEST_INSTALLER_TYPE})
137 else()
138 set(ctest_type "release")
139 endif()
140
141 if(PARSE_TIMEOUT_MINUTES)
142 math(EXPR timeout_seconds "60 * ${PARSE_TIMEOUT_MINUTES}")
143 else()
144 set(timeout_seconds 10800) # 3 hours...
145 endif()
146
147 add_test(${testname} ${CMAKE_COMMAND}
148 -D binary_dir=${CMAKE_CURRENT_BINARY_DIR}
149 -D source_dir=${CMAKE_CURRENT_SOURCE_DIR}
150 -D ctest_type=${ctest_type}
151 -D scriptname=${scriptname}
152 -D TD_BASE_DIR=${TD_BASE_DIR}
153 -D testname=${testname}
154 -P ${THIS_SCRIPT_DIR}/LocateCTestAndRunScript.cmake
155 )
156
157 # This test that runs the dashboard depends on the test that installs its
158 # driving ctest:
159 #
160 set_property(TEST ${testname} PROPERTY DEPENDS "install-cmake-${ctest_type}")
161
162 if(PARSE_DEPENDS)
163 set_property(TEST ${testname} PROPERTY DEPENDS "${PARSE_DEPENDS}")
164 endif()
165
166 if(PARSE_REQUIRED_FILES)
167 set_property(TEST ${testname} PROPERTY REQUIRED_FILES "${PARSE_REQUIRED_FILES}")
168 endif()
169
170 if(PARSE_ENVIRONMENT)
171 set_property(TEST ${testname} PROPERTY ENVIRONMENT
172 "${PARSE_ENVIRONMENT};TD_CTEST_VERSION_TYPE=${ctest_type}")
173 else()
174 set_property(TEST ${testname} PROPERTY ENVIRONMENT
175 "TD_CTEST_VERSION_TYPE=${ctest_type}")
176 endif()
177
178 set_property(TEST ${testname} PROPERTY
179 FAIL_REGULAR_EXPRESSION "error: TRIBITS_CTEST_DRIVER_ERROR_QUEUE")
180
181 if(PARSE_PROCESSORS)
182 set_property(TEST ${testname} PROPERTY PROCESSORS "${PARSE_PROCESSORS}")
183 endif()
184
185 if(PARSE_RUN_SERIAL)
186 set_property(TEST ${testname} PROPERTY RUN_SERIAL ON)
187 endif()
188
189 set_property(TEST ${testname} PROPERTY TIMEOUT "${timeout_seconds}")
190
191 # Track the required cmake installer types in a global property:
192 #
193 set_property(GLOBAL APPEND PROPERTY TD_CMAKE_INSTALLER_TYPES "${ctest_type}")
194
195 endfunction()
196
197
198 #
199 # Call this function last at the bottom of any drivers/MACHINE/CMakeLists.txt
200 # file. It will add tests as needed to download and install all the right
201 # flavors of ctest required to drive the other tests added with
202 # TRIBITS_DRIVER_ADD_DASHBOARD.
203 #
204 function(tribits_add_required_cmake_installs)
205
206 if (TRIBITS_TDD_USE_SYSTEM_CTEST STREQUAL "1")
207
208 message(STATUS "Skipping CMake install tests because TRIBITS_TDD_USE_SYSTEM_CTEST==1")
209
210 elseif (TDD_FORCE_INNER_CMAKE_INSTALL STREQUAL "1")
211
212 get_property(types GLOBAL PROPERTY TD_CMAKE_INSTALLER_TYPES)
213
214 if (types)
215 list(REMOVE_DUPLICATES types)
216 foreach (type ${types})
217 message(STATUS "Adding CMake install test ${type}")
218 tribits_driver_add_test_that_installs_cmake(${type})
219 endforeach()
220 else()
221 message("warning: no cmake install tests are necessary...")
222 message(" Put calls to TRIBITS_DRIVER_ADD_DASHBOARD")
223 message(" *before* calls to TRIBITS_ADD_REQUIRED_CMAKE_INSTALLS...")
224 endif()
225
226 else()
227
228 message(STATUS "Skipping CMake install tests because TDD_FORCE_INNER_CMAKE_INSTALL!=1")
229
230 endif()
231
232 endfunction()