Skip to content

Commit

Permalink
Factor out tribits_get_cdash_site_from_drop_site_and_location() (TriB…
Browse files Browse the repository at this point in the history
…ITSPub#483)

This will make this easier to reuse to get other CDash URLs.
  • Loading branch information
bartlettroscoe committed Jun 7, 2022
1 parent b3074cc commit 10dc684
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 7 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 = 6"
"Final UnitTests Result: num_run = 9"
"Final UnitTests Result: PASSED"
)

Expand Down
22 changes: 20 additions & 2 deletions test/ctest_driver/CTestDriverUnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ function(unittest_tribits_read_ctest_tag_file)
endfunction()


function(unittest_tribits_get_cdash_site_from_drop_site_and_location)

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

tribits_get_cdash_site_from_drop_site_and_location(
CTEST_DROP_SITE "some.site.com"
CTEST_DROP_LOCATION "/cdash/submit.php?project=SomeProject"
CDASH_SITE_URL_OUT cdashSiteUrl
)

unittest_compare_const(cdashSiteUrl "https://some.site.com/cdash")

endfunction()


function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location)

message("\n***")
Expand All @@ -85,7 +102,7 @@ function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location)
INDEX_PHP_URL_OUT indexPhpUrl
)

unittest_compare_const(indexPhpUrl "some.site.com/cdash/index.php")
unittest_compare_const(indexPhpUrl "https://some.site.com/cdash/index.php")

endfunction()

Expand Down Expand Up @@ -142,6 +159,7 @@ unittest_initialize_vars()

# Run the unit test functions
unittest_tribits_read_ctest_tag_file()
unittest_tribits_get_cdash_site_from_drop_site_and_location()
unittest_tribits_get_cdash_index_php_from_drop_site_and_location()
unittest_tribits_get_cdash_build_url_from_parts()
unittest_tribits_get_cdash_build_url_from_tag_file()
Expand All @@ -151,4 +169,4 @@ message("*** Determine final result of all unit tests")
message("***\n")

# Pass in the number of expected tests that must pass!
unittest_final_result(6)
unittest_final_result(9)
44 changes: 40 additions & 4 deletions tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
# @HEADER


include(PrintVar)
include(TribitsParseArgumentsHelpers)
include(TribitsReadTagFile)


Expand Down Expand Up @@ -85,7 +87,7 @@ function(tribits_get_build_url_and_write_to_file cdashBuildUrlOut cdashBuildUr
TAG_FILE "${CTEST_BINARY_DIRECTORY}/Testing/TAG"
CDASH_BUILD_URL_OUT cdashBuildUrl
)
set(cdashBuildUrl "https://${cdashBuildUrl}")
set(cdashBuildUrl "${cdashBuildUrl}")
if (cdashBuildUrlFile)
file(WRITE "${cdashBuildUrlFile}" "${cdashBuildUrl}")
endif()
Expand Down Expand Up @@ -165,11 +167,45 @@ function(tribits_get_cdash_index_php_from_drop_site_and_location)
"" #multi_value_keywords
${ARGN}
)
tribits_get_cdash_site_from_drop_site_and_location(
CTEST_DROP_SITE ${PREFIX_CTEST_DROP_SITE}
CTEST_DROP_LOCATION ${PREFIX_CTEST_DROP_LOCATION}
CDASH_SITE_URL_OUT cdashSiteUrl )
SET(${PREFIX_INDEX_PHP_URL_OUT} "${cdashSiteUrl}/index.php" PARENT_SCOPE)
endfunction()


# @FUNCTION: tribits_get_cdash_site_from_drop_site_and_location()
#
# Get the full CDash site base URL from the input CTEST_DROP_SITE and
# CTEST_DROP_LOCATION vars used in a ctest -S script.
#
# Usage::
#
# tribits_get_cdash_site_from_drop_site_and_location(
# CTEST_DROP_SITE <ctestDropSite>
# CTEST_DROP_LOCATION <ctestDropLocation>
# CDASH_SITE_URL_OUT <cdashSiteUrlOut>
# )
#
function(tribits_get_cdash_site_from_drop_site_and_location)
# Parse args
cmake_parse_arguments(PARSE_ARGV 0
PREFIX #prefix
"" #options
"CTEST_DROP_SITE;CTEST_DROP_LOCATION;CDASH_SITE_URL_OUT" #one_value_keywords
"" #multi_value_keywords
)
tribits_check_for_unparsed_arguments(PREFIX)
tribits_assert_parse_arg_one_value(PREFIX CTEST_DROP_SITE)
tribits_assert_parse_arg_one_value(PREFIX CTEST_DROP_LOCATION)
tribits_assert_parse_arg_one_value(PREFIX CDASH_SITE_URL_OUT)
# Get the full CDash site from parts
string(FIND "${PREFIX_CTEST_DROP_LOCATION}" "?" endOfSubmitPhpIdx)
string(SUBSTRING "${PREFIX_CTEST_DROP_LOCATION}" 0 ${endOfSubmitPhpIdx} submitPhpPart)
string(REPLACE "submit.php" "index.php" indexPhpPart "${submitPhpPart}")
set(indexPhpUrl "${PREFIX_CTEST_DROP_SITE}${indexPhpPart}")
SET(${PREFIX_INDEX_PHP_URL_OUT} "${indexPhpUrl}" PARENT_SCOPE)
string(REPLACE "/submit.php" "" endCDashUrl "${submitPhpPart}")
set(cdashSiteUrl "${PREFIX_CTEST_DROP_SITE}${endCDashUrl}")
set(${PREFIX_CDASH_SITE_URL_OUT} "https://${cdashSiteUrl}" PARENT_SCOPE)
endfunction()


Expand Down

0 comments on commit 10dc684

Please sign in to comment.