Debian Codegraph @

cmake/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.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
11 include(TribitsGetCDashUrlsInsideCTestS)
12
13
14 # Wrapper used for unit testing purposes
15 #
16 macro(extrarepo_execute_process_wrapper)
17 if (NOT CTEST_DEPENDENCY_HANDLING_UNIT_TESTING)
18 execute_process(${ARGN}
19 RESULT_VARIABLE EXTRAREPO_EXECUTE_PROCESS_WRAPPER_RTN_VAL)
20 if (NOT EXTRAREPO_EXECUTE_PROCESS_WRAPPER_RTN_VAL STREQUAL "0")
21 message(SEND_ERROR
22 "Error: execute_process(${ARGN}) returned"
23 " '${EXTRAREPO_EXECUTE_PROCESS_WRAPPER_RTN_VAL}'")
24 endif()
25 else()
26 message("execute_process(${ARGN})")
27 endif()
28 endmacro()
29
30
31 # Update an existing git repo
32 #
33 function(tribits_update_git_extrarepo GIT_EXE EXTRAREPO_SRC_DIR)
34
35 set(EXTRAREPO_FETCH_OUT_FILE
36 "${CTEST_BINARY_DIRECTORY}/${EXTRAREPO_NAME_IN}.fetch.out")
37 set(EXTRAREPO_CLEAN_OUT_FILE
38 "${CTEST_BINARY_DIRECTORY}/${EXTRAREPO_NAME_IN}.clean.out")
39 set(EXTRAREPO_RESET_OUT_FILE
40 "${CTEST_BINARY_DIRECTORY}/${EXTRAREPO_NAME_IN}.reset.out")
41 set(EXTRAREPO_SET_BRANCH_OUT_FILE
42 "${CTEST_BINARY_DIRECTORY}/${EXTRAREPO_NAME_IN}.set_branch.out")
43
44 set(FETCH_CMND_ARGS
45 COMMAND "${GIT_EXE}" fetch ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}
46 TIMEOUT 600 # seconds
47 WORKING_DIRECTORY "${EXTRAREPO_SRC_DIR}"
48 OUTPUT_FILE "${EXTRAREPO_FETCH_OUT_FILE}" )
49 set(CLEAN_CMND_ARGS
50 COMMAND "${GIT_EXE}" clean -fdx
51 WORKING_DIRECTORY "${EXTRAREPO_SRC_DIR}"
52 OUTPUT_FILE "${EXTRAREPO_CLEAN_OUT_FILE}" )
53 set(RESET_CMND_ARGS
54 COMMAND "${GIT_EXE}" reset --hard HEAD
55 WORKING_DIRECTORY "${EXTRAREPO_SRC_DIR}"
56 OUTPUT_FILE "${EXTRAREPO_RESET_OUT_FILE}" )
57 if (${PROJECT_NAME}_EXTRAREPOS_BRANCH)
58 set(SET_BRANCH_CMND_ARGS
59 COMMAND "${GIT_EXE}" checkout -B ${${PROJECT_NAME}_EXTRAREPOS_BRANCH}
60 --track ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}/${${PROJECT_NAME}_EXTRAREPOS_BRANCH}
61 WORKING_DIRECTORY "${EXTRAREPO_SRC_DIR}"
62 OUTPUT_FILE "${EXTRAREPO_SET_BRANCH_OUT_FILE}" )
63 ELSE ()
64 set(SET_BRANCH_CMND_ARGS
65 COMMAND "${GIT_EXE}" reset --hard "@{u}"
66 WORKING_DIRECTORY "${EXTRAREPO_SRC_DIR}"
67 OUTPUT_FILE "${EXTRAREPO_SET_BRANCH_OUT_FILE}" )
68 endif()
69
70 extrarepo_execute_process_wrapper(${FETCH_CMND_ARGS})
71 extrarepo_execute_process_wrapper(${CLEAN_CMND_ARGS})
72 extrarepo_execute_process_wrapper(${RESET_CMND_ARGS})
73 extrarepo_execute_process_wrapper(${SET_BRANCH_CMND_ARGS})
74
75 endfunction()
76
77
78 # Update or clone a single extra repo
79 #
80 function(tribits_clone_or_update_extrarepo EXTRAREPO_NAME_IN EXTRAREPO_DIR_IN
81 EXTRAREPO_REPOTYPE_IN EXTRAREPO_REPOURL_IN
82 )
83
84 #message("TRIBITS_CLONE_OR_UPDATE_EXTRAREPO: ${EXTRAREPO_NAME_IN} ${EXTRAREPO_REPOURL_IN}")
85
86 set(EXTRAREPO_SRC_DIR "${${PROJECT_NAME}_SOURCE_DIRECTORY}/${EXTRAREPO_DIR_IN}")
87 #print_var(EXTRAREPO_SRC_DIR)
88
89 set(EXTRAREPO_CLONE_OUT_FILE
90 "${CTEST_BINARY_DIRECTORY}/${EXTRAREPO_NAME_IN}.clone.out")
91 set(EXTRAREPO_CHECKOUT_OUT_FILE
92 "${CTEST_BINARY_DIRECTORY}/${EXTRAREPO_NAME_IN}.checkout.out")
93
94 if (NOT EXISTS "${EXTRAREPO_SRC_DIR}")
95
96 message("\n${EXTRAREPO_NAME_IN}: Doing initial ${EXTRAREPO_REPOTYPE_IN}"
97 " clone/checkout from URL '${EXTRAREPO_REPOURL_IN}' to dir '${EXTRAREPO_DIR_IN}' ...")
98
99 # Set the command to clone
100 if (${EXTRAREPO_REPOTYPE_IN} STREQUAL GIT)
101 if (${PROJECT_NAME}_EXTRAREPOS_BRANCH)
102 set(CHECKOUT_BRANCH_ARG -b ${${PROJECT_NAME}_EXTRAREPOS_BRANCH})
103 else()
104 set(CHECKOUT_BRANCH_ARG)
105 endif()
106 set(CLONE_CMND_ARGS
107 COMMAND "${GIT_EXECUTABLE}" clone
108 ${CHECKOUT_BRANCH_ARG} -o ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}
109 "${EXTRAREPO_REPOURL}" ${EXTRAREPO_DIR_IN}
110 WORKING_DIRECTORY "${${PROJECT_NAME}_SOURCE_DIRECTORY}"
111 OUTPUT_FILE "${EXTRAREPO_CLONE_OUT_FILE}" )
112 else()
113 message(SEND_ERROR
114 "Error, Invalid EXTRAREPO_REPOTYPE_IN='${EXTRAREPO_REPOTYPE_IN}'!")
115 endif()
116
117 # Do the clone
118 extrarepo_execute_process_wrapper(${CLONE_CMND_ARGS})
119
120 else()
121
122 message("\n${EXTRAREPO_NAME_IN}: Doing ${EXTRAREPO_REPOTYPE_IN} update"
123 " from URL '${EXTRAREPO_REPOURL_IN}' to dir '${EXTRAREPO_SRC_DIR}' ...")
124
125 endif()
126
127 if (${EXTRAREPO_REPOTYPE_IN} STREQUAL GIT)
128 # Always update the git repo, even after a clone. See
129 # tribits_ctest_driver() documentation.
130 tribits_update_git_extrarepo("${GIT_EXECUTABLE}" "${EXTRAREPO_SRC_DIR}")
131 else()
132 message(SEND_ERROR
133 "Error, Invalid EXTRAREPO_REPOTYPE_IN='${EXTRAREPO_REPOTYPE_IN}'!")
134 endif()
135
136 endfunction()
137
138
139 # Clone or update all of the extra repos and put them on the right branch.
140 #
141 # NOTE: The base repo is cloned by ctest_start() and updated by ctest_update()
142 # before calling this function. This function only operates on the extra
143 # repos.
144 #
145 function(tribits_clone_or_update_extra_repos CTEST_UPDATE_RETURN_VAL
146 UPDATE_FAILED_VAR_OUT
147 )
148
149 set(UPDATE_FAILED FALSE)
150
151 if (${PROJECT_NAME}_EXTRAREPOS_BRANCH)
152 message("For extra repos, doing switch to branch ${${PROJECT_NAME}_EXTRAREPOS_BRANCH}")
153 endif()
154
155 set(EXTRAREPO_IDX 0)
156 foreach(EXTRAREPO_NAME ${${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES})
157 list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS ${EXTRAREPO_IDX}
158 EXTRAREPO_DIR )
159 list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_VCTYPES ${EXTRAREPO_IDX}
160 EXTRAREPO_REPOTYPE )
161 list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_REPOURLS ${EXTRAREPO_IDX}
162 EXTRAREPO_REPOURL )
163 tribits_clone_or_update_extrarepo( ${EXTRAREPO_NAME} ${EXTRAREPO_DIR}
164 ${EXTRAREPO_REPOTYPE} ${EXTRAREPO_REPOURL} )
165 # ToDo: Detect and return failure in cloning or updating extra repos!
166 math(EXPR EXTRAREPO_IDX "${EXTRAREPO_IDX}+1")
167 endforeach()
168
169 set(${UPDATE_FAILED_VAR_OUT} ${UPDATE_FAILED} PARENT_SCOPE)
170
171 endfunction()
172
173
174 # Create the Updates.txt file
175 #
176 function(tribits_create_repo_updates_file)
177 extrarepo_execute_process_wrapper(
178 COMMAND ${Python3_EXECUTABLE}
179 ${GITDIST_EXE} --dist-no-color
180 log "--pretty=format:%h: %s%nAuthor: %an <%ae>%nDate: %ad%n"
181 --name-status -C ORIG_HEAD..HEAD
182 WORKING_DIRECTORY ${CTEST_SOURCE_DIRECTORY}
183 OUTPUT_FILE "${CTEST_BINARY_DIRECTORY}/Updates.txt"
184 )
185 endfunction()
186
187
188 # Select the set of extra repositories
189 #
190 macro(tribits_setup_extrarepos)
191
192 if (EXISTS "${${PROJECT_NAME}_EXTRAREPOS_FILE}" )
193 # Repos many not already exist because we have not cloned them yet!
194 set(${PROJECT_NAME}_CHECK_EXTRAREPOS_EXIST FALSE)
195 tribits_get_and_process_extra_repositories_lists()
196 else()
197 message("${${PROJECT_NAME}_EXTRAREPOS_FILE} does not exist,"
198 " skipping extra repositories.")
199 endif()
200
201 endmacro()
202
203
204 # Select the list of packages
205 #
206 # OUTPUT: Sets ${PROJECT_NAME}_DEFAULT_PACKAGES
207 #
208 # NOTE: This macro is used to clean up the main tribits_ctest_driver()
209 # macro.
210 #
211 macro(tribits_setup_packages)
212
213 include(TribitsPrintDependencyInfo)
214 include(TribitsWriteXmlDependenciesFiles)
215
216 # Here, we must point into the source tree just cloned (or updated)
217 # and not the "driver" source dir tree for two reasons. First, the
218 # list of core packages may be more recent in what was checked out.
219 # Second, the extra repos do not even exist in the "driver" source
220 # tree.
221
222 set(${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES OFF)
223 set(${PROJECT_NAME}_OUTPUT_DEPENDENCY_FILES FALSE)
224 if (CTEST_GENERATE_OUTER_DEPS_XML_OUTPUT_FILE)
225 set(${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE
226 "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_PACKAGE_DEPS_XML_FILE_NAME}")
227 else()
228 set(${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE)
229 endif()
230 if (CTEST_SUBMIT_CDASH_SUBPROJECTS_DEPS_FILE)
231 set(${PROJECT_NAME}_CDASH_DEPS_XML_OUTPUT_FILE
232 "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_CDASH_SUBPROJECT_DEPS_XML_FILE_NAME}" )
233 else()
234 set(${PROJECT_NAME}_CDASH_DEPS_XML_OUTPUT_FILE)
235 endif()
236 set(${PROJECT_NAME}_DEPS_HTML_OUTPUT_FILE)
237
238 # Don't ignore missing repos by default. This will allow processing to
239 # continue but this outer CTest script will fail (thereby sending a CDash
240 # email from the TDD system). However, when we configure actual packages,
241 # we do set this to TRUE so that the package configures will not fail due to
242 # missing extra repositories.
243 set_default_and_from_env(${PROJECT_NAME}_IGNORE_MISSING_EXTRA_REPOSITORIES FALSE)
244 set_default_and_from_env(${PROJECT_NAME}_PRE_REPOSITORIES "")
245 set_default_and_from_env(${PROJECT_NAME}_EXTRA_REPOSITORIES "")
246 split("${${PROJECT_NAME}_PRE_REPOSITORIES}" "," ${PROJECT_NAME}_PRE_REPOSITORIES)
247 split("${${PROJECT_NAME}_EXTRA_REPOSITORIES}" "," ${PROJECT_NAME}_EXTRA_REPOSITORIES)
248
249 tribits_read_in_native_repositories()
250 tribits_combine_native_and_extra_repos()
251 tribits_read_all_project_deps_files_create_deps_graph()
252 tribits_print_initial_dependency_info()
253 tribits_write_xml_dependency_files()
254
255 # When we get here, we will have the basic dependency structure set up
256 # with only defaults set
257
258 # Set this to "" so that it can be defined in enable_modified_packages_only()
259 set(${PROJECT_NAME}_ENABLE_ALL_PACKAGES "")
260
261 endmacro()
262
263
264 macro(enable_package_if_not_explicitly_excluded TRIBITS_PACKAGE)
265 if ("${${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}}" STREQUAL "")
266 message("Enabling explicitly set package ${TRIBITS_PACKAGE} ...")
267 set(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE} ON)
268 elseif(NOT ${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE})
269 if (${TRIBITS_PACKAGE}_EXPLICITY_EXCLUDED)
270 message("NOT enabling explicitly set package ${TRIBITS_PACKAGE} since it was explicitly excluded!")
271 else()
272 message("Enabling explicitly set package ${TRIBITS_PACKAGE} which was default or otherwise disabled!")
273 set(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE} ON)
274 endif()
275 else()
276 message("Explicitly set package ${TRIBITS_PACKAGE} is already enabled?")
277 endif()
278 endmacro()
279
280
281 # Select packages set by the input
282 #
283 macro(enable_user_selected_packages)
284
285 # 1) Set the enables for packages
286
287 if (${PROJECT_NAME}_PACKAGE_ENABLES_FILE)
288 message("Setting package enables specified in file"
289 " '${${PROJECT_NAME}_PACKAGE_ENABLES_FILE}'")
290 include(${${PROJECT_NAME}_PACKAGE_ENABLES_FILE})
291 elseif (NOT "${${PROJECT_NAME}_PACKAGES_USER_SELECTED}" STREQUAL "")
292 foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES_USER_SELECTED})
293 enable_package_if_not_explicitly_excluded(${TRIBITS_PACKAGE})
294 endforeach()
295 else()
296 message("Setting ${PROJECT_NAME}_ENABLE_ALL_PACKAGES=ON since"
297 " ${PROJECT_NAME}_PACKAGES_USER_SELECTED='${${PROJECT_NAME}_PACKAGES_USER_SELECTED}'")
298 set(${PROJECT_NAME}_ENABLE_ALL_PACKAGES ON)
299 endif()
300
301 # 2) Set extra package enables from ${PROJECT_NAME}_ADDITIONAL_PACKAGES
302
303 foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_ADDITIONAL_PACKAGES})
304 enable_package_if_not_explicitly_excluded(${TRIBITS_PACKAGE})
305 endforeach()
306
307 endmacro()
308
309
310 # Extract the list of changed files for the main repo on put into an
311 # modified files file.
312 #
313 macro(tribits_get_modified_files WORKING_DIR_IN MODIFIED_FILES_FILE_NAME_IN)
314 set(CMND_ARGS
315 COMMAND "${GIT_EXECUTABLE}" diff --name-only ORIG_HEAD..HEAD
316 WORKING_DIRECTORY "${WORKING_DIR_IN}"
317 OUTPUT_FILE ${MODIFIED_FILES_FILE_NAME_IN}
318 #OUTPUT_STRIP_TRAILING_WHITESPACE
319 )
320 if (NOT CTEST_DEPENDENCY_HANDLING_UNIT_TESTING)
321 execute_process(${CMND_ARGS})
322 else()
323 message("execute_process(${CMND_ARGS})")
324 endif()
325 endmacro()
326
327
328 # Select only packages that are modified or failed in the last CI iteration
329 #
330 macro(enable_only_modified_packages)
331
332 #
333 # A) Get the list of changed packages
334 #
335
336 set(MODIFIED_FILES_FILE_NAME "${CTEST_BINARY_DIRECTORY}/modifiedFiles.txt")
337
338 # A.1) Get changes from main ${PROJECT_NAME} repo
339
340 tribits_get_modified_files("${CTEST_SOURCE_DIRECTORY}" "${MODIFIED_FILES_FILE_NAME}")
341
342 # A.2) Get changes from extra repos
343
344 set(EXTRAREPO_IDX 0)
345 foreach(EXTRAREPO_NAME ${${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES})
346
347 list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS
348 ${EXTRAREPO_IDX} EXTRAREPO_DIR )
349 list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_HASPKGS
350 ${EXTRAREPO_IDX} EXTRAREPO_PACKSTAT )
351
352 # For now, only look for changes if it has packages. Later, we may need
353 # to generalize this for the general extra repo case with deeper directory
354 # and other VC systems than GIT.
355 if (EXTRAREPO_PACKSTAT STREQUAL HASPACKAGES)
356
357 set(EXTRAREPO_SRC_DIR "${CTEST_SOURCE_DIRECTORY}/${EXTRAREPO_DIR}")
358 set(EXTRAREPO_MODIFIED_FILES_FILE_NAME
359 "${CTEST_BINARY_DIRECTORY}/modifiedFiles.${EXTRAREPO_NAME}.txt")
360
361 tribits_get_modified_files("${EXTRAREPO_SRC_DIR}"
362 "${EXTRAREPO_MODIFIED_FILES_FILE_NAME}")
363
364 file(STRINGS ${EXTRAREPO_MODIFIED_FILES_FILE_NAME} EXTRAREPO_MODIFIED_FILES_STR)
365 set(EXTRAREPO_FILES_STR "")
366 foreach(STR_LINE ${EXTRAREPO_MODIFIED_FILES_STR})
367 string(APPEND EXTRAREPO_FILES_STR "${EXTRAREPO_DIR}/${STR_LINE}\n")
368 endforeach()
369 file(APPEND "${MODIFIED_FILES_FILE_NAME}" ${EXTRAREPO_FILES_STR})
370
371 endif()
372
373 math(EXPR EXTRAREPO_IDX "${EXTRAREPO_IDX}+1")
374
375 endforeach()
376
377 # A.3) Get the names of the modified packages
378
379 if (NOT Python3_EXECUTABLE)
380 message(FATAL_ERROR "Error, Python must be enabled to map from modified"
381 " files to packages!")
382 endif()
383
384 if (EXISTS "${MODIFIED_FILES_FILE_NAME}")
385 execute_process(
386 COMMAND ${Python3_EXECUTABLE}
387 ${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages-from-files-list.py
388 --files-list-file=${MODIFIED_FILES_FILE_NAME}
389 --project-dir=${TRIBITS_PROJECT_ROOT}
390 --deps-xml-file=${CTEST_BINARY_DIRECTORY}/${${PROJECT_NAME}_PACKAGE_DEPS_XML_FILE_NAME}
391 OUTPUT_VARIABLE MODIFIED_PACKAGES_LIST
392 OUTPUT_STRIP_TRAILING_WHITESPACE
393 )
394 else()
395 set(MODIFIED_PACKAGES_LIST)
396 endif()
397
398 split("${MODIFIED_PACKAGES_LIST}" "," MODIFIED_PACKAGES_LIST)
399 print_var(MODIFIED_PACKAGES_LIST)
400
401 #
402 # B) Get the list of packages that failed last CI iteration
403 #
404
405 # NOTE: It is critical to enable and test packages until they pass. If you
406 # don't do this, then the package will not show as updated in the above
407 # logic. In this case only downstream packages will get enabled. If the
408 # failing packages break the downstream packages, this will be bad (for lots
409 # of reasons). Therefore, we must enable failing packages from the last CI
410 # iteration and keep enabling and testing them until they do pass!
411
412 if (EXISTS "${FAILED_PACKAGES_FILE_NAME}")
413 file(READ "${FAILED_PACKAGES_FILE_NAME}" FAILING_PACKAGES_LIST)
414 string(STRIP "${FAILING_PACKAGES_LIST}" FAILING_PACKAGES_LIST)
415 print_var(FAILING_PACKAGES_LIST)
416 endif()
417
418 #
419 # C) Enable the changed and previously failing packages
420 #
421
422 foreach(TRIBITS_PACKAGE ${MODIFIED_PACKAGES_LIST})
423 #print_var(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE})
424 assert_defined(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE})
425 if ("${${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}}" STREQUAL "")
426 if (
427 ${TRIBITS_PACKAGE} STREQUAL "ALL_PACKAGES"
428 OR
429 ${TRIBITS_PACKAGE}_TESTGROUP STREQUAL "PT"
430 OR
431 (
432 ${TRIBITS_PACKAGE}_TESTGROUP STREQUAL "ST"
433 AND
434 ${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE
435 )
436 )
437 message("Enabling modified package: ${TRIBITS_PACKAGE}")
438 set(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE} ON)
439 else()
440 message("NOT enabling modified ST package: ${TRIBITS_PACKAGE}")
441 endif()
442 else()
443 message("Not enabling explicitly disabled modified package: ${TRIBITS_PACKAGE}")
444 endif()
445 endforeach()
446
447 if (FAILING_PACKAGES_LIST STREQUAL "ALL_PACKAGES")
448 message("Enabling previously failing ALL_PACKAGES")
449 set(${PROJECT_NAME}_ENABLE_ALL_PACKAGES ON)
450 else()
451 foreach(TRIBITS_PACKAGE ${FAILING_PACKAGES_LIST})
452 if ("${${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}}" STREQUAL "")
453 if (
454 ${TRIBITS_PACKAGE}_TESTGROUP STREQUAL "PT"
455 OR
456 (
457 ${TRIBITS_PACKAGE}_TESTGROUP STREQUAL "ST"
458 AND
459 ${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE
460 )
461 )
462 message("Enabling previously failing package: ${TRIBITS_PACKAGE}")
463 set(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE} ON)
464 else()
465 message("NOT enabling previously failing ST package: ${TRIBITS_PACKAGE}")
466 endif()
467 else()
468 message("Not enabling explicitly disabled previously"
469 " failing package: ${TRIBITS_PACKAGE}")
470 endif()
471 endforeach()
472 endif()
473
474 #
475 # D) Print the final status
476 #
477
478 if (${PROJECT_NAME}_ENABLE_ALL_PACKAGES)
479 if (NOT ${PROJECT_NAME}_CTEST_DO_ALL_AT_ONCE)
480 message(FATAL_ERROR
481 "Error, failing 'ALL_PACKAGES' only allowed with all-at-once mode!")
482 endif()
483 message("\nDirectly modified or failing non-disabled packages that need"
484 " to be tested: ALL_PACKAGES")
485 else()
486 tribits_print_package_list_enable_status(
487 "\nDirectly modified or failing non-disabled packages that need to be tested"
488 INTERNAL ON NONEMPTY )
489 endif()
490
491 endmacro()
492
493
494 # Exclude disabled packages from ${PROJECT_NAME}_EXCLUDE_PACKAGES
495 #
496 # NOTE: These disables need to dominate over the above enables so this code is
497 # after all the enable code has run
498 #
499 macro(disable_excluded_packages)
500 foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_EXCLUDE_PACKAGES})
501 message("Disabling excluded package ${TRIBITS_PACKAGE} ...")
502 set(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE} OFF)
503 set(${TRIBITS_PACKAGE}_EXPLICITY_EXCLUDED TRUE)
504 endforeach()
505 endmacro()
506
507
508 # Remove packages that are only implicitly enabled but don't have tests
509 # enabled.
510 #
511 macro(select_final_set_of_packages_to_directly_test)
512
513 set(${PROJECT_NAME}_PACKAGES_TO_DIRECTLY_TEST)
514
515 foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES})
516
517 set(PROCESS_THE_PACKAGE FALSE)
518
519 if (${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}
520 AND ${TRIBITS_PACKAGE}_ENABLE_TESTS
521 )
522 set(PROCESS_THE_PACKAGE TRUE)
523 elseif (${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}
524 AND CTEST_EXPLICITLY_ENABLE_IMPLICITLY_ENABLED_PACKAGES
525 )
526 set(PROCESS_THE_PACKAGE TRUE)
527 endif()
528
529 if(PROCESS_THE_PACKAGE)
530 append_set(${PROJECT_NAME}_PACKAGES_TO_DIRECTLY_TEST ${TRIBITS_PACKAGE})
531 endif()
532
533 endforeach()
534
535 endmacro()
536
537
538 # Set mapping of labels to subprojects (i.e. TriBITS packages) for CDash.
539 #
540 # NOTE: Unlike for the inner CMake configure, only subprojects that are
541 # explicitly tested will be marked as a CDash subproject. This limits the
542 # rows in CDash. This does not seem to be a problem for when running ctest
543 # locally. When run locally, ctest will just report aggregated times for
544 # subprojects that have 1 or more tests. Not true for CDash.
545 #
546 macro(tribits_ctest_driver_set_labels_to_subprojects_mapping)
547 set(CTEST_LABELS_FOR_SUBPROJECTS)
548 foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES_TO_DIRECTLY_TEST})
549 list(APPEND CTEST_LABELS_FOR_SUBPROJECTS ${TRIBITS_PACKAGE})
550 endforeach()
551 endmacro()
552
553
554 # Select the default generator.
555 #
556 macro(select_default_generator)
557 # When the build tree is known and exists, use
558 # its generator.
559 set(DEFAULT_GENERATOR "DID NOT SET!")
560 if(EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt")
561 file(STRINGS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt"
562 line REGEX "^CMAKE_GENERATOR:" LIMIT_COUNT 1)
563 if("${line}" MATCHES "=(.+)$")
564 set(DEFAULT_GENERATOR "${CMAKE_MATCH_1}")
565 endif()
566 else()
567 set(DEFAULT_GENERATOR "Unix Makefiles")
568 endif()
569 endmacro()
570
571
572 # Call INITIALIZE_ERROR_QUEUE once at the top of TRIBITS_CTEST_DRIVER
573 #
574 macro(initialize_error_queue)
575 set(TRIBITS_CTEST_DRIVER_ERROR_QUEUE "")
576 endmacro()
577
578
579 # QUEUE_ERROR should be called only for errors that are not already reported to
580 # the dashboard in some other way. For example, if calling ctest_submit fails,
581 # then that failure does NOT show up on the dashboard, so it is appropriate to
582 # call QUEUE_ERROR for that case. For a build error or test failure, it is NOT
583 # appropriate to call QUEUE_ERROR because those already show up on the
584 # dashboard (assuming a good ctest_submit...)
585 #
586 # When adding more callers of QUEUE_ERROR, just make sure that it does not
587 # duplicate an existing/reported dashboard failure.
588 #
589 macro(queue_error err_msg)
590 set(TRIBITS_CTEST_DRIVER_ERROR_QUEUE
591 ${TRIBITS_CTEST_DRIVER_ERROR_QUEUE} "${err_msg}")
592 endmacro()
593
594
595 # Call report_queued_errors() once at the bottom of tribits_ctest_driver()
596 #
597 macro(report_queued_errors)
598 if ("${TRIBITS_CTEST_DRIVER_ERROR_QUEUE}" STREQUAL "")
599 message("TRIBITS_CTEST_DRIVER_ERROR_QUEUE is empty. All is well.")
600 else()
601 message("ERROR: TRIBITS_CTEST_DRIVER_ERROR_QUEUE reports the following error message queue:")
602 foreach(err_msg ${TRIBITS_CTEST_DRIVER_ERROR_QUEUE})
603 message("${err_msg}")
604 endforeach()
605 endif()
606 endmacro()
607
608
609 # Setup for tracking if a configure is being attempted to keep memory if it
610 # will pass or not.
611 #
612 # This will wrilte files in the directory ${CTEST_BINARY_DIRECTORY} to keep
613 # track of this across multiple ctest -S script invocations.
614 #
615 macro(tribits_remember_if_configure_attempted)
616
617 # Must always define these files names as they they are used in functions
618 # called later in the same ctest -S invocation!
619 set(CONFIGURE_ATTEMPTED_FILE
620 "${CTEST_BINARY_DIRECTORY}/ConfigureAttempted.txt")
621 set(CONFIGURE_PASSED_FILE
622 "${CTEST_BINARY_DIRECTORY}/ConfigurePasssed.txt")
623
624 if (CTEST_DO_CONFIGURE)
625 file(WRITE "${CONFIGURE_ATTEMPTED_FILE}" "Attempting configure")
626 if (EXISTS "${CONFIGURE_PASSED_FILE}")
627 file(REMOVE "${CONFIGURE_PASSED_FILE}")
628 endif()
629 elseif(CTEST_DO_NEW_START)
630 if (EXISTS "${CONFIGURE_ATTEMPTED_FILE}")
631 file(REMOVE "${CONFIGURE_ATTEMPTED_FILE}")
632 endif()
633 if (EXISTS "${CONFIGURE_PASSED_FILE}")
634 file(REMOVE "${CONFIGURE_PASSED_FILE}")
635 endif()
636 endif()
637
638 endmacro()
639 # NOTE: Above, this is made a macro because it defines the vars
640 # CONFIGURE_ATTEMPTED_FILE and CONFIGURE_PASSED_FILE at the top function
641 # scope. This is needed so the below functions will see them set.
642
643
644 # Determine if a past configure was attempted but did not pass
645 #
646 function(tribits_previous_configure_attempted_but_not_passsed
647 PREVIOUS_CONFIGURE_ATTEMPTED_BUT_NOT_PASSSED_VAR_OUT
648 )
649
650 #print_var(CONFIGURE_ATTEMPTED_FILE)
651 #print_var(CONFIGURE_PASSED_FILE)
652
653 if(
654 (EXISTS "${CONFIGURE_ATTEMPTED_FILE}")
655 AND
656 (NOT EXISTS "${CONFIGURE_PASSED_FILE}")
657 )
658 set(PREVIOUS_CONFIGURE_ATTEMPTED_BUT_NOT_PASSSED TRUE)
659 else()
660 set(PREVIOUS_CONFIGURE_ATTEMPTED_BUT_NOT_PASSSED FALSE)
661 endif()
662
663 set(${PREVIOUS_CONFIGURE_ATTEMPTED_BUT_NOT_PASSSED_VAR_OUT}
664 ${PREVIOUS_CONFIGURE_ATTEMPTED_BUT_NOT_PASSSED} PARENT_SCOPE)
665
666 endfunction()
667
668
669 # Remember that the configure passed for later ctest -S invocations
670 #
671 function(tribits_remember_configure_passed)
672 file(WRITE "${CONFIGURE_PASSED_FILE}" "Configure Passed!")
673 endfunction()
674
675
676 # Override CTEST_SUBMIT to drive multiple submits and to detect failed
677 # submissions and track them as queued errors.
678 #
679 macro(tribits_ctest_submit)
680
681 # Cache the original CTEST_DROP_SITE and CTEST_DROP_LOCATION
682 if ("${TRIBITS_CTEST_DROP_SITE_ORIG}" STREQUAL "")
683 set(TRIBITS_CTEST_DROP_SITE_ORIG ${CTEST_DROP_SITE})
684 if (TRIBITS_CTEST_SUBMIT_DEBUG_DUMP)
685 print_var(TRIBITS_CTEST_DROP_SITE_ORIG)
686 endif()
687 endif()
688 if ("${TRIBITS_CTEST_DROP_LOCATION_ORIG}" STREQUAL "")
689 set(TRIBITS_CTEST_DROP_LOCATION_ORIG ${CTEST_DROP_LOCATION})
690 if (TRIBITS_CTEST_SUBMIT_DEBUG_DUMP)
691 print_var(TRIBITS_CTEST_DROP_LOCATION_ORIG)
692 endif()
693 endif()
694
695 # Do the first submit
696 set(CTEST_DROP_SITE ${TRIBITS_CTEST_DROP_SITE_ORIG})
697 set(CTEST_DROP_LOCATION ${TRIBITS_CTEST_DROP_LOCATION_ORIG})
698 if (TRIBITS_CTEST_SUBMIT_DEBUG_DUMP)
699 print_var(CTEST_DROP_SITE)
700 print_var(CTEST_DROP_LOCATION)
701 endif()
702
703 tribits_ctest_submit_driver(${ARGN})
704
705 # Do the second submit if requested!
706 if (TRIBITS_2ND_CTEST_DROP_SITE OR TRIBITS_2ND_CTEST_DROP_LOCATION)
707
708 message("\nDoing submit to second CDash site ...\n")
709
710 if (NOT "${TRIBITS_2ND_CTEST_DROP_SITE}" STREQUAL "")
711 if (TRIBITS_CTEST_SUBMIT_DEBUG_DUMP)
712 print_var(TRIBITS_2ND_CTEST_DROP_SITE)
713 endif()
714 set(CTEST_DROP_SITE ${TRIBITS_2ND_CTEST_DROP_SITE})
715 endif()
716
717 if (NOT "${TRIBITS_2ND_CTEST_DROP_LOCATION}" STREQUAL "")
718 if (TRIBITS_CTEST_SUBMIT_DEBUG_DUMP)
719 print_var(TRIBITS_2ND_CTEST_DROP_LOCATION)
720 endif()
721 set(CTEST_DROP_LOCATION ${TRIBITS_2ND_CTEST_DROP_LOCATION})
722 endif()
723
724 tribits_ctest_submit_driver(${ARGN})
725
726 endif()
727
728 endmacro()
729
730
731 macro(tribits_ctest_submit_driver)
732
733 # If using a recent enough ctest with RETRY_COUNT, use it to overcome
734 # failed submits:
735 set(retry_args "")
736 set(retry_args
737 RETRY_COUNT ${CTEST_SUBMIT_RETRY_COUNT}
738 RETRY_DELAY ${CTEST_SUBMIT_RETRY_DELAY})
739 message("info: using retry_args='${retry_args}' for _ctest_submit call")
740
741 # Call the original CTEST_SUBMIT and pay attention to its RETURN_VALUE:
742 ctest_submit(${ARGN} ${retry_args} RETURN_VALUE rv)
743
744 if(NOT "${rv}" STREQUAL "0")
745 queue_error("error: ctest_submit failed: rv='${rv}' ARGN='${ARGN}' retry_args='${retry_args}'")
746 endif()
747
748 endmacro()
749
750
751 # Wrapper for ctest_update(...) for unit testing
752 #
753 macro(ctest_update_wrapper)
754 if (NOT CTEST_UPDATE_UNIT_TESTING_MODE)
755 ctest_update(${ARGN})
756 else()
757 message("ctest_update(${ARGN})")
758 set(UPDATE_RETURN_VAL ${CTEST_UPDATE_RETURN_VAL})
759 endif()
760 endmacro()
761
762
763 # Helper macros to pass through common CMake configure arguments used by both
764 # package-by-package approach and all-at-once approach
765 #
766 macro(tribits_fwd_cmake_config_args_0)
767 set( CONFIGURE_OPTIONS
768 "-D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}"
769 "-DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS}"
770 "-D${PROJECT_NAME}_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON"
771 "-D${PROJECT_NAME}_WARNINGS_AS_ERRORS_FLAGS:STRING=${${PROJECT_NAME}_WARNINGS_AS_ERRORS_FLAGS}"
772 "-D${PROJECT_NAME}_ALLOW_NO_PACKAGES:BOOL=ON"
773 "-D${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=${${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES}"
774 )
775 if (NOT CTEST_GENERATE_DEPS_XML_OUTPUT_FILE)
776 list(APPEND CONFIGURE_OPTIONS
777 "-D${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE:FILEPATH=")
778 endif()
779 if (NOT "${${PROJECT_NAME}_GENERATE_VERSION_DATE_FILES}" STREQUAL "")
780 list(APPEND CONFIGURE_OPTIONS
781 "-D${PROJECT_NAME}_GENERATE_VERSION_DATE_FILES:BOOL=${${PROJECT_NAME}_GENERATE_VERSION_DATE_FILES}")
782 endif()
783 if (NOT "${${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE}" STREQUAL "")
784 list(APPEND CONFIGURE_OPTIONS
785 "-D${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE:BOOL=${${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE}")
786 endif()
787 if (NOT MPI_EXEC_MAX_NUMPROCS STREQUAL 0)
788 list(APPEND CONFIGURE_OPTIONS
789 "-DMPI_EXEC_MAX_NUMPROCS:STRING=${MPI_EXEC_MAX_NUMPROCS}")
790 endif()
791 if (${PROJECT_NAME}_SKIP_CTEST_ADD_TEST)
792 list(APPEND CONFIGURE_OPTIONS
793 "-D${PROJECT_NAME}_SKIP_CTEST_ADD_TEST:BOOL=${${PROJECT_NAME}_SKIP_CTEST_ADD_TEST}")
794 endif()
795 if (CTEST_DO_COVERAGE_TESTING)
796 list(APPEND CONFIGURE_OPTIONS
797 "-D${PROJECT_NAME}_ENABLE_COVERAGE_TESTING:BOOL=ON")
798 endif()
799 if (${PROJECT_NAME}_EXTRAREPOS_FILE STREQUAL "NONE")
800 set(EXTRAREOS_FILE_PASSED "")
801 else()
802 set(EXTRAREOS_FILE_PASSED "${${PROJECT_NAME}_EXTRAREPOS_FILE}")
803 endif()
804 list(APPEND CONFIGURE_OPTIONS
805 "-D${PROJECT_NAME}_EXTRAREPOS_FILE:STRING=${EXTRAREOS_FILE_PASSED}")
806 list(APPEND CONFIGURE_OPTIONS # See TRIBITS_SETUP_PACKAGES
807 "-D${PROJECT_NAME}_IGNORE_MISSING_EXTRA_REPOSITORIES:BOOL=ON")
808 list(APPEND CONFIGURE_OPTIONS
809 "-D${PROJECT_NAME}_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE:STRING=${${PROJECT_NAME}_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE}")
810 if (CTEST_DO_INSTALL)
811 list(APPEND CONFIGURE_OPTIONS
812 "-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON")
813 endif()
814 endmacro()
815
816
817 macro(tribits_fwd_cmake_config_args_1)
818 set(CONFIGURE_OPTIONS ${CONFIGURE_OPTIONS}
819 ${EXTRA_SYSTEM_CONFIGURE_OPTIONS} ${EXTRA_CONFIGURE_OPTIONS}
820 ${${PROJECT_NAME}_EXTRA_CONFIGURE_OPTIONS} )
821 endmacro()
822
823
824 # Remove the all of the LastTestsFailed*.log files so we can determine if any
825 # tests have failed.
826 #
827 macro(tribits_remove_last_test_failed_log_file)
828 # Remove the LastTestsFailed log so we can detect if there are any
829 # failed tests.
830 set(TEST_TMP_DIR "${CTEST_BINARY_DIRECTORY}/Testing/Temporary")
831 set(LAST_TESTS_FILED_LOG_FILE_GLOB "${TEST_TMP_DIR}/LastTestsFailed*.log")
832 file(GLOB logfiles "${LAST_TESTS_FILED_LOG_FILE_GLOB}")
833 foreach(logfile ${logfiles})
834 file(REMOVE "${logfile}")
835 endforeach()
836 endmacro()
837
838
839 # Sets the var FAILED_TEST_LOG_FILE if the file is found
840 macro(tribits_find_last_test_failed_log_file)
841 file(GLOB FAILED_TEST_LOG_FILE "${LAST_TESTS_FILED_LOG_FILE_GLOB}")
842 endmacro()
843
844
845 # Get names of failed packages from failed tests
846 function(tribits_get_failed_packages_from_failed_tests
847 LAST_TESTS_FAILED_FILE FAILED_PACKAGES_OUT
848 )
849 execute_process(
850 COMMAND ${Python3_EXECUTABLE}
851 "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages-from-last-tests-failed.py"
852 "--deps-xml-file=${CTEST_BINARY_DIRECTORY}/${${PROJECT_NAME}_PACKAGE_DEPS_XML_FILE_NAME}"
853 "--last-tests-failed-file=${LAST_TESTS_FAILED_FILE}"
854 OUTPUT_VARIABLE FAILED_PACKAGES
855 OUTPUT_STRIP_TRAILING_WHITESPACE
856 )
857 split("${FAILED_PACKAGES}" "," FAILED_PACKAGES)
858 set(${FAILED_PACKAGES_OUT} "${FAILED_PACKAGES}" PARENT_SCOPE)
859 endfunction()
860
861
862 # Drive the configure, build, test, and submit package-by-package
863 #
864 # Sets ${PROJECT_NAME}_FAILED_PACKAGES as an indication if there are any
865 # failures.
866 #
867 macro(tribits_ctest_package_by_package)
868
869 message(
870 "\n***"
871 "\n*** Loop through ${PROJECT_NAME} packages to configure, build, and test ..."
872 "\n***")
873
874 set(${PROJECT_NAME}_LAST_CONFIGURED_PACKAGE)
875 set(${PROJECT_NAME}_FAILED_LIB_BUILD_PACKAGES)
876 set(PACKAGE_IDX 0)
877
878 foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES_TO_DIRECTLY_TEST})
879
880 message("")
881 message("${PACKAGE_IDX}) Processing current package ${TRIBITS_PACKAGE}:"
882 " libs='${${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}}',"
883 " tests='${${TRIBITS_PACKAGE}_ENABLE_TESTS}'")
884 message("")
885
886 set_property(GLOBAL PROPERTY SubProject ${TRIBITS_PACKAGE})
887 set_property(GLOBAL PROPERTY Label ${TRIBITS_PACKAGE})
888
889 #
890 # A) Configure the package and its dependent packages
891 #
892
893 message("Configuring TRIBITS_PACKAGE='${TRIBITS_PACKAGE}'")
894
895 # Create CONFIGURE_OPTIONS for this TRIBITS_PACKAGE
896 tribits_fwd_cmake_config_args_0()
897 list(APPEND CONFIGURE_OPTIONS
898 "-D${PROJECT_NAME}_ENABLE_TESTS:BOOL=${${TRIBITS_PACKAGE}_ENABLE_TESTS}")
899 if (DEFINED ${PROJECT_NAME}_LAST_CONFIGURED_PACKAGE)
900 list(APPEND CONFIGURE_OPTIONS
901 "-D${PROJECT_NAME}_ENABLE_${${PROJECT_NAME}_LAST_CONFIGURED_PACKAGE}:BOOL=")
902 set(${PROJECT_NAME}_LAST_CONFIGURED_PACKAGE)
903 endif()
904 list(APPEND CONFIGURE_OPTIONS
905 "-D${PROJECT_NAME}_DEFINE_MISSING_PACKAGE_LIBS_TARGETS=ON")
906 foreach(FAILED_PACKAGE ${${PROJECT_NAME}_FAILED_LIB_BUILD_PACKAGES})
907 list(APPEND CONFIGURE_OPTIONS
908 "-D${PROJECT_NAME}_ENABLE_${FAILED_PACKAGE}:BOOL=OFF")
909 endforeach()
910 tribits_fwd_cmake_config_args_1()
911 list(APPEND CONFIGURE_OPTIONS # Package enable must be at the very end to override other stuff!
912 "-D${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}:BOOL=ON" )
913 message("\nCONFIGURE_OPTIONS = '${CONFIGURE_OPTIONS}'")
914
915 # Remember this package so we can set its enable to "" next time
916 set(${PROJECT_NAME}_LAST_CONFIGURED_PACKAGE "${TRIBITS_PACKAGE}")
917
918 #
919 # B) Configure the package and its dependent packages
920 #
921
922 set(PBP_CONFIGURE_PASSED TRUE)
923
924 if (CTEST_DEPENDENCY_HANDLING_UNIT_TESTING)
925
926 message("${TRIBITS_PACKAGE}: Skipping configure due"
927 " to running in unit testing mode!")
928
929 else()
930
931 #
932 # We always have to configure if we are going to do anything for the
933 # package. We just want submit configure results to CDash if we are not
934 # asked to configure!
935 #
936
937 set(PBP_CONFIGURE_PASSED FALSE)
938
939 ctest_configure(
940 BUILD "${CTEST_BINARY_DIRECTORY}"
941 OPTIONS "${CONFIGURE_OPTIONS}" # New option!
942 RETURN_VALUE CONFIGURE_RETURN_VAL
943 )
944
945 message("Generating the file '${CMAKE_CACHE_CLEAN_FILE}' ...")
946 tribits_strip_comments_from_cmake_cache_file(
947 "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt"
948 "${CMAKE_CACHE_CLEAN_FILE}"
949 )
950
951 # If the configure failed, add the package to the list
952 # of failed packages
953 if ("${CONFIGURE_RETURN_VAL}" EQUAL "0")
954 message("\n${TRIBITS_PACKAGE}: Configure passed!\n")
955 set(PBP_CONFIGURE_PASSED TRUE)
956 # load target properties and test keywords
957 ctest_read_custom_files(BUILD "${CTEST_BINARY_DIRECTORY}")
958 # Override from this file!
959 include("${TRIBITS_PROJECT_ROOT}/CTestConfig.cmake")
960 else()
961 message("\n${TRIBITS_PACKAGE} FAILED to configure!\n")
962 endif()
963
964 if (EXISTS ${CMAKE_CACHE_CLEAN_FILE})
965 set(CTEST_NOTES_FILES "${CTEST_NOTES_FILES_WO_CACHE};${CMAKE_CACHE_CLEAN_FILE}")
966 else()
967 set(CTEST_NOTES_FILES "${CTEST_NOTES_FILES_WO_CACHE}")
968 endif()
969
970 print_var(CTEST_NOTES_FILES)
971
972 if (NOT CTEST_DO_CONFIGURE AND CTEST_DO_SUBMIT)
973 message("${TRIBITS_PACKAGE}: Skipping submitting configure"
974 " and notes due to CTEST_DO_CONFIGURE='${CTEST_DO_CONFIGURE}'!")
975 elseif (CTEST_DO_SUBMIT)
976 message("\nSubmitting configure and notes ...")
977 tribits_ctest_submit( PARTS configure notes )
978 endif()
979
980 endif()
981
982 # Print out values read from project CTestCustom.cmake file!
983 print_var(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE)
984 print_var(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE)
985
986 #
987 # C) Build the library and then ALL
988 #
989
990 set(PBP_BUILD_PASSED TRUE)
991 set(PBP_BUILD_LIBS_PASSED TRUE)
992
993 print_var(PBP_CONFIGURE_PASSED)
994
995 if ( NOT PBP_CONFIGURE_PASSED AND CTEST_DO_BUILD )
996
997 message("\n${TRIBITS_PACKAGE}: Skipping build due"
998 " to configure failing!")
999
1000 set(PBP_BUILD_PASSED FALSE)
1001 set(PBP_BUILD_LIBS_PASSED FALSE)
1002
1003 elseif (NOT CTEST_DO_BUILD)
1004
1005 message("\n${TRIBITS_PACKAGE}: Skipping build due"
1006 " to CTEST_DO_BUILD='${CTEST_DO_BUILD}'!")
1007
1008 elseif (CTEST_DEPENDENCY_HANDLING_UNIT_TESTING OR
1009 CTEST_CONFIGURATION_UNIT_TESTING
1010 )
1011
1012 message("\n${TRIBITS_PACKAGE}: Skipping build due"
1013 " to running in unit testing mode!")
1014
1015 else()
1016
1017 # Start by trying to build just the libraries for the current package
1018
1019 set( CTEST_BUILD_TARGET ${TRIBITS_PACKAGE}_libs )
1020 message("\nBuilding target: '${CTEST_BUILD_TARGET}' ...\n")
1021 set(PBP_BUILD_LIBS_PASSED FALSE)
1022 ctest_build(
1023 BUILD "${CTEST_BINARY_DIRECTORY}"
1024 RETURN_VALUE BUILD_LIBS_RETURN_VAL
1025 NUMBER_ERRORS BUILD_LIBS_NUM_ERRORS
1026 APPEND
1027 )
1028 message("Build return: RETURN_VALUE=${BUILD_LIBS_RETURN_VAL},"
1029 " NUMBER_ERRORS=${BUILD_LIBS_NUM_ERRORS}")
1030
1031 # Determine if the build failed or not.
1032
1033 if ("${BUILD_LIBS_NUM_ERRORS}" EQUAL "0")
1034 message("\n${TRIBITS_PACKAGE}: Libs build passed!")
1035 set(PBP_BUILD_LIBS_PASSED TRUE)
1036 else()
1037 message("\nFAILED library build for package '${TRIBITS_PACKAGE}'!")
1038 set(PBP_BUILD_PASSED FALSE)
1039 endif()
1040 # Above: Since make -i is used BUILD_LIBS_RETURN_VAL might be 0, but
1041 # if there are errors the build should fail, so both
1042 # BUILD_LIBS_RETURN_VAL and BUILD_LIBS_NUM_ERRORS should be 0 for a
1043 # good build and for the all target to be built.
1044
1045 # Submit the library build results to the dashboard
1046 if (CTEST_DO_SUBMIT)
1047 tribits_ctest_submit( PARTS build )
1048 endif()
1049
1050 # If the build of the libraries passed, then go on the build
1051 # the tests/examples and run them.
1052
1053 if (PBP_BUILD_LIBS_PASSED)
1054
1055 # Build the ALL target, but append the results to the last build.xml
1056 set(CTEST_BUILD_TARGET)
1057 message("\nBuild ALL target for '${TRIBITS_PACKAGE}' ...\n")
1058 ctest_build(
1059 BUILD "${CTEST_BINARY_DIRECTORY}"
1060 RETURN_VALUE BUILD_ALL_RETURN_VAL
1061 NUMBER_ERRORS BUILD_ALL_NUM_ERRORS
1062 APPEND
1063 )
1064 message("Build all: BUILD_ALL_NUM_ERRORS='${BUILD_ALL_NUM_ERRORS}',"
1065 "BUILD_ALL_RETURN_VAL='${BUILD_ALL_RETURN_VAL}'" )
1066
1067 if (NOT "${BUILD_ALL_NUM_ERRORS}" EQUAL "0")
1068 message("${TRIBITS_PACKAGE}: All build FAILED!")
1069 set(PBP_BUILD_PASSED FALSE)
1070 else()
1071 message("${TRIBITS_PACKAGE}: All build passed!")
1072 endif()
1073
1074 # Submit the build for all target
1075 if (CTEST_DO_SUBMIT)
1076 tribits_ctest_submit( PARTS build )
1077 endif()
1078
1079 endif()
1080
1081 endif()
1082
1083 #
1084 # D) Run the tests
1085 #
1086
1087 set(PBP_TESTS_PASSED TRUE)
1088
1089 if (NOT PBP_BUILD_LIBS_PASSED AND CTEST_DO_TEST)
1090
1091 message("\n${TRIBITS_PACKAGE}: Skipping tests since library build failed!\n")
1092
1093 set(PBP_TESTS_PASSED FALSE)
1094
1095 elseif (NOT CTEST_DO_TEST)
1096
1097 message("\n${TRIBITS_PACKAGE}: Skipping running tests due"
1098 " to CTEST_DO_TEST='${CTEST_DO_TEST}'!")
1099
1100 else()
1101
1102 #
1103 # D.1) Run the regular tests
1104 #
1105
1106 set(PBP_TESTS_PASSED FALSE)
1107
1108 # Run the tests that match the ${TRIBITS_PACKAGE} name
1109 message("\nRunning test for package '${TRIBITS_PACKAGE}'"
1110 " (parallel level ${CTEST_PARALLEL_LEVEL}) ...\n")
1111 tribits_remove_last_test_failed_log_file()
1112 ctest_test(
1113 BUILD "${CTEST_BINARY_DIRECTORY}"
1114 PARALLEL_LEVEL "${CTEST_PARALLEL_LEVEL}"
1115 INCLUDE_LABEL "^${TRIBITS_PACKAGE}$"
1116 )
1117 # See if a 'LastTestsFailed*.log' file exists to determine if there are
1118 # failed tests
1119 tribits_find_last_test_failed_log_file()
1120 if (FAILED_TEST_LOG_FILE)
1121 message("\n${TRIBITS_PACKAGE}: File '${FAILED_TEST_LOG_FILE}'"
1122 " exists so there were failed tests!")
1123 else()
1124 message("\n${TRIBITS_PACKAGE}: File '${FAILED_TEST_LOG_FILE}'"
1125 " does NOT exist so all tests passed!")
1126 set(PBP_TESTS_PASSED TRUE)
1127 endif()
1128 # 2009/12/05: ToDo: We need to add an argument to ctest_test(...)
1129 # called something like 'NUMBER_FAILED numFailedTests' to allow us to
1130 # detect when the tests have filed.
1131 if (CTEST_DO_SUBMIT)
1132 tribits_ctest_submit( PARTS Test )
1133 endif()
1134
1135 #
1136 # D.2) Collect coverage results
1137 #
1138
1139 if (CTEST_DO_COVERAGE_TESTING)
1140
1141 message("\nRunning coverage for package '${TRIBITS_PACKAGE}' ...\n")
1142
1143 ctest_coverage(
1144 BUILD "${CTEST_BINARY_DIRECTORY}"
1145 LABELS ${TRIBITS_PACKAGE} ${TRIBITS_PACKAGE}Libs ${TRIBITS_PACKAGE}Exes
1146 )
1147
1148 if (CTEST_DO_SUBMIT)
1149 tribits_ctest_submit( PARTS Coverage )
1150 endif()
1151
1152 endif()
1153
1154 endif()
1155
1156 #
1157 # E) Run memory testing
1158 #
1159
1160 if (NOT PBP_BUILD_LIBS_PASSED AND CTEST_DO_MEMORY_TESTING)
1161
1162 message("\n${TRIBITS_PACKAGE}: Skipping running memory checking"
1163 "tests since library build failed!\n")
1164
1165 elseif (NOT CTEST_DO_MEMORY_TESTING)
1166
1167 message("\n${TRIBITS_PACKAGE}: Skipping running memory checking tests due"
1168 " to CTEST_DO_MEMORY_TESTING='${CTEST_DO_MEMORY_TESTING}'!")
1169
1170 else()
1171
1172 message("\nRunning memory testing for package '${TRIBITS_PACKAGE}' ...\n")
1173
1174 print_var(CTEST_MEMORYCHECK_COMMAND)
1175 print_var(CTEST_MEMORYCHECK_COMMAND_OPTIONS)
1176 print_var(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE)
1177
1178 ctest_memcheck(
1179 BUILD "${CTEST_BINARY_DIRECTORY}"
1180 PARALLEL_LEVEL "${CTEST_PARALLEL_LEVEL}"
1181 INCLUDE_LABEL "^${TRIBITS_PACKAGE}$"
1182 )
1183 # ToDo: Determine if memory testing passed or not and affect overall
1184 # pass/fail!
1185
1186 if (CTEST_DO_SUBMIT)
1187 tribits_ctest_submit( PARTS MemCheck )
1188 endif()
1189
1190 endif()
1191
1192 #
1193 # F) Record if this package failed the build or any tests
1194 #
1195
1196 if (NOT PBP_CONFIGURE_PASSED OR NOT PBP_BUILD_LIBS_PASSED)
1197 list(APPEND ${PROJECT_NAME}_FAILED_LIB_BUILD_PACKAGES ${TRIBITS_PACKAGE})
1198 endif()
1199
1200 if (NOT PBP_BUILD_PASSED OR NOT PBP_TESTS_PASSED)
1201 list(APPEND ${PROJECT_NAME}_FAILED_PACKAGES ${TRIBITS_PACKAGE})
1202 endif()
1203
1204 #
1205 # G) Do submit of update
1206 #
1207
1208 if (CTEST_DO_SUBMIT)
1209 message("\nSubmit the update file that will trigger the notification email ...\n")
1210 tribits_ctest_submit( PARTS update )
1211 endif()
1212
1213 math(EXPR PACKAGE_IDX "${PACKAGE_IDX}+1")
1214
1215 endforeach(TRIBITS_PACKAGE)
1216
1217 if (${PROJECT_NAME}_FAILED_LIB_BUILD_PACKAGES)
1218 message(
1219 "\nFinal set packages that failed to configure or have the libraries build:"
1220 " '${${PROJECT_NAME}_FAILED_LIB_BUILD_PACKAGES}'")
1221 endif()
1222
1223 message("\nDone with the incremental building and testing of"
1224 " ${PROJECT_NAME} packages!\n")
1225
1226 endmacro()
1227 # NOTE: Above, the option
1228 # ${PROJECT_NAME}_DEFINE_MISSING_PACKAGE_LIBS_TARGETS=ON is passed down
1229 # through to the inner CMake TriBITS configure to trigger the creation of
1230 # dummy targets <PackageName>_libs for all the packages for the case where a
1231 # package is disabled due to a disabled upstream package and
1232 # ${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON but the target
1233 # <thePackage>_libs is attempted to be built anyway and we expect it to build
1234 # nothing and result in no error. (The outer ctest -S driver is not smart
1235 # enough to know all the lgoic for if a package will actually be enabled or
1236 # not. That is the job of the inner TriBITS dependency logic and
1237 # ${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON.) Otherwise, with
1238 # CMake 3.19+, cmake_build() catches errors in undefined global build targets
1239 # like this and reports them correctly. This workaround allows the
1240 # package-by-package mode to gracefully disable downstream packages that can't
1241 # be enabled due to the disable of a broken upstream packages. See the test
1242 # TriBITS_CTestDriver_PBP_ST_BreakConfigureRequiredPkg that exercises this use
1243 # case.
1244
1245
1246 # Drive the configure, build, test, and submit all at once for all of the
1247 # enabled packages.
1248 #
1249 # Sets ${PROJECT_NAME}_FAILED_PACKAGES as an indication if there are any
1250 # failures.
1251 #
1252 macro(tribits_ctest_all_at_once)
1253
1254 message(
1255 "\n***"
1256 "\n*** Configure, build, test and submit results all-at-once for all enabled packages ..."
1257 "\n***")
1258
1259 set(AAO_CONFIGURE_FAILED FALSE)
1260 set(AAO_BUILD_FAILED FALSE)
1261 set(AAO_INSTALL_FAILED FALSE)
1262
1263 #
1264 # A) Define mapping from labels to subprojects and gather configure arguments
1265 #
1266
1267 tribits_ctest_driver_set_labels_to_subprojects_mapping()
1268 print_var(CTEST_LABELS_FOR_SUBPROJECTS)
1269
1270 message("")
1271 message("Configuring ...")
1272 message("")
1273
1274 # Create CONFIGURE_OPTIONS
1275 tribits_fwd_cmake_config_args_0()
1276 if (NOT "${${PROJECT_NAME}_PACKAGE_ENABLES_FILE}" STREQUAL "")
1277 # NOTE: For now, the user is expected to pass through this file in the
1278 # inner CMake cache var ${PROJECT_NAME}_CONFIGURE_OPTIONS_FILE! We should
1279 # fix this in the future but that is what it is for now.
1280 elseif (${PROJECT_NAME}_ENABLE_ALL_PACKAGES)
1281 list(APPEND CONFIGURE_OPTIONS
1282 "-D${PROJECT_NAME}_ENABLE_ALL_PACKAGES=ON" )
1283 foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_EXCLUDE_PACKAGES})
1284 list(APPEND CONFIGURE_OPTIONS
1285 "-D${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}=OFF" )
1286 endforeach()
1287 # NOTE: Above we have to explicitly set disables for the excluded packages
1288 # since we are pssing in ${PROJECT_NAME}_ENABLE_ALL_PACKAGES=ON. This is
1289 # effectively the "black-listing" approach.
1290 else()
1291 foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES_TO_DIRECTLY_TEST})
1292 list(APPEND CONFIGURE_OPTIONS
1293 "-D${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}=ON" )
1294 endforeach()
1295 # NOTE: Above we don't have to consider the packages excluded in
1296 # ${PROJECT_NAME}_EXCLUDE_PACKAGES because they are not enabled ad this
1297 # point and therefore no in ${PROJECT_NAME}_PACKAGES_TO_DIRECTLY_TEST.
1298 # This is effectively the "white-listing" approach.
1299 endif()
1300 list(APPEND CONFIGURE_OPTIONS
1301 "-D${PROJECT_NAME}_ENABLE_TESTS:BOOL=${${PROJECT_NAME}_INNER_ENABLE_TESTS}")
1302 tribits_fwd_cmake_config_args_1()
1303 message("\nCONFIGURE_OPTIONS = '${CONFIGURE_OPTIONS}'")
1304
1305 #
1306 # B) Configure the package and its dependent packages
1307 #
1308
1309 tribits_previous_configure_attempted_but_not_passsed(
1310 PREVIOUS_CONFIGURE_ATTEMPTED_BUT_NOT_PASSSED)
1311 #print_var(PREVIOUS_CONFIGURE_ATTEMPTED_BUT_NOT_PASSSED)
1312
1313 if ((NOT CTEST_DO_CONFIGURE) AND PREVIOUS_CONFIGURE_ATTEMPTED_BUT_NOT_PASSSED)
1314
1315 message(
1316 "\nSkipping configure due to CTEST_DO_CONFIGURE='${CTEST_DO_CONFIGURE}'!\n"
1317 "\nHOWEVER: A configure was previously attempted but did not pass so consider configure FAILED!")
1318 set(AAO_CONFIGURE_PASSED FALSE)
1319 set(AAO_CONFIGURE_FAILED TRUE)
1320
1321 elseif (NOT CTEST_DO_CONFIGURE)
1322
1323 message("\nSkipping configure due to CTEST_DO_CONFIGURE='${CTEST_DO_CONFIGURE}'!\n")
1324 set(AAO_CONFIGURE_PASSED TRUE)
1325 # Just assume configure passeed for the purpose of running the build.
1326
1327 elseif (CTEST_DEPENDENCY_HANDLING_UNIT_TESTING)
1328
1329 message("Skipping actual ctest_configure() because"
1330 " CTEST_DEPENDENCY_HANDLING_UNIT_TESTING='${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING}'!"
1331 )
1332 set(AAO_CONFIGURE_PASSED TRUE)
1333
1334 else()
1335
1336 ctest_configure(
1337 BUILD "${CTEST_BINARY_DIRECTORY}"
1338 OPTIONS "${CONFIGURE_OPTIONS}" # New option!
1339 RETURN_VALUE CONFIGURE_RETURN_VAL
1340 )
1341
1342 message("Generating the file '${CMAKE_CACHE_CLEAN_FILE}' ...")
1343 tribits_strip_comments_from_cmake_cache_file(
1344 "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt"
1345 "${CMAKE_CACHE_CLEAN_FILE}"
1346 )
1347
1348 if (NOT "${CONFIGURE_RETURN_VAL}" EQUAL "0")
1349 message("Configure FAILED!")
1350 set(AAO_CONFIGURE_PASSED FALSE)
1351 set(AAO_CONFIGURE_FAILED TRUE)
1352 else()
1353 message("Configure PASSED!")
1354 set(AAO_CONFIGURE_PASSED TRUE)
1355 endif()
1356
1357 if (AAO_CONFIGURE_PASSED)
1358 tribits_remember_configure_passed()
1359 endif()
1360
1361 set(CTEST_NOTES_FILES "${CTEST_NOTES_FILES_WO_CACHE}")
1362
1363 if (EXISTS ${CMAKE_CACHE_CLEAN_FILE})
1364 list(APPEND CTEST_NOTES_FILES "${CMAKE_CACHE_CLEAN_FILE}")
1365 endif()
1366
1367 if (EXISTS "${REPO_VERSION_FILE}")
1368 set(CTEST_NOTES_FILES "${REPO_VERSION_FILE};${CTEST_NOTES_FILES}")
1369 endif()
1370
1371 print_var(CTEST_NOTES_FILES)
1372
1373 # Submit configure results and the notes to the dashboard
1374 if (CTEST_DO_SUBMIT)
1375 message("\nSubmitting update, configure and notes ...")
1376 tribits_ctest_submit( PARTS update configure notes )
1377 endif()
1378
1379 endif()
1380
1381 # Read in configured CTestCustom.cmake
1382 ctest_read_custom_files(BUILD "${CTEST_BINARY_DIRECTORY}")
1383 # NOTE: Above, it is safe to call ctest_read_custom_files() even if the
1384 # configure failed and the file CTestCustom.cmake does exist. In this case,
1385 # CTest will just do nothing.
1386
1387 # Override any values by loading <projectDir>/CTestConfig.cmake
1388 include("${TRIBITS_PROJECT_ROOT}/CTestConfig.cmake")
1389
1390 # Print out values read from project CTestCustom.cmake file
1391 print_var(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE)
1392 print_var(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE)
1393
1394 #
1395 # C) Do the build
1396 #
1397
1398 if (NOT CTEST_DO_BUILD)
1399
1400 message("\nSkipping build due to CTEST_DO_BUILD='${CTEST_DO_BUILD}'!\n")
1401
1402 elseif (CTEST_DEPENDENCY_HANDLING_UNIT_TESTING AND AAO_CONFIGURE_PASSED)
1403
1404 message("Skipping build because"
1405 " CTEST_DEPENDENCY_HANDLING_UNIT_TESTING='${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING}'!"
1406 )
1407
1408 elseif (AAO_CONFIGURE_PASSED)
1409
1410 message("")
1411 message("Building all targets ...")
1412 message("")
1413
1414 ctest_build(
1415 BUILD "${CTEST_BINARY_DIRECTORY}"
1416 RETURN_VALUE BUILD_ALL_RETURN_VAL
1417 NUMBER_ERRORS BUILD_ALL_NUM_ERRORS
1418 )
1419 message("Build output: BUILD_ALL_NUM_ERRORS='${BUILD_ALL_NUM_ERRORS}',"
1420 "BUILD_ALL_RETURN_VAL='${BUILD_ALL_RETURN_VAL}'" )
1421
1422 if (NOT "${BUILD_ALL_NUM_ERRORS}" EQUAL "0")
1423 message("Build FAILED!")
1424 set(AAO_BUILD_FAILED TRUE)
1425 else()
1426 message("Build PASSED!")
1427 endif()
1428
1429 # Submit the build for all target
1430 if (CTEST_DO_SUBMIT)
1431 tribits_ctest_submit( PARTS build )
1432 endif()
1433
1434 if (CTEST_DO_INSTALL)
1435
1436 message("")
1437 message("Installing (i.e. building target 'install_package_by_package') ...")
1438 message("")
1439
1440 ctest_build(
1441 BUILD "${CTEST_BINARY_DIRECTORY}"
1442 TARGET install_package_by_package
1443 RETURN_VALUE BUILD_INSTALL_RETURN_VAL
1444 NUMBER_ERRORS BUILD_INSTALL_NUM_ERRORS
1445 )
1446 message("Build install output:"
1447 " BUILD_INSTALL_NUM_ERRORS='${BUILD_INSTALL_NUM_ERRORS}',"
1448 "BUILD_INSTALL_RETURN_VAL='${BUILD_INSTALL_RETURN_VAL}'" )
1449
1450 if (NOT "${BUILD_INSTALL_NUM_ERRORS}" EQUAL "0")
1451 message("Install FAILED!")
1452 set(AAO_INSTALL_FAILED TRUE)
1453 else()
1454 message("Install PASSED!")
1455 endif()
1456
1457 # Submit the build for all target
1458 if (CTEST_DO_SUBMIT)
1459 tribits_ctest_submit( PARTS build )
1460 endif()
1461
1462 endif()
1463
1464 else()
1465
1466 message("")
1467 message("Skipping build because configure failed!")
1468 message("")
1469
1470 endif()
1471
1472 #
1473 # D) Run tests
1474 #
1475
1476 if (NOT CTEST_DO_TEST)
1477
1478 message("")
1479 message("Skipping tests because CTEST_DO_TEST='${CTEST_DO_TEST}'!")
1480 message("")
1481
1482 elseif (NOT AAO_CONFIGURE_PASSED)
1483
1484 message("")
1485 message("Skipping tests because configure failed!")
1486 message("")
1487
1488 elseif (CTEST_DEPENDENCY_HANDLING_UNIT_TESTING AND AAO_CONFIGURE_PASSED)
1489
1490 message("Skipping testing because"
1491 " CTEST_DEPENDENCY_HANDLING_UNIT_TESTING='${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING}'!"
1492 )
1493
1494 else()
1495
1496 # NOTE: We always run the tests if the configure passed no matter if there
1497 # are build failures because the only way that we can detect what packages
1498 # have build failures is to see what packages have test failures.
1499
1500 tribits_remove_last_test_failed_log_file()
1501
1502 # Run the tests
1503 message("")
1504 message("\nRunning tests (parallel level ${CTEST_PARALLEL_LEVEL}) ...\n")
1505 message("")
1506
1507 ctest_test(
1508 BUILD "${CTEST_BINARY_DIRECTORY}"
1509 PARALLEL_LEVEL "${CTEST_PARALLEL_LEVEL}"
1510 )
1511
1512 # See if a 'LastTestsFailed*.log' file exists to determine if there are
1513 # failed tests.
1514 tribits_find_last_test_failed_log_file()
1515 if (FAILED_TEST_LOG_FILE)
1516 message("File '${FAILED_TEST_LOG_FILE}' exists so there were non-passing tests!")
1517 else()
1518 message("File '${FAILED_TEST_LOG_FILE}' does NOT exist so all tests passed!")
1519 endif()
1520
1521 if (CTEST_DO_SUBMIT)
1522 tribits_ctest_submit( PARTS Test )
1523 endif()
1524
1525 endif()
1526
1527 #
1528 # E) Gather coverage results
1529 #
1530
1531 if (NOT CTEST_DO_COVERAGE_TESTING)
1532
1533 message("")
1534 message("Skipping coverage tests because CTEST_DO_COVERAGE_TESTING='${CTEST_DO_COVERAGE_TESTING}'!")
1535 message("")
1536
1537 elseif (NOT AAO_CONFIGURE_PASSED)
1538
1539 message("")
1540 message("Skipping coverage tests because configure failed!")
1541 message("")
1542
1543 elseif (CTEST_DEPENDENCY_HANDLING_UNIT_TESTING AND AAO_CONFIGURE_PASSED)
1544
1545 message("Skipping coverage testing because"
1546 " CTEST_DEPENDENCY_HANDLING_UNIT_TESTING='${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING}'!"
1547 )
1548
1549 else()
1550
1551 # NOTE: We always gather the coverage results if the configure passed
1552 # independent if there was any build or test failures. The coverage stats
1553 # may not be very valid if there are build or test failures but there is
1554 # no harm and showing the coverage based on tests that actually run (even
1555 # if they fail).
1556
1557 message("\nGathering coverage results ...\n")
1558 ctest_coverage(
1559 BUILD "${CTEST_BINARY_DIRECTORY}"
1560 )
1561 if (CTEST_DO_SUBMIT)
1562 tribits_ctest_submit( PARTS Coverage )
1563 endif()
1564
1565 endif()
1566
1567 #
1568 # F) Do memory testing
1569 #
1570
1571 if (NOT CTEST_DO_MEMORY_TESTING)
1572
1573 message("")
1574 message("Skipping memory testing because CTEST_DO_MEMORY_TESTING='${CTEST_DO_MEMORY_TESTING}'!")
1575 message("")
1576
1577 elseif (NOT AAO_CONFIGURE_PASSED)
1578
1579 message("")
1580 message("Skipping memory tests because configure failed!")
1581 message("")
1582
1583 elseif (CTEST_DEPENDENCY_HANDLING_UNIT_TESTING AND AAO_CONFIGURE_PASSED)
1584
1585 message("Skipping memory testing because"
1586 " CTEST_DEPENDENCY_HANDLING_UNIT_TESTING='${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING}'!"
1587 )
1588
1589 else()
1590
1591 # NOTE: We always gather the memory results if the configure passed
1592 # independent if there was any build or test failures. The memory stats
1593 # may not be very valid if there are build or test failures but there is
1594 # no harm and showing the memory based on tests that actually run (even
1595 # if they fail).
1596
1597 message("\nRunning memory tests ...\n")
1598 print_var(CTEST_MEMORYCHECK_COMMAND)
1599 print_var(CTEST_MEMORYCHECK_COMMAND_OPTIONS)
1600 print_var(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE)
1601 ctest_memcheck(
1602 BUILD "${CTEST_BINARY_DIRECTORY}"
1603 )
1604 if (CTEST_DO_SUBMIT)
1605 tribits_ctest_submit( PARTS MemCheck )
1606 endif()
1607
1608 endif()
1609
1610 #
1611 # G) Determine final pass/fail by gathering list of failing packages
1612 #
1613
1614 if (AAO_CONFIGURE_FAILED OR AAO_BUILD_FAILED OR AAO_INSTALL_FAILED)
1615 if (${PROJECT_NAME}_ENABLE_ALL_PACKAGES)
1616 # Special value "ALL_PACKAGES" so that it will trigger enabling all
1617 # packages on the next CI iteration!
1618 set(${PROJECT_NAME}_FAILED_PACKAGES ALL_PACKAGES)
1619 else()
1620 # Specific packages were selected to be tested so fail all of them!
1621 set(${PROJECT_NAME}_FAILED_PACKAGES ${${PROJECT_NAME}_PACKAGES_TO_DIRECTLY_TEST})
1622 endif()
1623 # NOTE: With the all-at-once approach, there is no way to determine which
1624 # packages have build or install failures given the current ctest_build()
1625 # command. And since some build targets don't get used in tests, we can't
1626 # look at what packages have test failures in order to know that a build
1627 # failure will cause a test failure. And in the case of install failures,
1628 # those will never cause test failures. Therefore, if there are any build
1629 # or install failures, we just have to assume that any tested package
1630 # could have failed. Hence, we set the above just like for a (global)
1631 # configure failures. Perhaps we could read the generated *.xml files to
1632 # figure that out but that is not worth the work right now. The only bad
1633 # consequence of this is that a CI build would end up building and testing
1634 # every package even if only one downstream package had a build failure,
1635 # for example. That is just one of the downsides of the all-at-once
1636 # approach vs. the package-by-package approach.
1637 elseif (FAILED_TEST_LOG_FILE)
1638 tribits_get_failed_packages_from_failed_tests("${FAILED_TEST_LOG_FILE}"
1639 ${PROJECT_NAME}_FAILED_PACKAGES )
1640 else()
1641 # If no tests failed, then there are no failed packages!
1642 set(${PROJECT_NAME}_FAILED_PACKAGES)
1643 endif()
1644 # ToDo: Optionally determine pass/fail based
1645
1646 message("\nDone with the all-at-once configure, build, test, and submit of ${PROJECT_NAME} packages!\n")
1647
1648 endmacro()