Skip to content

Commit

Permalink
WIP: Produce CDash URLs to all builds and nonpassing tests for same r…
Browse files Browse the repository at this point in the history
…epo version (TriBITSPub#483)

ToDo: This code seeems to produce the correct URLs but I need to add strong
tests to lock this down.
  • Loading branch information
bartlettroscoe committed Jun 5, 2022
1 parent 1f19ac3 commit c45701c
Show file tree
Hide file tree
Showing 3 changed files with 324 additions and 3 deletions.
38 changes: 38 additions & 0 deletions test/ctest_driver/CTestDriverUnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,42 @@ include(TribitsReadTagFile)
include(TribitsGetCDashUrlsInsideCTestS)


function(unittest_tribits_get_cdash_revision_builds_url)

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

tribits_get_cdash_revision_builds_url(
CDASH_SITE_URL "somesite.com/my-cdash"
PROJECT_NAME goodProject
GIT_REPO_SHA1 "abc123"
CDASH_REVISION_BUILDS_URL_OUT cdashRevesionBuildsUrlOut
)
unittest_compare_const(cdashRevesionBuildsUrlOut
"somesite.com/my-cdash/index.php?project=goodProject&filtercount=1&showfilters=1&field1=revision&compare1=61&value1=abc123")

endfunction()


function(unittest_tribits_get_cdash_revision_nonpassing_tests_url)

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

tribits_get_cdash_revision_nonpassing_tests_url(
CDASH_SITE_URL "somesite.com/my-cdash"
PROJECT_NAME goodProject
GIT_REPO_SHA1 "abc123"
CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrlOut
)
unittest_compare_const(cdashRevisionNonpassingTestsUrlOut
"somesite.com/my-cdash/queryTests.php?project=goodProject&filtercount=2&showfilters=1&filtercombine=and&field1=revision&compare1=61&value1=abc123=status&compare2=62&value2=passed")

endfunction()


function(unittest_tribits_read_ctest_tag_file)

message("\n***")
Expand Down Expand Up @@ -158,6 +194,8 @@ endfunction()
unittest_initialize_vars()

# Run the unit test functions
unittest_tribits_get_cdash_revision_builds_url()
unittest_tribits_get_cdash_revision_nonpassing_tests_url()
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()
Expand Down
21 changes: 19 additions & 2 deletions tribits/ctest_driver/TribitsCTestDriverCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2093,11 +2093,25 @@ function(tribits_ctest_driver)
ctest_start(${CTEST_START_ARGS})

tribits_remember_if_configure_attempted()

# ToDo: Remove this!
tribits_get_build_url_and_write_to_file(CDASH_BUILD_URL
"${CTEST_BINARY_DIRECTORY}/CDashBuildUrl.txt")
tribits_print_cdash_url("Results will be submitted to CDash at:"
"${CDASH_BUILD_URL}")

# ToDo: Get this working!
tribits_get_cdash_results_string_and_write_to_file(
"${CTEST_BINARY_DIRECTORY}/CDashBuildUrl.txt"
CDASH_RESULTS_STRING_OUT CDASH_RESULTS_STRING)
message("Results will be submitted on CDash at the following links:\n\n"
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"
"${CDASH_RESULTS_STRING}\n"
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
)

#return() # ToDo: Remove this temporary return!

message(
"\n***"
"\n*** Update the source code repositories ..."
Expand Down Expand Up @@ -2370,8 +2384,11 @@ function(tribits_ctest_driver)

report_queued_errors()

tribits_print_cdash_url("See results submitted to CDash at:"
"${CDASH_BUILD_URL}")
message("See results submitted on CDash at the following links:\n\n"
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"
"${CDASH_RESULTS_STRING}\n"
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
)

if ((NOT UPDATE_FAILED) AND ("${${PROJECT_NAME}_FAILED_PACKAGES}" STREQUAL ""))
message(
Expand Down
268 changes: 267 additions & 1 deletion tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,276 @@ include(TribitsParseArgumentsHelpers)
include(TribitsReadTagFile)


################################################################################
#
# This module contains functions for constructing CDash URLs to build and test
# results from inside of a CTest -S script.
#
################################################################################


# @FUNCTION: tribits_get_cdash_results_string_and_write_to_file()
#
# Calls `tribits_get_cdash_results_urls_string()`_ and then writes the CDash
# URLs to a file.
#
# Usage::
#
# tribits_get_cdash_results_string_and_write_to_file(
# <cdashResultsUrlsFile>
# [CDASH_RESULTS_STRING_OUT <cdashResultsUrlsStringOut>] )
#
# If ``<cdashResultsUrlsStringOut>`` is non-empty, then that variable will
# contain the string of CDash results URLs that was written to the file
# <cdashResultsUrlsFile>.
#
function(tribits_get_cdash_results_string_and_write_to_file
cdashResultsUrlsFile
)
# Parse args
cmake_parse_arguments( PARSE_ARGV 1
PARSE "" "" # prefix, options, one_value_keywords
"CDASH_RESULTS_STRING_OUT" # multi_value_keywords
)
tribits_check_for_unparsed_arguments(PARSE)
tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_RESULTS_STRING_OUT)
# Get and set CDash results URL
tribits_get_cdash_results_urls_string(cdashResultsString)
if (PARSE_CDASH_RESULTS_STRING_OUT)
set(${PARSE_CDASH_RESULTS_STRING_OUT} "${cdashResultsString}" PARENT_SCOPE)
endif()
endfunction()


# @FUNCTION: tribits_get_cdash_results_urls_string()
#
# Call `tribits_get_cdash_results_urls()`_ and then construct a CDash URLs
# string fit for printing.
#
# Usage::
#
# tribits_get_cdash_results_urls_string(
# <cdashResultsUrlsStringOut>
# )
#
# Construct the build and test URLs on CDash given the site name, buildname,
# and buildstamp (taken from the TAG file) from inside of a running ctest -S
# program and optionally write it to a file as well.
#
function(tribits_get_cdash_results_urls_string cdashResultsUrlsStringOut)
tribits_get_cdash_results_urls(
CDASH_BUILD_URL_OUT cdashBuildUrl
CDASH_REVISION_BUILDS_URL_OUT cdashRevisionBuildsUrl
CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrl
)
tribits_generate_cdash_results_string_from_urls(
CDASH_BUILD_URL "${cdashBuildUrl}"
CDASH_REVISION_BUILDS_URL "${cdashRevisionBuildsUrl}"
CDASH_REVISION_NONPASSING_TESTS_URL "${cdashRevisionNonpassingTestsUrl}"
CDASH_RESULTS_STRING_OUT cdashResultsUrlsString
)
set(${cdashResultsUrlsStringOut} "${cdashResultsUrlsString}" PARENT_SCOPE)
endfunction()


# @FUNCTION: tribits_generate_cdash_results_string_from_urls()
#
# Generate the CDash results URL string given the individual URLs.
#
# Usage::
#
# tribits_generate_cdash_results_string_from_urls(
# CDASH_BUILD_URL "<cdashBuildUrl>"
# [CDASH_REVISION_BUILDS_URL "<cdashRevisionBuildsUrl>"]
# [CDASH_REVISION_NONPASSING_TESTS_URL "<cdashRevisionNonpassingTestsUrl>"]
# CDASH_RESULTS_STRING_OUT <cdashResultsUrlsStringOut>
# )
#
# Takes the URLs returned from `tribits_get_cdash_results_urls()`_ and
# generates a string out of them which is set in the return var
# ``<cdashResultsUrlsStringOut>``.
#
function(tribits_generate_cdash_results_string_from_urls)
# Parse args
cmake_parse_arguments(PARSE_ARGV 0
PARSE "" "" # prefix, options, one_value_keywords
# multi_value_keywords
"CDASH_BUILD_URL;CDASH_REVISION_BUILDS_URL;CDASH_REVISION_NONPASSING_TESTS_URL;CDASH_RESULTS_STRING_OUT"
)
tribits_check_for_unparsed_arguments()
tribits_assert_parse_arg_one_value(PARSE CDASH_BUILD_URL
CDASH_RESULTS_STRING_OUT)
tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_REVISION_BUILDS_URL
CDASH_REVISION_NONPASSING_TESTS_URL)
# Construct CDash results URLs string
set(cdashResultsString "")
string(APPEND cdashResultsString
"Link to this build's results on CDash:\n"
"\n"
" ${PARSE_CDASH_BUILD_URL}\n")
if (PARSE_CDASH_REVISION_BUILDS_URL)
string(APPEND cdashResultsString
"\nLink all builds for this repo version on CDash:\n"
"\n"
" ${PARSE_CDASH_REVISION_BUILDS_URL}\n")
endif()
if (PARSE_CDASH_REVISION_NONPASSING_TESTS_URL)
string(APPEND cdashResultsString
"\nLink to all nonpassing tests for all builds for this repo version on CDash:\n"
"\n"
" ${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL}\n")
endif()
# Set output
set(${PARSE_CDASH_RESULTS_STRING_OUT} ${cdashResultsString} PARENT_SCOPE)
endfunction()


# @FUNCTION: tribits_get_cdash_results_urls()
#
# Construct the build and test URLs on CDash given the site name, buildname,
# and buildstamp (taken from the TAG file) from inside of a running ctest -S
# program and optionally write it to a file as well.
#
# Usage::
#
# tribits_get_cdash_results_urls(
# CDASH_BUILD_URL_OUT <cdashBuildUrlOut>
# [CDASH_REVISION_BUILDS_URL_OUT <cdashRevisionBuildsUrlOut>]
# [CDASH_REVISION_NONPASSING_TESTS_URL_OUT <cdashRevisionNonpassingTestsUrlOut>]
# )
#
# Here, the CDash URLs are constructed the following CMake variables already
# set in a ``ctest -S`` process:
#
# * ``CTEST_DROP_SITE``
# * ``CTEST_DROP_LOCATION`` (``submit.php`` is replaced with ``index.php``)
# * ``CTEST_PROJECT_NAME``
# * ``CTEST_SITE``
# * ``CTEST_BUILD_NAME``
# * ``CTEST_BINARY_DIRECTORY``
# * ``CTEST_SOURCE_DIRECTORY``
#
# and other information derived from that.
#
# The buildstamp is read in from the file
# ``${CTEST_BINARY_DIRECTORY}/Testing/TAG``.
#
# If available, the revision SHA1 is obtained from the git repo at
# ``CTEST_SOURCE_DIRECTORY`` if the directory
# ``${CTEST_SOURCE_DIRECTORY}/.git`` exists. If the base project source
# directory is not a git reposistory, then ``<cdashRevisionBuildsUrlOut>`` and
# ``<cdashRevisionNonpassingTestsUrlOut>``, if requested, will be set to
# empty.
#
# Note that the CDash URLs will have ``https://`` added to the beginning so
# that GitHub Actions and other systems will put in a hyperlink to them.
#
function(tribits_get_cdash_results_urls)
# Parse args
cmake_parse_arguments(PARSE_ARGV 0
PARSE "" "" # prefix, options, one_value_keywords
# multi_value_keywords
"CDASH_BUILD_URL_OUT;CDASH_REVISION_BUILDS_URL_OUT;CDASH_REVISION_NONPASSING_TESTS_URL_OUT"
)
tribits_check_for_unparsed_arguments(PARSE)
tribits_assert_parse_arg_one_value(PARSE CDASH_BUILD_URL_OUT)
tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_REVISION_BUILDS_URL_OUT
CDASH_REVISION_NONPASSING_TESTS_URL_OUT)
# Get the info
tribits_get_build_url_and_write_to_file(cdashBuildUrl "")
tribits_git_repo_sha1("${CTEST_SOURCE_DIRECTORY}" gitRepoSha1
FAILURE_MESSAGE_OUT gitRepoSha1FailureMsg)
if (gitRepoSha1)
tribits_get_cdash_site_from_drop_site_and_location(
CTEST_DROP_SITE "${CTEST_DROP_SITE}"
CTEST_DROP_LOCATION "${CTEST_DROP_LOCATION}"
CDASH_SITE_URL_OUT cdashSiteUrl
)
tribits_get_cdash_revision_builds_url(
CDASH_SITE_URL "${cdashSiteUrl}"
PROJECT_NAME "${CTEST_PROJECT_NAME}"
GIT_REPO_SHA1 "${gitRepoSha1}"
CDASH_REVISION_BUILDS_URL_OUT cdashRevisionBuildsUrl
)
tribits_get_cdash_revision_nonpassing_tests_url(
CDASH_SITE_URL "${cdashSiteUrl}"
PROJECT_NAME "${CTEST_PROJECT_NAME}"
GIT_REPO_SHA1 "${gitRepoSha1}"
CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrl
)
else()
set(cdashRevisionBuildsUrl "")
set(cdashRevisionNonpassingTestsUrl "")
endif()
# Set the outputs
set(${PARSE_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE)
set(${PARSE_CDASH_REVISION_BUILDS_URL_OUT} "${cdashRevisionBuildsUrl}"
PARENT_SCOPE)
set(${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL_OUT} "${cdashRevisionNonpassingTestsUrl}"
PARENT_SCOPE)
endfunction()


# @FUNCTION: tribits_get_cdash_revision_builds_url()
#
# Get the CDash URL for all builds with the same repo version SHA1
#
# Usage::
#
# tribits_get_cdash_revision_builds_url(
# CDASH_SITE_URL <cdashSiteUrl>
# PROJECT_NAME <projectName>
# GIT_REPO_SHA1 <gitRepoSha1>
# CDASH_REVISION_BUILDS_URL_OUT <cdashRevisionBuildsUrlOut>
# )
#
function(tribits_get_cdash_revision_builds_url)
cmake_parse_arguments(PARSE_ARGV 0
PARSE "" "" # prefix, options, one_value_keywords
# multi_value_keywords
"CDASH_SITE_URL;PROJECT_NAME;GIT_REPO_SHA1;CDASH_REVISION_BUILDS_URL_OUT"
)
tribits_check_for_unparsed_arguments()
tribits_assert_parse_arg_one_value(PARSE CDASH_SITE_URL PROJECT_NAME
GIT_REPO_SHA1 CDASH_REVISION_BUILDS_URL_OUT)
set(${PARSE_CDASH_REVISION_BUILDS_URL_OUT}
"${PARSE_CDASH_SITE_URL}/index.php?project=${PARSE_PROJECT_NAME}&filtercount=1&showfilters=1&field1=revision&compare1=61&value1=${PARSE_GIT_REPO_SHA1}"
PARENT_SCOPE)
endfunction()


# @FUNCTION: tribits_get_cdash_revision_nonpassing_tests_url()
#
# Get the CDash URL for all non-passing tests with the same repo version SHA1
#
# Usage::
#
# tribits_get_cdash_revision_nonpassing_tests_url(
# CDASH_SITE_URL <cdashSiteUrl>
# PROJECT_NAME <projectName>
# GIT_REPO_SHA1 <gitRepoSha1>
# CDASH_REVISION_NONPASSING_TESTS_URL_OUT <cdashRevisionNonpassingTestsUrlOut>
# )
#
function(tribits_get_cdash_revision_nonpassing_tests_url)
cmake_parse_arguments( PARSE_ARGV 0
PARSE "" "" # prefix, options, one_value_keywords
# multi_value_keywords
"CDASH_SITE_URL;PROJECT_NAME;GIT_REPO_SHA1;CDASH_REVISION_NONPASSING_TESTS_URL_OUT"
)
tribits_check_for_unparsed_arguments()
tribits_assert_parse_arg_one_value(PARSE CDASH_SITE_URL PROJECT_NAME
GIT_REPO_SHA1 CDASH_REVISION_NONPASSING_TESTS_URL_OUT)
set(${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL_OUT}
"${PARSE_CDASH_SITE_URL}/queryTests.php?project=${PARSE_PROJECT_NAME}&filtercount=2&showfilters=1&filtercombine=and&field1=revision&compare1=61&value1=${PARSE_GIT_REPO_SHA1}=status&compare2=62&value2=passed"
PARENT_SCOPE)
endfunction()


# @FUNCTION: tribits_get_build_url_and_write_to_file()
#
# Construct the build URL on CDash given the site name, buildname, and
# buildstamp (take from the TAG file) from inside of a running ctest -S
# buildstamp (taken from the TAG file) from inside of a running ctest -S
# program and optionally write it to a file as well.
#
# Usage::
Expand Down

0 comments on commit c45701c

Please sign in to comment.