From 493388ce48cb4188068c6f0379bb2afa60c0a41a Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 11 Jun 2015 09:00:01 -0400 Subject: ctest_update: Fix RETURN_VALUE on VCS tool failure (#15610) Make RETURN_VALUE report -1 if the update command failed as the documentation claims. Also avoid reporting a ctest script-level failure if the update command fails because we still correctly administered the update step. --- Source/CTest/cmCTestUpdateHandler.cxx | 4 ++-- Tests/CTestUpdateCVS.cmake.in | 19 +++++++++++++++++++ Tests/CTestUpdateCommon.cmake | 20 ++++++++++++++++++++ Tests/CTestUpdateGIT.cmake.in | 20 ++++++++++++++++++++ Tests/CTestUpdateHG.cmake.in | 19 +++++++++++++++++++ Tests/CTestUpdateSVN.cmake.in | 19 +++++++++++++++++++ 6 files changed, 99 insertions(+), 2 deletions(-) diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 8494d28..963e501 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -283,13 +283,13 @@ int cmCTestUpdateHandler::ProcessHandler() { xml.Content("Update command failed:\n"); xml.Content(vc->GetUpdateCommandLine()); - cmCTestLog(this->CTest, ERROR_MESSAGE, " Update command failed: " + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Update command failed: " << vc->GetUpdateCommandLine() << "\n"); } xml.EndElement(); // UpdateReturnStatus xml.EndElement(); // Update xml.EndDocument(); - return numUpdated; + return updated? numUpdated : -1; } //---------------------------------------------------------------------- diff --git a/Tests/CTestUpdateCVS.cmake.in b/Tests/CTestUpdateCVS.cmake.in index 1699c3f..277b3a6 100644 --- a/Tests/CTestUpdateCVS.cmake.in +++ b/Tests/CTestUpdateCVS.cmake.in @@ -170,3 +170,22 @@ set(CTEST_CHECKOUT_COMMAND # Run the dashboard script with CTest. run_dashboard_script(dash-binary) + +#----------------------------------------------------------------------------- +# Test ctest_update(RETURN_VALUE) on failure +message("Running CTest Dashboard Script (fail to update)...") + +set(ctest_update_check [[ +if(NOT ret LESS 0) + message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}") +endif() +]]) +create_dashboard_script(dash-binary-fail + "set(CTEST_CVS_COMMAND \"update-command-does-not-exist\") +") +unset(ctest_update_check) + +# Run the dashboard script with CTest. +set(FAIL_UPDATE 1) +run_dashboard_script(dash-binary-fail) +unset(FAIL_UPDATE) diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index df1a713..458e427 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -258,6 +258,24 @@ function(check_no_update bin_dir) endif() endfunction() +#----------------------------------------------------------------------------- +# Function to find the Update.xml file and make sure +# it only has the UpdateReturnStatus failure message and no updates. +function(check_fail_update bin_dir) + set(PATTERN ${TOP}/${bin_dir}/Testing/*/Update.xml) + file(GLOB UPDATE_XML_FILE RELATIVE ${TOP} ${PATTERN}) + string(REGEX REPLACE "//Update.xml$" "/Update.xml" + UPDATE_XML_FILE "${UPDATE_XML_FILE}") + message(" found ${UPDATE_XML_FILE}") + file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_STATUS + REGEX "^\t[^<\n]+" + ) + if(UPDATE_XML_STATUS MATCHES "Update command failed") + message(" correctly found 'Update command failed'") + else() + message(FATAL_ERROR " missing 'Update command failed'") + endif() +endfunction() #----------------------------------------------------------------------------- # Function to run the dashboard through a script @@ -271,6 +289,8 @@ function(run_dashboard_script bin_dir) list(APPEND UPDATE_MAYBE Updated{subdir} Updated{CTestConfig.cmake}) if(NO_UPDATE) check_no_update(${bin_dir}) + elseif(FAIL_UPDATE) + check_fail_update(${bin_dir}) else() check_updates(${bin_dir} Updated{foo.txt} diff --git a/Tests/CTestUpdateGIT.cmake.in b/Tests/CTestUpdateGIT.cmake.in index 3734e2b..6488a1f 100644 --- a/Tests/CTestUpdateGIT.cmake.in +++ b/Tests/CTestUpdateGIT.cmake.in @@ -358,3 +358,23 @@ run_dashboard_script(dash-binary-quiet) if("${OUTPUT}" MATCHES "Updating the repository") message(FATAL_ERROR "Found 'Updating the repository' in quiet output") endif() + +#----------------------------------------------------------------------------- +# Test ctest_update(RETURN_VALUE) on failure +message("Running CTest Dashboard Script (fail to update)...") + +set(ctest_update_check [[ + +if(NOT ret LESS 0) + message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}") +endif() +]]) +create_dashboard_script(dash-binary-fail + "set(CTEST_GIT_COMMAND \"update-command-does-not-exist\") +") +unset(ctest_update_check) + +# Run the dashboard script with CTest. +set(FAIL_UPDATE 1) +run_dashboard_script(dash-binary-fail) +unset(FAIL_UPDATE) diff --git a/Tests/CTestUpdateHG.cmake.in b/Tests/CTestUpdateHG.cmake.in index c5440f9..c76bf91 100644 --- a/Tests/CTestUpdateHG.cmake.in +++ b/Tests/CTestUpdateHG.cmake.in @@ -164,3 +164,22 @@ execute_process( # Run the dashboard script with CTest. run_dashboard_script(dash-binary) + +#----------------------------------------------------------------------------- +# Test ctest_update(RETURN_VALUE) on failure +message("Running CTest Dashboard Script (fail to update)...") + +set(ctest_update_check [[ +if(NOT ret LESS 0) + message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}") +endif() +]]) +create_dashboard_script(dash-binary-fail + "set(CTEST_HG_COMMAND \"update-command-does-not-exist\") +") +unset(ctest_update_check) + +# Run the dashboard script with CTest. +set(FAIL_UPDATE 1) +run_dashboard_script(dash-binary-fail) +unset(FAIL_UPDATE) diff --git a/Tests/CTestUpdateSVN.cmake.in b/Tests/CTestUpdateSVN.cmake.in index b5728fd..b757a44 100644 --- a/Tests/CTestUpdateSVN.cmake.in +++ b/Tests/CTestUpdateSVN.cmake.in @@ -147,3 +147,22 @@ set(CTEST_CHECKOUT_COMMAND # Run the dashboard script with CTest. run_dashboard_script(dash-binary) + +#----------------------------------------------------------------------------- +# Test ctest_update(RETURN_VALUE) on failure +message("Running CTest Dashboard Script (fail to update)...") + +set(ctest_update_check [[ +if(NOT ret LESS 0) + message(FATAL_ERROR "ctest_update incorrectly succeeded with ${ret}") +endif() +]]) +create_dashboard_script(dash-binary-fail + "set(CTEST_SVN_COMMAND \"update-command-does-not-exist\") +") +unset(ctest_update_check) + +# Run the dashboard script with CTest. +set(FAIL_UPDATE 1) +run_dashboard_script(dash-binary-fail) +unset(FAIL_UPDATE) -- cgit v0.12