Skip to content

Commit

Permalink
Implement tribits_get_cdash_build_url_from_parts() (TriBITSPub#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlettroscoe committed Aug 10, 2021
1 parent 0ce719a commit 79a5064
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 3 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 = 3"
"Final UnitTests Result: num_run = 4"
"Final UnitTests Result: PASSED"
)

Expand Down
28 changes: 26 additions & 2 deletions test/ctest_driver/CTestDriverUnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ set( CMAKE_MODULE_PATH
)

include(GlobalSet)
include(TribitsReadTagFile)
include(UnitTestHelpers)

include(TribitsReadTagFile)
include(TribitsGetCDashUrlFromTagFile)


function(unittest_tribits_read_ctest_tag_file)

Expand All @@ -71,6 +73,27 @@ function(unittest_tribits_read_ctest_tag_file)
endfunction()


function(unittest_tribits_get_cdash_build_url_from_parts)

message("\n***")
message("*** Testing tribits_get_cdash_build_url_from_parts()")
message("***\n")

tribits_get_cdash_build_url_from_parts(
INDEX_PHP_URL "mycdash/index.php"
PROJECT_NAME "my project"
SITE_NAME "my site"
BUILD_NAME "my buildname g++-2.5"
BUILD_STAMP "20210729-0024-My Group"
CDASH_BUILD_URL_OUT cdashBuildUrlOut
)

unittest_compare_const(cdashBuildUrlOut
"mycdash/index.php?project=my%20project&filtercount=3&showfilters=1&filtercombine=and&field1=site&compare1=61&value1=my%20site&field2=buildname&compare2=61&value2=my%20buildname%20g%2B%2B-2.5&field3=buildstamp&compare3=61&value3=20210729-0024-My%20Group")

endfunction()


#
# Execute the unit tests
#
Expand All @@ -82,10 +105,11 @@ global_set(UNITTEST_OVERALL_NUMRUN 0)

# Run the unit test functions
unittest_tribits_read_ctest_tag_file()
unittest_tribits_get_cdash_build_url_from_parts()

message("\n***")
message("*** Determine final result of all unit tests")
message("***\n")

# Pass in the number of expected tests that must pass!
unittest_final_result(3)
unittest_final_result(4)
76 changes: 76 additions & 0 deletions tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
include(TribitsReadTagFile)


# @FUNCTION: tribits_get_cdash_build_url_from_tag_file()
#
# Create CDash index.php URL from the build parts.
#
# Usage::
#
# tribits_get_cdash_build_url_from_tag_file(
# INDEX_PHP_URL <indexPhpUrl>
# PROJECT_NAME <projectName>
# SITE_NAME <siteName>
# BUILD_NAME <buildName>
# TAG_FILE <tagFile>
# CDASH_BUILD_URL_OUT <cdashBuildUrlOut>
# )
#
# Note that spaces are allowed ``<siteName>`` or ``<buildName>`` and those
# will be handled correctly to produce a valid URL.
#
function(tribits_get_cdash_build_url_from_tag_file)
# ToDo: Implement!
endfunction()


# @FUNCTION: tribits_get_cdash_build_url_from_parts()
#
# Create CDash index.php URL from the build parts.
#
# Usage::
#
# tribits_get_cdash_build_url_from_parts(
# INDEX_PHP_URL <indexPhpUrl>
# PROJECT_NAME <projectName>
# SITE_NAME <siteName>
# BUILD_NAME <buildName>
# BUILD_STAMP <buildStamp>
# CDASH_BUILD_URL_OUT <cdashBuildUrlOut>
# )
#
# Note that spaces are allowed ``<siteName>``, ``<buildName>`` or
# ``<buildStamp>`` and those will be handled correctly to produce a valid URL.
#
function(tribits_get_cdash_build_url_from_parts)
# Get arguments
cmake_parse_arguments(
PREFIX #prefix
"" #options
"INDEX_PHP_URL;PROJECT_NAME;SITE_NAME;BUILD_NAME;BUILD_STAMP;CDASH_BUILD_URL_OUT" #one_value_keywords
"" #multi_value_keytowrds
${ARGN}
)
# Do replacements for spaces and special chars in data
tribits_replace_chars_for_url("${PREFIX_PROJECT_NAME}" project)
tribits_replace_chars_for_url("${PREFIX_SITE_NAME}" site)
tribits_replace_chars_for_url("${PREFIX_BUILD_NAME}" buildname)
tribits_replace_chars_for_url("${PREFIX_BUILD_STAMP}" buildstamp)
# Build the URL
set(cdashIndexProj "${PREFIX_INDEX_PHP_URL}?project=${project}")
set(filtersPreTxt "filtercount=3&showfilters=1&filtercombine=and")
set(siteFlt "field1=site&compare1=61&value1=${site}")
set(buildnameFlt "field2=buildname&compare2=61&value2=${buildname}")
set(buildStampFlt "field3=buildstamp&compare3=61&value3=${buildstamp}")
set(cdashBuildUrl
"${cdashIndexProj}&${filtersPreTxt}&${siteFlt}&${buildnameFlt}&${buildStampFlt}")
set(${PREFIX_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE)
endfunction()


function(tribits_replace_chars_for_url inputStr outputStrForUrlOutVar)
set(outputStrForUrl "${inputStr}")
string(REPLACE " " "%20" outputStrForUrl "${outputStrForUrl}")
string(REPLACE "+" "%2B" outputStrForUrl "${outputStrForUrl}")
set(${outputStrForUrlOutVar} "${outputStrForUrl}" PARENT_SCOPE)
endfunction()

0 comments on commit 79a5064

Please sign in to comment.