Merge topic 'ctest_update-RETURN_VALUE'
493388ce
ctest_update: Fix RETURN_VALUE on VCS tool failure (#15610)bcf25803
Tests: Teach CTest.Update* tests to check ctest_update return codeb6667729
Tests: Simplify CTest.UpdateGIT QUIET mode test
This commit is contained in:
commit
919b116f98
|
@ -283,13 +283,13 @@ int cmCTestUpdateHandler::ProcessHandler()
|
||||||
{
|
{
|
||||||
xml.Content("Update command failed:\n");
|
xml.Content("Update command failed:\n");
|
||||||
xml.Content(vc->GetUpdateCommandLine());
|
xml.Content(vc->GetUpdateCommandLine());
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE, " Update command failed: "
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Update command failed: "
|
||||||
<< vc->GetUpdateCommandLine() << "\n");
|
<< vc->GetUpdateCommandLine() << "\n");
|
||||||
}
|
}
|
||||||
xml.EndElement(); // UpdateReturnStatus
|
xml.EndElement(); // UpdateReturnStatus
|
||||||
xml.EndElement(); // Update
|
xml.EndElement(); // Update
|
||||||
xml.EndDocument();
|
xml.EndDocument();
|
||||||
return numUpdated;
|
return updated? numUpdated : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -170,3 +170,22 @@ set(CTEST_CHECKOUT_COMMAND
|
||||||
|
|
||||||
# Run the dashboard script with CTest.
|
# Run the dashboard script with CTest.
|
||||||
run_dashboard_script(dash-binary)
|
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)
|
||||||
|
|
|
@ -182,6 +182,14 @@ endfunction()
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Function to write the dashboard test script.
|
# Function to write the dashboard test script.
|
||||||
function(create_dashboard_script bin_dir custom_text)
|
function(create_dashboard_script bin_dir custom_text)
|
||||||
|
if (NOT ctest_update_check)
|
||||||
|
set(ctest_update_check [[
|
||||||
|
if(ret LESS 0)
|
||||||
|
message(FATAL_ERROR "ctest_update failed with ${ret}")
|
||||||
|
endif()
|
||||||
|
]])
|
||||||
|
endif()
|
||||||
|
|
||||||
# Write the dashboard script.
|
# Write the dashboard script.
|
||||||
file(WRITE ${TOP}/${bin_dir}.cmake
|
file(WRITE ${TOP}/${bin_dir}.cmake
|
||||||
"# CTest Dashboard Script
|
"# CTest Dashboard Script
|
||||||
|
@ -193,8 +201,8 @@ set(CTEST_BINARY_DIRECTORY \${CTEST_DASHBOARD_ROOT}/${bin_dir})
|
||||||
${custom_text}
|
${custom_text}
|
||||||
# Start a dashboard and run the update step
|
# Start a dashboard and run the update step
|
||||||
ctest_start(Experimental)
|
ctest_start(Experimental)
|
||||||
ctest_update(SOURCE \${CTEST_SOURCE_DIRECTORY})
|
ctest_update(SOURCE \${CTEST_SOURCE_DIRECTORY} RETURN_VALUE ret ${ctest_update_args})
|
||||||
")
|
${ctest_update_check}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
@ -250,6 +258,24 @@ function(check_no_update bin_dir)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
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<UpdateReturnStatus>[^<\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
|
# Function to run the dashboard through a script
|
||||||
|
@ -263,6 +289,8 @@ function(run_dashboard_script bin_dir)
|
||||||
list(APPEND UPDATE_MAYBE Updated{subdir} Updated{CTestConfig.cmake})
|
list(APPEND UPDATE_MAYBE Updated{subdir} Updated{CTestConfig.cmake})
|
||||||
if(NO_UPDATE)
|
if(NO_UPDATE)
|
||||||
check_no_update(${bin_dir})
|
check_no_update(${bin_dir})
|
||||||
|
elseif(FAIL_UPDATE)
|
||||||
|
check_fail_update(${bin_dir})
|
||||||
else()
|
else()
|
||||||
check_updates(${bin_dir}
|
check_updates(${bin_dir}
|
||||||
Updated{foo.txt}
|
Updated{foo.txt}
|
||||||
|
|
|
@ -334,31 +334,22 @@ set(CTEST_UPDATE_VERSION_ONLY TRUE)
|
||||||
# Run the dashboard script with CTest.
|
# Run the dashboard script with CTest.
|
||||||
set(NO_UPDATE 1)
|
set(NO_UPDATE 1)
|
||||||
run_dashboard_script(dash-binary-no-update)
|
run_dashboard_script(dash-binary-no-update)
|
||||||
|
unset(NO_UPDATE)
|
||||||
|
|
||||||
rewind_source(dash-source)
|
rewind_source(dash-source)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Test ctest_update(QUIET)
|
# Test ctest_update(QUIET)
|
||||||
set(NO_UPDATE 0)
|
|
||||||
message("Running CTest Dashboard Script (update quietly)...")
|
message("Running CTest Dashboard Script (update quietly)...")
|
||||||
|
|
||||||
|
set(ctest_update_args QUIET)
|
||||||
create_dashboard_script(dash-binary-quiet
|
create_dashboard_script(dash-binary-quiet
|
||||||
"# git command configuration
|
"# git command configuration
|
||||||
set(CTEST_GIT_COMMAND \"${GIT}\")
|
set(CTEST_GIT_COMMAND \"${GIT}\")
|
||||||
set(CTEST_GIT_UPDATE_OPTIONS)
|
set(CTEST_GIT_UPDATE_OPTIONS)
|
||||||
set(CTEST_GIT_UPDATE_CUSTOM \${CTEST_GIT_COMMAND} pull origin master)
|
set(CTEST_GIT_UPDATE_CUSTOM \${CTEST_GIT_COMMAND} pull origin master)
|
||||||
")
|
")
|
||||||
|
unset(ctest_update_args)
|
||||||
# We need to modify the created dashboard script to include our "QUIET"
|
|
||||||
# option.
|
|
||||||
set(filename "${TOP}/dash-binary-quiet.cmake")
|
|
||||||
file(READ "${filename}" contents)
|
|
||||||
string(REPLACE
|
|
||||||
[=[ctest_update(SOURCE ${CTEST_SOURCE_DIRECTORY})]=]
|
|
||||||
[=[ctest_update(SOURCE ${CTEST_SOURCE_DIRECTORY} QUIET)]=]
|
|
||||||
contents
|
|
||||||
"${contents}")
|
|
||||||
file(WRITE "${filename}" "${contents}")
|
|
||||||
|
|
||||||
# Run the dashboard script with CTest.
|
# Run the dashboard script with CTest.
|
||||||
run_dashboard_script(dash-binary-quiet)
|
run_dashboard_script(dash-binary-quiet)
|
||||||
|
@ -367,3 +358,23 @@ run_dashboard_script(dash-binary-quiet)
|
||||||
if("${OUTPUT}" MATCHES "Updating the repository")
|
if("${OUTPUT}" MATCHES "Updating the repository")
|
||||||
message(FATAL_ERROR "Found 'Updating the repository' in quiet output")
|
message(FATAL_ERROR "Found 'Updating the repository' in quiet output")
|
||||||
endif()
|
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)
|
||||||
|
|
|
@ -164,3 +164,22 @@ execute_process(
|
||||||
|
|
||||||
# Run the dashboard script with CTest.
|
# Run the dashboard script with CTest.
|
||||||
run_dashboard_script(dash-binary)
|
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)
|
||||||
|
|
|
@ -147,3 +147,22 @@ set(CTEST_CHECKOUT_COMMAND
|
||||||
|
|
||||||
# Run the dashboard script with CTest.
|
# Run the dashboard script with CTest.
|
||||||
run_dashboard_script(dash-binary)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue