Skip to content

Commit

Permalink
Update tribits_read_ctest_tag_file() to also read model (TriBITSPub#154)
Browse files Browse the repository at this point in the history
Version of CMake 3.17 (and likely earlier) added the model in addition to
group to the TAG file.
  • Loading branch information
bartlettroscoe committed Jul 28, 2021
1 parent 204a609 commit 1a9efd1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/ctest_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tribits_add_advanced_test( CTestDriverUnitTests
-D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-P "${CMAKE_CURRENT_SOURCE_DIR}/CTestDriverUnitTests.cmake"
PASS_REGULAR_EXPRESSION_ALL
"Final UnitTests Result: num_run = 2"
"Final UnitTests Result: num_run = 3"
"Final UnitTests Result: PASSED"
)

Expand Down
14 changes: 8 additions & 6 deletions test/ctest_driver/CTestDriverUnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ function(unittest_read_ctest_tag_file)

set(TAG_FILE_IN "${CMAKE_CURRENT_LIST_DIR}/data/dummy_build_dir/Testing/TAG")

tribits_read_ctest_tag_file(${TAG_FILE_IN} BUILD_START_TIME_OUT CDASH_TRACK_OUT)
tribits_read_ctest_tag_file(${TAG_FILE_IN} buildStartTime cdashGroup cdashModel)

unittest_compare_const(BUILD_START_TIME_OUT
unittest_compare_const(buildStartTime
"20101015-1112")

unittest_compare_const(CDASH_TRACK_OUT
"My CDash Track") # NOTE: Spaces are important to test here!
unittest_compare_const(cdashGroup
"My CDash Group") # NOTE: Spaces are important to test here!
unittest_compare_const(cdashModel
"The Model") # NOTE: Spaces are important to test here!

endfunction()


#
# Execute the unit tests
#
Expand All @@ -86,4 +88,4 @@ message("*** Determine final result of all unit tests")
message("***\n")

# Pass in the number of expected tests that must pass!
unittest_final_result(2)
unittest_final_result(3)
3 changes: 2 additions & 1 deletion test/ctest_driver/data/dummy_build_dir/Testing/TAG
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
20101015-1112
My CDash Track
My CDash Group
The Model
4 changes: 2 additions & 2 deletions tribits/ctest_driver/TribitsGetCTestTestXmlDir.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ include(TribitsReadTagFile)

set(TAG_FILE "${CTEST_BUILD_DIR}/Testing/TAG")

tribits_read_ctest_tag_file("${TAG_FILE}" BUILD_START_TIME CDASH_TRACK)
tribits_read_ctest_tag_file("${TAG_FILE}" buildStartTime cdashGroup cdashModel)

message("${CTEST_BUILD_DIR}/Testing/${BUILD_START_TIME}")
message("${CTEST_BUILD_DIR}/Testing/${buildStartTime}")
24 changes: 17 additions & 7 deletions tribits/ctest_driver/TribitsReadTagFile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ include(TribitsCMakePolicies)
include(Split)


# @FUNCTION: tribits_read_ctest_tag_file()
#
# Read in the <build>/Testing/TAG file contents
#
# Usage::
#
function(tribits_read_ctest_tag_file TAG_FILE_IN BUILD_START_TIME_OUT CDASH_TRACK_OUT)
file(READ "${TAG_FILE_IN}" TAG_FILE_STR)
split("${TAG_FILE_STR}" "\n" TAG_FILE_STR_LIST)
list(GET TAG_FILE_STR_LIST 0 BUILD_START_TIME)
list(GET TAG_FILE_STR_LIST 1 CDASH_TRACK)
set(${BUILD_START_TIME_OUT} "${BUILD_START_TIME}" PARENT_SCOPE)
set(${CDASH_TRACK_OUT} "${CDASH_TRACK}" PARENT_SCOPE)
# tribits_read_ctest_tag_file( <tagFileIn>
# <buildStartTimeOut> <cdashGroupOut> <cdashModel> )
#
#
function(tribits_read_ctest_tag_file tagFileIn
buildStartTimeOut cdashGroupOut cdashModelOut
)
file(READ "${tagFileIn}" tagFileStr)
split("${tagFileStr}" "\n" tagFileStrList)
list(GET tagFileStrList 0 buildStartTime)
list(GET tagFileStrList 1 cdashGroup)
list(GET tagFileStrList 2 cdashModel)
set(${buildStartTimeOut} "${buildStartTime}" PARENT_SCOPE)
set(${cdashGroupOut} "${cdashGroup}" PARENT_SCOPE)
set(${cdashModelOut} "${cdashModel}" PARENT_SCOPE)
endfunction()

0 comments on commit 1a9efd1

Please sign in to comment.