Skip to content

Commit

Permalink
WIP: Factor out tribits_get_cdash_site_from_drop_site_and_location() (T…
Browse files Browse the repository at this point in the history
…riBITSPub#483)

This will make this easy to reuse to get other CDash URLs.
  • Loading branch information
bartlettroscoe committed Jun 5, 2022
1 parent d951cc9 commit 1f19ac3
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 6 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)
82 changes: 79 additions & 3 deletions tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# @HEADER
# ************************************************************************
#
# TriBITS: Tribal Build, Integrate, and Test System
# Copyright 2013 Sandia Corporation
#
# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
# the U.S. Government retains certain rights in this software.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Corporation nor the names of the
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ************************************************************************
# @HEADER


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


Expand Down Expand Up @@ -125,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 1f19ac3

Please sign in to comment.