Skip to content

Commit

Permalink
WIP: Caputure output from tribits_ctest_update_commands.cmake (TriBIT…
Browse files Browse the repository at this point in the history
…SPub#278)

I also added this to the notes files and refactored that a little to clean
them up.
  • Loading branch information
bartlettroscoe committed Feb 15, 2019
1 parent 73479ce commit 808827f
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 14 deletions.
65 changes: 55 additions & 10 deletions tribits/ctest_driver/TribitsCTestDriverCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,20 @@ INCLUDE(${CMAKE_CURRENT_LIST_DIR}/TribitsCTestDriverCoreHelpers.cmake)
# ``BUILD_DIR_NAME`` is expected to be set in each specific CTest -S
# driver script.
#
# .. _CTEST_NOTES_FILES:
#
# ``CTEST_NOTES_FILES``
#
# Built-in CTest variable that specifies a set of files that will get
# uploaded to CDash as "notes files". This function will also add other
# files as well such as the ``CMakeCache.clean.txt`` file (cleaned-up
# version of the CMakeCache.txt file), the ``Updates.txt`` file (lists new
# git commits pulled in all the git repos since), the
# ``UpdateCommandsOutput.txt`` file (list of commands and their output
# which are run by the ``ctest_update()`` in the base git repo), and the
# ``${PROJECT_NAME}RepoVersion.txt`` file (gives version of all the git
# repos being tested).
#
# .. _Specifying where the results go to CDash (TRIBITS_CTEST_DRIVER()):
#
# **Specifying where the results go to CDash (TRIBITS_CTEST_DRIVER()):**
Expand Down Expand Up @@ -1751,6 +1765,9 @@ FUNCTION(TRIBITS_CTEST_DRIVER)

SET(CREATE_VC_UPDATE_FILE FALSE)

SET(CTEST_UPDATE_COMMANDS_OUTPUT_FILE
"${CTEST_BINARY_DIRECTORY}/UpdateCommandsOutput.txt")

IF (CTEST_DO_UPDATES)

SET(UPDATE_TYPE "git")
Expand Down Expand Up @@ -1796,11 +1813,13 @@ FUNCTION(TRIBITS_CTEST_DRIVER)
# Provide a custom command to do the update

SET(CTEST_GIT_UPDATE_CUSTOM
"${CMAKE_COMMAND}" -DGIT_EXE=${GIT_EXE}
-DREMOTE_NAME=${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}
-DBRANCH=${${PROJECT_NAME}_BRANCH}
-DUNIT_TEST_MODE=${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING}
-P ${THIS_CMAKE_CURRENT_LIST_DIR}/tribits_ctest_update_commands.cmake
"${CMAKE_COMMAND}"
-DGIT_EXE=${GIT_EXE}
-DREMOTE_NAME=${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}
-DBRANCH=${${PROJECT_NAME}_BRANCH}
-DUNIT_TEST_MODE=${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING}
-DOUTPUT_FILE=${CTEST_UPDATE_COMMANDS_OUTPUT_FILE}
-P ${THIS_CMAKE_CURRENT_LIST_DIR}/tribits_ctest_update_commands_wrapper.cmake
)
MESSAGE("CTEST_GIT_UPDATE_CUSTOM=${CTEST_GIT_UPDATE_CUSTOM}")

Expand Down Expand Up @@ -1929,6 +1948,14 @@ FUNCTION(TRIBITS_CTEST_DRIVER)
RETURN_VALUE CTEST_UPDATE_RETURN_VAL)
MESSAGE("CTEST_UPDATE(...) returned '${CTEST_UPDATE_RETURN_VAL}' [ rtn >= 0: num files; rnt == -1: error ]")

# Print the output from the git commands called in ctest_update()
IF (EXISTS "${CTEST_UPDATE_COMMANDS_OUTPUT_FILE}")
FILE(READ "${CTEST_UPDATE_COMMANDS_OUTPUT_FILE}" CTEST_UPDATE_COMMANDS_OUTPUT_STR)
MESSAGE("\n------------------------------------------------------------------------")
MESSAGE("${CTEST_UPDATE_COMMANDS_OUTPUT_STR}")
MESSAGE("------------------------------------------------------------------------\n")
ENDIF()

TRIBITS_CLONE_OR_UPDATE_EXTRA_REPOS(${CTEST_UPDATE_RETURN_VAL} LOC_UPDATE_FAILED)
IF (LOC_UPDATE_FAILED)
SET(UPDATE_FAILED TRUE)
Expand Down Expand Up @@ -2066,12 +2093,30 @@ FUNCTION(TRIBITS_CTEST_DRIVER)
"\n***\n"
)

IF (EXISTS ${CTEST_BINARY_DIRECTORY}/Updates.txt)
SET(CTEST_NOTES_FILES_WO_CACHE
"${CTEST_BINARY_DIRECTORY}/Updates.txt;${CTEST_NOTES_FILES}")
ELSE()
SET(CTEST_NOTES_FILES_WO_CACHE "${CTEST_NOTES_FILES}")
# Set up a list of notes files that don't include the CMakeCache.clean.txt
# file which will change for every submit in the package-by-package modee.

SET(CTEST_NOTES_FILES_WO_CACHE)

SET(REPO_VERSION_FILE "${CTEST_BINARY_DIRECTORY}/${PROJECT_NAME}RepoVersion.txt")
IF (EXISTS "${REPO_VERSION_FILE}")
LIST(APPEND CTEST_NOTES_FILES_WO_CACHE "${REPO_VERSION_FILE}")
ENDIF()

SET(MULTIREPO_GIT_UPDATES_FILE "${CTEST_BINARY_DIRECTORY}/Updates.txt" )
IF (EXISTS "${MULTIREPO_GIT_UPDATES_FILE}")
LIST(APPEND CTEST_NOTES_FILES_WO_CACHE "${MULTIREPO_GIT_UPDATES_FILE}")
ENDIF()

IF (EXISTS "${CTEST_UPDATE_COMMANDS_OUTPUT_FILE}")
LIST(APPEND CTEST_NOTES_FILES_WO_CACHE "${CTEST_UPDATE_COMMANDS_OUTPUT_FILE}" )
ENDIF()

# Tack on any notes files that the client might have set to the end of these
IF ("${CTEST_NOTES_FILES}")
LIST(APPEND CTEST_NOTES_FILES_WO_CACHE "${CTEST_NOTES_FILES}")
ENDIF()

PRINT_VAR(CTEST_NOTES_FILES_WO_CACHE)

# Note: We must only do the submit after we have decided if there are any
Expand Down
27 changes: 23 additions & 4 deletions tribits/ctest_driver/tribits_ctest_update_commands.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
#
# ctest -P script to do and update of the base git repo.
# cmake -P script to do and update of the base git repo.
#
# ToDo: Finish documentation
# Usage:
#
# cmake [arguments] -P tribits_ctest_update_commands.cmake
#
# where the -D<var>=<value> arguments are shown below.
#
# The list of commands in this script completely clean out a git repo and
# create a local branch with name ${BRANCH} tracking a remote branch ${BRANCH}
# in the remote repo ${REMOTE_NAME}. This is robust no matter what the
# current state of the local git repo. The built-in git commands used by
# ctest_update() are not robust to some use cases where these commands are.
# For example, the commands are robust to the situation where the local repo
# may be tracking a remote branch that may have been deleted in the remote
# repo. The default commands used in ctest_update() (at least as of CMake
# 3.12) crash in that case.
#

message("cmake -P tribits_ctest_update_commands.cmake:")
message("\ncmake -P tribits_ctest_update_commands.cmake:")
message("-- GIT_EXE=${GIT_EXE}")
message("-- REMOTE_NAME=${REMOTE_NAME}")
message("-- BRANCH=${BRANCH}")
Expand All @@ -17,7 +31,7 @@ macro(execute_process_wrapper)
message("\nRunning: execute_process(${ARGN})")
if (NOT UNIT_TEST_MODE)
execute_process(${ARGN} RESULT_VARIABLE RTN_CODE)
message("RESULT_VARIABLE=${RTN_CODE}")
message("RTN_CODE: ${RTN_CODE}")
IF (NOT "${RTN_CODE}" STREQUAL "0")
set(OVERALL_SUCCESS FALSE)
set(ERROR_CODE ${RTN_CODE})
Expand Down Expand Up @@ -47,3 +61,8 @@ if (OVERALL_SUCCESS)
else()
message(FATAL_ERROR "Git Update FAILED!")
endif()

# NOTE: Above, you have to use separate execute_process() commands for each
# git command or you get git errors complaining about git commands running on
# top of each other. The execute_process() implementation must not ensure
# that one command is completely finished before the next one starts.
28 changes: 28 additions & 0 deletions tribits/ctest_driver/tribits_ctest_update_commands_wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# cmake -P script that calls tribits_ctest_update_commands.cmake and sends
# STDOUT to a file.
#
# This script is required if you want to capture the output from these
# commands to a file since this is called from ctest_update() which discards
# the output (and does not send it to CDash).
#

message("\ncmake -P tribits_ctest_update_commands_wrapper.cmake:")
message("-- OUTPUT_FILE=${OUTPUT_FILE}\n")

execute_process(
COMMAND "${CMAKE_COMMAND}"
-DGIT_EXE=${GIT_EXE}
-DREMOTE_NAME=${REMOTE_NAME}
-DBRANCH=${BRANCH}
-DUNIT_TEST_MODE=${UNIT_TEST_MODE}
-P ${CMAKE_CURRENT_LIST_DIR}/tribits_ctest_update_commands.cmake
OUTPUT_FILE "${OUTPUT_FILE}"
ERROR_FILE "${OUTPUT_FILE}"
RESULT_VARIABLE RTN_CODE
)
message("\ntribits_ctest_update_commands_wrapper.cmake return: ${RTN_CODE}\n")

if (NOT "${RTN_CODE}" STREQUAL "0")
message(FATAL_ERROR "Git Update FAILED!")
endif()

0 comments on commit 808827f

Please sign in to comment.