diff options
-rw-r--r-- | Modules/ExternalProject.cmake | 34 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestP4.cxx | 61 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 20 | ||||
-rw-r--r-- | Tests/CMakeTests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/CMakeTests/FileDownloadBadHashTest.cmake.in | 10 | ||||
-rw-r--r-- | Tests/CMakeTests/FileDownloadTest.cmake.in | 13 | ||||
-rw-r--r-- | Tests/CTestUpdateCommon.cmake | 4 |
9 files changed, 109 insertions, 41 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 63f1180..1c1bd2f 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -585,13 +585,30 @@ message(STATUS \"downloading... done\") endfunction() -function(_ep_write_verifyfile_script script_filename local hash) +function(_ep_write_verifyfile_script script_filename local hash retries download_script) if("${hash}" MATCHES "${_ep_hash_regex}") set(algo "${CMAKE_MATCH_1}") string(TOLOWER "${CMAKE_MATCH_2}" expect_value) set(script_content "set(expect_value \"${expect_value}\") -file(${algo} \"\${file}\" actual_value) -if(\"\${actual_value}\" STREQUAL \"\${expect_value}\") +set(attempt 0) +set(succeeded 0) +while(\${attempt} LESS ${retries} OR \${attempt} EQUAL ${retries} AND NOT \${succeeded}) + file(${algo} \"\${file}\" actual_value) + if(\"\${actual_value}\" STREQUAL \"\${expect_value}\") + set(succeeded 1) + elseif(\${attempt} LESS ${retries}) + message(STATUS \"${algo} hash of \${file} +does not match expected value + expected: \${expect_value} + actual: \${actual_value} +Retrying download. +\") + file(REMOVE \"\${file}\") + execute_process(COMMAND ${CMAKE_COMMAND} -P \"${download_script}\") + endif() +endwhile() + +if(\${succeeded}) message(STATUS \"verifying file... done\") else() message(FATAL_ERROR \"error: ${algo} hash of @@ -1394,6 +1411,8 @@ function(_ep_add_download_command name) set(repository "external project URL") set(module "${url}") set(tag "${hash}") + set(retries 0) + set(download_script "") configure_file( "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in" "${stamp_dir}/${name}-urlinfo.txt" @@ -1423,16 +1442,17 @@ function(_ep_add_download_command name) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) - _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" - "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") - set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake + set(download_script "${stamp_dir}/download-${name}.cmake") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") + set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) + set(retries 3) set(comment "Performing download step (download, verify and extract) for '${name}'") else() set(file "${url}") set(comment "Performing download step (verify and extract) for '${name}'") endif() - _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}") + _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}" "${retries}" "${download_script}") list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake COMMAND) _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index bbc39e6..301eff0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 12) -set(CMake_VERSION_TWEAK 20140122) +set(CMake_VERSION_TWEAK 20140127) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 0058721..b09d6f5 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -380,10 +380,16 @@ std::string cmCTestP4::GetWorkingRevision() p4_identify.push_back(0); std::string rev; - IdentifyParser out(this, "rev-out> ", rev); - OutputLogger err(this->Log, "rev-err> "); + IdentifyParser out(this, "p4_changes-out> ", rev); + OutputLogger err(this->Log, "p4_changes-err> "); - RunChild(&p4_identify[0], &out, &err); + bool result = RunChild(&p4_identify[0], &out, &err); + + // If there was a problem contacting the server return "<unknown>" + if(!result) + { + return "<unknown>"; + } if(rev.empty()) { @@ -423,29 +429,24 @@ void cmCTestP4::LoadRevisions() // Use 'p4 changes ...@old,new' to get a list of changelists std::string range = this->SourceDirectory + "/..."; - if(this->OldRevision != "0") + // If any revision is unknown it means we couldn't contact the server. + // Do not process updates + if(this->OldRevision == "<unknown>" || this->NewRevision == "<unknown>") { - range.append("@").append(this->OldRevision); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " At least one of the revisions " + << "is unknown. No repository changes will be reported.\n"); + return; } - if(this->NewRevision != "0") - { - if(this->OldRevision != "0") - { - range.append(",").append(this->NewRevision); - } - else - { - range.append("@").append(this->NewRevision); - } - } + range.append("@").append(this->OldRevision) + .append(",").append(this->NewRevision); p4_changes.push_back("changes"); p4_changes.push_back(range.c_str()); p4_changes.push_back(0); - ChangesParser out(this, "changes-out> "); - OutputLogger err(this->Log, "changes-err> "); + ChangesParser out(this, "p4_changes-out> "); + OutputLogger err(this->Log, "p4_changes-err> "); ChangeLists.clear(); this->RunChild(&p4_changes[0], &out, &err); @@ -464,8 +465,8 @@ void cmCTestP4::LoadRevisions() p4_describe.push_back(i->c_str()); p4_describe.push_back(0); - DescribeParser outDescribe(this, "describe-out> "); - OutputLogger errDescribe(this->Log, "describe-err> "); + DescribeParser outDescribe(this, "p4_describe-out> "); + OutputLogger errDescribe(this->Log, "p4_describe-err> "); this->RunChild(&p4_describe[0], &outDescribe, &errDescribe); } } @@ -484,8 +485,8 @@ void cmCTestP4::LoadModifications() p4_diff.push_back(source.c_str()); p4_diff.push_back(0); - DiffParser out(this, "diff-out> "); - OutputLogger err(this->Log, "diff-err> "); + DiffParser out(this, "p4_diff-out> "); + OutputLogger err(this->Log, "p4_diff-err> "); this->RunChild(&p4_diff[0], &out, &err); } @@ -503,8 +504,8 @@ bool cmCTestP4::UpdateCustom(const std::string& custom) } p4_custom.push_back(0); - OutputLogger custom_out(this->Log, "custom-out> "); - OutputLogger custom_err(this->Log, "custom-err> "); + OutputLogger custom_out(this->Log, "p4_customsync-out> "); + OutputLogger custom_err(this->Log, "p4_customsync-err> "); return this->RunUpdateCommand(&p4_custom[0], &custom_out, &custom_err); } @@ -518,6 +519,14 @@ bool cmCTestP4::UpdateImpl() return this->UpdateCustom(custom); } + // If we couldn't get a revision number before updating, abort. + if(this->OldRevision == "<unknown>") + { + this->UpdateCommandLine = "Unknown current revision"; + cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown current revision\n"); + return false; + } + std::vector<char const*> p4_sync; SetP4Options(p4_sync); @@ -552,8 +561,8 @@ bool cmCTestP4::UpdateImpl() p4_sync.push_back(source.c_str()); p4_sync.push_back(0); - OutputLogger out(this->Log, "sync-out> "); - OutputLogger err(this->Log, "sync-err> "); + OutputLogger out(this->Log, "p4_sync-out> "); + OutputLogger err(this->Log, "p4_sync-err> "); return this->RunUpdateCommand(&p4_sync[0], &out, &err); } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 311763b..e79bc6c 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2983,6 +2983,8 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) << " for file: [" << file << "]" << std::endl << " expected hash: [" << expectedHash << "]" << std::endl << " actual hash: [" << actualHash << "]" << std::endl + << " status: [" << (int)res << ";\"" + << ::curl_easy_strerror(res) << "\"]" << std::endl ; this->SetError(oss.str().c_str()); return false; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 5e1f1ed..731bc00 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1110,16 +1110,24 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) /*restat=*/ false, /*generator=*/ true); + cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(lg); + cmNinjaDeps implicitDeps; - for (std::vector<cmLocalGenerator *>::const_iterator i = - this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) { - const std::vector<std::string>& lf = (*i)->GetMakefile()->GetListFiles(); - implicitDeps.insert(implicitDeps.end(), lf.begin(), lf.end()); - } + for(std::vector<cmLocalGenerator*>::const_iterator i = + this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) + { + std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles(); + for(std::vector<std::string>::const_iterator fi = lf.begin(); + fi != lf.end(); ++fi) + { + implicitDeps.push_back(ng->ConvertToNinjaPath(fi->c_str())); + } + } + implicitDeps.push_back("CMakeCache.txt"); + std::sort(implicitDeps.begin(), implicitDeps.end()); implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()), implicitDeps.end()); - implicitDeps.push_back("CMakeCache.txt"); this->WriteBuild(os, "Re-run CMake if any of its inputs changed.", diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 41714f6..ce36830 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -38,6 +38,10 @@ AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" ) +AddCMakeTest(FileDownloadBadHash "") +set_property(TEST CMake.FileDownloadBadHash PROPERTY + WILL_FAIL TRUE + ) AddCMakeTest(FileUpload "") diff --git a/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in b/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in new file mode 100644 index 0000000..4a47c06 --- /dev/null +++ b/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in @@ -0,0 +1,10 @@ +set(url "file://@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") +set(dir "@CMAKE_CURRENT_BINARY_DIR@/downloads") + +file(DOWNLOAD + ${url} + ${dir}/file3.png + TIMEOUT 2 + STATUS status + EXPECTED_HASH SHA1=5555555555555555555555555555555555555555 + ) diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index 91086c6..83ade2b 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -94,3 +94,16 @@ file(DOWNLOAD EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 ) message(STATUS "${status}") + +message(STATUS "FileDownload:11") +file(DOWNLOAD + badhostname.png + ${dir}/file11.png + TIMEOUT 2 + STATUS status + ) +message(STATUS "${status}") +list(GET status 0 status_code) +if(NOT ${status_code} EQUAL 6) + message(SEND_ERROR "error: expected status code 6 for bad host name, got: ${status_code}") +endif() diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index db4e08d..642a618 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -54,7 +54,9 @@ function(check_updates build) set(EXTRA "${UPDATE_XML_ENTRIES}") list(REMOVE_ITEM EXTRA ${ARGN} ${UPDATE_EXTRA} ${UPDATE_MAYBE}) set(MISSING "${ARGN}" ${UPDATE_EXTRA}) - list(REMOVE_ITEM MISSING ${UPDATE_XML_ENTRIES}) + if(NOT "" STREQUAL "${UPDATE_XML_ENTRIES}") + list(REMOVE_ITEM MISSING ${UPDATE_XML_ENTRIES}) + endif() if(NOT UPDATE_NOT_GLOBAL) set(rev_elements Revision PriorRevision ${UPDATE_GLOBAL_ELEMENTS}) |