summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2010-05-27 16:21:56 (GMT)
committerDavid Cole <david.cole@kitware.com>2010-05-27 16:21:56 (GMT)
commitf67139ae6fdf964218a93e5506722a367e781c6f (patch)
tree2245faa382647a682ed2cfe41bc70331c706247e /Tests
parent282a119e355f86e20cc04fabd98083de2799c0ea (diff)
downloadCMake-f67139ae6fdf964218a93e5506722a367e781c6f.zip
CMake-f67139ae6fdf964218a93e5506722a367e781c6f.tar.gz
CMake-f67139ae6fdf964218a93e5506722a367e781c6f.tar.bz2
Improve FILE(DOWNLOAD) and ExternalProject.
Improve FILE(DOWNLOAD ...): - Add percent complete progress output to the FILE DOWNLOAD command. This progress output is off by default to preserve existing behavior. To turn it on, pass SHOW_PROGRESS as an argument. - Add EXPECTED_MD5 argument. Verify that the downloaded file has the expected md5 sum after download is complete. - Add documentation for SHOW_PROGRESS and EXPECTED_MD5. When the destination file exists already and has the expected md5 sum, then do not bother re-downloading the file. ("Short circuit" return.) Also, add a test that checks for the status output indicating that the short circuit behavior is actually occurring. Use a binary file for the test so that the md5 sum is guaranteed to be the same on all platforms regardless of "shifting text file line ending" issues. Improve ExternalProject: - Add argument URL_MD5. - Add verify step that compares md5 sum of .tar.gz file before extracting it. - Add md5 check to download step, too, to prevent unnecessary downloads. - Emit a warning message when a file is not verified. Indicate that the file may be corrupt or that no checksum was specified.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeTests/CMakeLists.txt5
-rw-r--r--Tests/CMakeTests/FileDownloadInput.pngbin0 -> 358 bytes
-rw-r--r--Tests/CMakeTests/FileDownloadTest.cmake.in41
-rw-r--r--Tests/ExternalProject/CMakeLists.txt8
4 files changed, 54 insertions, 0 deletions
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt
index 7a176e9..3e5f08c 100644
--- a/Tests/CMakeTests/CMakeLists.txt
+++ b/Tests/CMakeTests/CMakeLists.txt
@@ -28,6 +28,11 @@ AddCMakeTest(Math "")
AddCMakeTest(CMakeMinimumRequired "")
AddCMakeTest(CompilerIdVendor "")
+AddCMakeTest(FileDownload "")
+set_property(TEST CMake.FileDownload PROPERTY
+ PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum"
+ )
+
if(HAVE_ELF_H)
AddCMakeTest(ELF "")
endif()
diff --git a/Tests/CMakeTests/FileDownloadInput.png b/Tests/CMakeTests/FileDownloadInput.png
new file mode 100644
index 0000000..7bbcee4
--- /dev/null
+++ b/Tests/CMakeTests/FileDownloadInput.png
Binary files differ
diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in
new file mode 100644
index 0000000..578f510
--- /dev/null
+++ b/Tests/CMakeTests/FileDownloadTest.cmake.in
@@ -0,0 +1,41 @@
+set(url "file://@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png")
+set(dir "@CMAKE_CURRENT_BINARY_DIR@/downloads")
+
+message(STATUS "FileDownload:1")
+file(DOWNLOAD
+ ${url}
+ ${dir}/file1.png
+ TIMEOUT 2
+ )
+
+message(STATUS "FileDownload:2")
+file(DOWNLOAD
+ ${url}
+ ${dir}/file2.png
+ TIMEOUT 2
+ SHOW_PROGRESS
+ )
+
+# Two calls in a row, exactly the same arguments.
+# Since downloaded file should exist already for 2nd call,
+# the 2nd call will short-circuit and return early...
+#
+if(EXISTS ${dir}/file3.png)
+ file(REMOVE ${dir}/file3.png)
+endif()
+
+message(STATUS "FileDownload:3")
+file(DOWNLOAD
+ ${url}
+ ${dir}/file3.png
+ TIMEOUT 2
+ EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1
+ )
+
+message(STATUS "FileDownload:4")
+file(DOWNLOAD
+ ${url}
+ ${dir}/file3.png
+ TIMEOUT 2
+ EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1
+ )
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index f02f2f7..4ae04d3 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -65,7 +65,9 @@ ExternalProject_Add(${proj}
SVN_REPOSITORY ""
SVN_REVISION ""
TEST_COMMAND ""
+ TIMEOUT ""
URL ""
+ URL_MD5 ""
UPDATE_COMMAND ""
)
@@ -96,6 +98,7 @@ endif()
set(proj TutorialStep1-LocalTAR)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar"
+ URL_MD5 a87c5b47c0201c09ddfe1d5738fdb1e3
LIST_SEPARATOR ::
PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
@@ -107,6 +110,7 @@ ExternalProject_Add(${proj}
set(proj TutorialStep1-LocalNoDirTAR)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar"
+ URL_MD5 d09e3d370c5c908fa035c30939ee438e
LIST_SEPARATOR @@
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
-DTEST_LIST:STRING=1@@2@@3
@@ -126,6 +130,7 @@ ExternalProject_Add_Step(${proj} mypatch
set(proj TutorialStep1-LocalTGZ)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tgz"
+ URL_MD5 38c648e817339c356f6be00eeed79bd0
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
INSTALL_COMMAND ""
)
@@ -133,6 +138,7 @@ ExternalProject_Add(${proj}
set(proj TutorialStep1-LocalNoDirTGZ)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz"
+ URL_MD5 0b8182edcecdf40bf1c9d71d7d259f78
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
INSTALL_COMMAND ""
@@ -161,6 +167,7 @@ if(do_cvs_tests)
ExternalProject_Add(${proj}
SOURCE_DIR ${local_cvs_repo}
URL ${CMAKE_CURRENT_SOURCE_DIR}/cvsrepo.tgz
+ URL_MD5 55fc85825ffdd9ed2597123c68b79f7e
BUILD_COMMAND ""
CONFIGURE_COMMAND ${CVS_EXECUTABLE} --version
INSTALL_COMMAND ""
@@ -257,6 +264,7 @@ if(do_svn_tests)
ExternalProject_Add(${proj}
SOURCE_DIR ${local_svn_repo}
URL ${CMAKE_CURRENT_SOURCE_DIR}/svnrepo.tgz
+ URL_MD5 2f468be4ed1fa96377fca0cc830819c4
BUILD_COMMAND ""
CONFIGURE_COMMAND ${Subversion_SVN_EXECUTABLE} --version
INSTALL_COMMAND ""