Skip to content

Commit 32cc1ad

Browse files
Factor out tribits_get_cdash_site_from_drop_site_and_location() (#483)
This will make this easier to reuse to get other CDash URLs.
1 parent d951cc9 commit 32cc1ad

File tree

3 files changed

+101
-7
lines changed

3 files changed

+101
-7
lines changed

test/ctest_driver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tribits_add_advanced_test( CTestDriverUnitTests
66
-D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
77
-P "${CMAKE_CURRENT_SOURCE_DIR}/CTestDriverUnitTests.cmake"
88
PASS_REGULAR_EXPRESSION_ALL
9-
"Final UnitTests Result: num_run = 6"
9+
"Final UnitTests Result: num_run = 9"
1010
"Final UnitTests Result: PASSED"
1111
)
1212

test/ctest_driver/CTestDriverUnitTests.cmake

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,23 @@ function(unittest_tribits_read_ctest_tag_file)
7373
endfunction()
7474

7575

76+
function(unittest_tribits_get_cdash_site_from_drop_site_and_location)
77+
78+
message("\n***")
79+
message("*** Testing tribits_get_cdash_site_from_drop_site_and_location()")
80+
message("***\n")
81+
82+
tribits_get_cdash_site_from_drop_site_and_location(
83+
CTEST_DROP_SITE "some.site.com"
84+
CTEST_DROP_LOCATION "/cdash/submit.php?project=SomeProject"
85+
CDASH_SITE_URL_OUT cdashSiteUrl
86+
)
87+
88+
unittest_compare_const(cdashSiteUrl "https://some.site.com/cdash")
89+
90+
endfunction()
91+
92+
7693
function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location)
7794

7895
message("\n***")
@@ -85,7 +102,7 @@ function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location)
85102
INDEX_PHP_URL_OUT indexPhpUrl
86103
)
87104

88-
unittest_compare_const(indexPhpUrl "some.site.com/cdash/index.php")
105+
unittest_compare_const(indexPhpUrl "https://some.site.com/cdash/index.php")
89106

90107
endfunction()
91108

@@ -142,6 +159,7 @@ unittest_initialize_vars()
142159

143160
# Run the unit test functions
144161
unittest_tribits_read_ctest_tag_file()
162+
unittest_tribits_get_cdash_site_from_drop_site_and_location()
145163
unittest_tribits_get_cdash_index_php_from_drop_site_and_location()
146164
unittest_tribits_get_cdash_build_url_from_parts()
147165
unittest_tribits_get_cdash_build_url_from_tag_file()
@@ -151,4 +169,4 @@ message("*** Determine final result of all unit tests")
151169
message("***\n")
152170

153171
# Pass in the number of expected tests that must pass!
154-
unittest_final_result(6)
172+
unittest_final_result(9)

tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
# @HEADER
2+
# ************************************************************************
3+
#
4+
# TriBITS: Tribal Build, Integrate, and Test System
5+
# Copyright 2013 Sandia Corporation
6+
#
7+
# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8+
# the U.S. Government retains certain rights in this software.
9+
#
10+
# Redistribution and use in source and binary forms, with or without
11+
# modification, are permitted provided that the following conditions are
12+
# met:
13+
#
14+
# 1. Redistributions of source code must retain the above copyright
15+
# notice, this list of conditions and the following disclaimer.
16+
#
17+
# 2. Redistributions in binary form must reproduce the above copyright
18+
# notice, this list of conditions and the following disclaimer in the
19+
# documentation and/or other materials provided with the distribution.
20+
#
21+
# 3. Neither the name of the Corporation nor the names of the
22+
# contributors may be used to endorse or promote products derived from
23+
# this software without specific prior written permission.
24+
#
25+
# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
#
37+
# ************************************************************************
38+
# @HEADER
39+
40+
41+
include(PrintVar)
42+
include(TribitsParseArgumentsHelpers)
143
include(TribitsReadTagFile)
244

345

@@ -45,7 +87,7 @@ function(tribits_get_build_url_and_write_to_file cdashBuildUrlOut cdashBuildUr
4587
TAG_FILE "${CTEST_BINARY_DIRECTORY}/Testing/TAG"
4688
CDASH_BUILD_URL_OUT cdashBuildUrl
4789
)
48-
set(cdashBuildUrl "https://${cdashBuildUrl}")
90+
set(cdashBuildUrl "${cdashBuildUrl}")
4991
if (cdashBuildUrlFile)
5092
file(WRITE "${cdashBuildUrlFile}" "${cdashBuildUrl}")
5193
endif()
@@ -125,11 +167,45 @@ function(tribits_get_cdash_index_php_from_drop_site_and_location)
125167
"" #multi_value_keywords
126168
${ARGN}
127169
)
170+
tribits_get_cdash_site_from_drop_site_and_location(
171+
CTEST_DROP_SITE ${PREFIX_CTEST_DROP_SITE}
172+
CTEST_DROP_LOCATION ${PREFIX_CTEST_DROP_LOCATION}
173+
CDASH_SITE_URL_OUT cdashSiteUrl )
174+
SET(${PREFIX_INDEX_PHP_URL_OUT} "${cdashSiteUrl}/index.php" PARENT_SCOPE)
175+
endfunction()
176+
177+
178+
# @FUNCTION: tribits_get_cdash_site_from_drop_site_and_location()
179+
#
180+
# Get the full CDash site base URL from the input CTEST_DROP_SITE and
181+
# CTEST_DROP_LOCATION vars used in a ctest -S script.
182+
#
183+
# Usage::
184+
#
185+
# tribits_get_cdash_site_from_drop_site_and_location(
186+
# CTEST_DROP_SITE <ctestDropSite>
187+
# CTEST_DROP_LOCATION <ctestDropLocation>
188+
# CDASH_SITE_URL_OUT <cdashSiteUrlOut>
189+
# )
190+
#
191+
function(tribits_get_cdash_site_from_drop_site_and_location)
192+
# Parse args
193+
cmake_parse_arguments(PARSE_ARGV 0
194+
PREFIX #prefix
195+
"" #options
196+
"CTEST_DROP_SITE;CTEST_DROP_LOCATION;CDASH_SITE_URL_OUT" #one_value_keywords
197+
"" #multi_value_keywords
198+
)
199+
tribits_check_for_unparsed_arguments(PREFIX)
200+
tribits_assert_parse_arg_one_value(PREFIX CTEST_DROP_SITE)
201+
tribits_assert_parse_arg_one_value(PREFIX CTEST_DROP_LOCATION)
202+
tribits_assert_parse_arg_one_value(PREFIX CDASH_SITE_URL_OUT)
203+
# Get the full CDash site from parts
128204
string(FIND "${PREFIX_CTEST_DROP_LOCATION}" "?" endOfSubmitPhpIdx)
129205
string(SUBSTRING "${PREFIX_CTEST_DROP_LOCATION}" 0 ${endOfSubmitPhpIdx} submitPhpPart)
130-
string(REPLACE "submit.php" "index.php" indexPhpPart "${submitPhpPart}")
131-
set(indexPhpUrl "${PREFIX_CTEST_DROP_SITE}${indexPhpPart}")
132-
SET(${PREFIX_INDEX_PHP_URL_OUT} "${indexPhpUrl}" PARENT_SCOPE)
206+
string(REPLACE "/submit.php" "" endCDashUrl "${submitPhpPart}")
207+
set(cdashSiteUrl "${PREFIX_CTEST_DROP_SITE}${endCDashUrl}")
208+
set(${PREFIX_CDASH_SITE_URL_OUT} "https://${cdashSiteUrl}" PARENT_SCOPE)
133209
endfunction()
134210

135211

0 commit comments

Comments
 (0)