summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2020-07-28 14:23:26 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-07-28 14:23:35 (GMT)
commit22bfe014d0a2676f46523b3e0cd334dba154f77a (patch)
treeb02240ea37123cd493db477f7a51b7569984d521 /Tests
parent261a2585d9df7113a5ba7c9beacb641754444523 (diff)
parentfed7d8f76de3442f4aede00f8e47c3d142f73e94 (diff)
downloadCMake-22bfe014d0a2676f46523b3e0cd334dba154f77a.zip
CMake-22bfe014d0a2676f46523b3e0cd334dba154f77a.tar.gz
CMake-22bfe014d0a2676f46523b3e0cd334dba154f77a.tar.bz2
Merge topic 'file-download-no-save'
fed7d8f76d file(DOWNLOAD): Make file argument optional Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5060
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeTests/CMakeLists.txt2
-rw-r--r--Tests/CMakeTests/FileDownloadTest.cmake.in13
-rw-r--r--Tests/CMakeTests/FileTestScript.cmake4
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt1
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt4
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake8
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt0
-rw-r--r--Tests/RunCMake/file/RunCMakeTest.cmake1
8 files changed, 30 insertions, 3 deletions
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt
index e32d693..348e6d0 100644
--- a/Tests/CMakeTests/CMakeLists.txt
+++ b/Tests/CMakeTests/CMakeLists.txt
@@ -35,7 +35,7 @@ AddCMakeTest(CMakeHostSystemInformation "")
AddCMakeTest(FileDownload "")
set_tests_properties(CMake.FileDownload PROPERTIES
PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum"
- FAIL_REGULAR_EXPRESSION "Unexpected status"
+ FAIL_REGULAR_EXPRESSION "Unexpected status|incorrectly interpreted"
)
AddCMakeTest(FileDownloadBadHash "")
set_property(TEST CMake.FileDownloadBadHash PROPERTY
diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in
index 76c0000..69d9a14 100644
--- a/Tests/CMakeTests/FileDownloadTest.cmake.in
+++ b/Tests/CMakeTests/FileDownloadTest.cmake.in
@@ -163,3 +163,16 @@ __reportIfWrongStatus("${status}" 0)
if(NOT EXISTS file12.png)
message(SEND_ERROR "file12.png not downloaded: ${status}")
endif()
+
+message(STATUS "FileDownload:13")
+file(DOWNLOAD
+ ${url}
+ TIMEOUT ${timeout}
+ STATUS status
+ )
+__reportIfWrongStatus("${status}" 0)
+if(EXISTS TIMEOUT)
+ file(REMOVE TIMEOUT)
+ message(SEND_ERROR "TIMEOUT argument was incorrectly interpreted as a filename")
+endif()
+message(STATUS "${status}")
diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake
index 145f28a..fc3c28a 100644
--- a/Tests/CMakeTests/FileTestScript.cmake
+++ b/Tests/CMakeTests/FileTestScript.cmake
@@ -10,7 +10,7 @@ elseif(testname STREQUAL different_not_enough_args) # fail
file(DIFFERENT ffff)
elseif(testname STREQUAL download_not_enough_args) # fail
- file(DOWNLOAD ffff)
+ file(DOWNLOAD)
elseif(testname STREQUAL read_not_enough_args) # fail
file(READ ffff)
@@ -181,7 +181,7 @@ elseif(testname STREQUAL to_native_path) # pass
message("v='${v}'")
elseif(testname STREQUAL download_wrong_number_of_args) # fail
- file(DOWNLOAD zzzz://bogus/ffff)
+ file(DOWNLOAD)
elseif(testname STREQUAL download_file_with_no_path) # pass
file(DOWNLOAD zzzz://bogus/ffff ffff)
diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt
new file mode 100644
index 0000000..b0f0d19
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at DOWNLOAD-no-save-hash\.cmake:[0-9]+ \(file\):
+ file DOWNLOAD cannot calculate hash if file is not saved\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake
new file mode 100644
index 0000000..ce959a7
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake
@@ -0,0 +1,8 @@
+if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
+ set(slash /)
+endif()
+file(DOWNLOAD
+ "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-no-save-md5.txt"
+ EXPECTED_HASH MD5=55555555555555555555555555555555
+ STATUS status
+ )
diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake
index a4de1d3..8d84943 100644
--- a/Tests/RunCMake/file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/file/RunCMakeTest.cmake
@@ -11,6 +11,7 @@ run_cmake(DOWNLOAD-netrc-bad)
run_cmake(DOWNLOAD-tls-cainfo-not-set)
run_cmake(DOWNLOAD-tls-verify-not-set)
run_cmake(DOWNLOAD-pass-not-set)
+run_cmake(DOWNLOAD-no-save-hash)
run_cmake(TOUCH)
run_cmake(TOUCH-error-in-source-directory)
run_cmake(TOUCH-error-missing-directory)