diff options
author | Brad King <brad.king@kitware.com> | 2022-11-17 21:59:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-11-18 14:02:15 (GMT) |
commit | 52b9c7b958a9e184ccfa023ad85cf8fde4308afd (patch) | |
tree | 11d08048ea4118a6723c2fed95b96a8ac18ab72f /Tests/RunCMake/file-DOWNLOAD | |
parent | 9dda7c276cb2b46f422c1b36e9d4c5aa09c2ff35 (diff) | |
download | CMake-52b9c7b958a9e184ccfa023ad85cf8fde4308afd.zip CMake-52b9c7b958a9e184ccfa023ad85cf8fde4308afd.tar.gz CMake-52b9c7b958a9e184ccfa023ad85cf8fde4308afd.tar.bz2 |
Tests: Move CMake.FileDownload cases into RunCMake.file-DOWNLOAD
The RunCMake infrastructure is more well-suited to check the results of
each case. It can also report more precisely what went wrong when a
case fails.
Diffstat (limited to 'Tests/RunCMake/file-DOWNLOAD')
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/EXPECTED_HASH-stdout.txt | 8 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/EXPECTED_HASH.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/SHOW_PROGRESS-stdout.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/SHOW_PROGRESS.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/bad-hostname-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/bad-hostname.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/basic-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/basic.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/file-without-path-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/file-without-path.cmake | 10 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/no-file-arg.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/no-file-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/no-file.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/range-stdout.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/range.cmake | 15 |
16 files changed, 106 insertions, 0 deletions
diff --git a/Tests/RunCMake/file-DOWNLOAD/EXPECTED_HASH-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/EXPECTED_HASH-stdout.txt new file mode 100644 index 0000000..bd1727a --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/EXPECTED_HASH-stdout.txt @@ -0,0 +1,8 @@ +-- status='0;"No error"' +-- status='0;"skipping download as file already exists with expected MD5 sum"' +-- status='0;"skipping download as file already exists with expected MD5 hash"' +-- status='0;"skipping download as file already exists with expected SHA1 hash"' +-- status='0;"skipping download as file already exists with expected SHA224 hash"' +-- status='0;"skipping download as file already exists with expected SHA256 hash"' +-- status='0;"skipping download as file already exists with expected SHA384 hash"' +-- status='0;"skipping download as file already exists with expected SHA512 hash"' diff --git a/Tests/RunCMake/file-DOWNLOAD/EXPECTED_HASH.cmake b/Tests/RunCMake/file-DOWNLOAD/EXPECTED_HASH.cmake new file mode 100644 index 0000000..dc7f8ff --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/EXPECTED_HASH.cmake @@ -0,0 +1,13 @@ +include(common.cmake) + +# Actually download the file and verify its hash. +file_download(EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92) + +# Verify that the local file already exists with expected hash. +file_download(EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92) +file_download(EXPECTED_HASH MD5=dbd330d52f4dbd60115d4191904ded92) +file_download(EXPECTED_HASH SHA1=67eee17f79d9ac557284fc0b8ad19f25723fb578) +file_download(EXPECTED_HASH SHA224=ba283726bbb602776818b463943189afd91836cb7ee5dd6e2c7b5ae4) +file_download(EXPECTED_HASH SHA256=cf3334b1275071e1da6e8c396ccb72cf1b2388d8c937526f3af26230affb9423) +file_download(EXPECTED_HASH SHA384=43a5d13978d97c660db44481aee0604cb4ff6ca0775cd5c2cd68cd8000e107e507c4caf6c228941231041e282ffb8950) +file_download(EXPECTED_HASH SHA512=6984e0909a1018030ccaa418e3be1654223cdccff0fe6adc745f9aea7e377f178be53b9fc7d54a6f81c2b62ef9ddcd38ba1978fedf4c5e7139baaf355eefad5b) diff --git a/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake b/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake index c800521..01da3fc 100644 --- a/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake +++ b/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake @@ -1,5 +1,10 @@ include(RunCMake) +# We do not contact any real URLs, but do try a bogus one. +# Remove any proxy configuration that may change behavior. +unset(ENV{http_proxy}) +unset(ENV{https_proxy}) + run_cmake(hash-mismatch) run_cmake(unused-argument) run_cmake(httpheader-not-set) @@ -8,3 +13,11 @@ run_cmake(tls-cainfo-not-set) run_cmake(tls-verify-not-set) run_cmake(pass-not-set) run_cmake(no-save-hash) + +run_cmake(bad-hostname) +run_cmake(basic) +run_cmake(EXPECTED_HASH) +run_cmake(file-without-path) +run_cmake(no-file) +run_cmake(range) +run_cmake(SHOW_PROGRESS) diff --git a/Tests/RunCMake/file-DOWNLOAD/SHOW_PROGRESS-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/SHOW_PROGRESS-stdout.txt new file mode 100644 index 0000000..e0a4982 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/SHOW_PROGRESS-stdout.txt @@ -0,0 +1,2 @@ +-- \[download 100% complete\] +-- status='0;"No error"' diff --git a/Tests/RunCMake/file-DOWNLOAD/SHOW_PROGRESS.cmake b/Tests/RunCMake/file-DOWNLOAD/SHOW_PROGRESS.cmake new file mode 100644 index 0000000..ccabced --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/SHOW_PROGRESS.cmake @@ -0,0 +1,3 @@ +include(common.cmake) + +file_download(SHOW_PROGRESS) diff --git a/Tests/RunCMake/file-DOWNLOAD/bad-hostname-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/bad-hostname-stdout.txt new file mode 100644 index 0000000..12278e0 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/bad-hostname-stdout.txt @@ -0,0 +1 @@ +-- status='6;"Couldn't resolve host name"' diff --git a/Tests/RunCMake/file-DOWNLOAD/bad-hostname.cmake b/Tests/RunCMake/file-DOWNLOAD/bad-hostname.cmake new file mode 100644 index 0000000..d3b7a28 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/bad-hostname.cmake @@ -0,0 +1,9 @@ +include(common.cmake) + +# Do not use any proxy for lookup of an invalid site. +# DNS failure by proxy looks different than DNS failure without proxy. +set(ENV{no_proxy} "$ENV{no_proxy},badhostname.invalid") + +set(url "badhostname.invalid") + +file_download() diff --git a/Tests/RunCMake/file-DOWNLOAD/basic-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/basic-stdout.txt new file mode 100644 index 0000000..701e995 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/basic-stdout.txt @@ -0,0 +1 @@ +-- status='0;"No error"' diff --git a/Tests/RunCMake/file-DOWNLOAD/basic.cmake b/Tests/RunCMake/file-DOWNLOAD/basic.cmake new file mode 100644 index 0000000..1fd931c --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/basic.cmake @@ -0,0 +1,3 @@ +include(common.cmake) + +file_download() diff --git a/Tests/RunCMake/file-DOWNLOAD/file-without-path-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/file-without-path-stdout.txt new file mode 100644 index 0000000..701e995 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/file-without-path-stdout.txt @@ -0,0 +1 @@ +-- status='0;"No error"' diff --git a/Tests/RunCMake/file-DOWNLOAD/file-without-path.cmake b/Tests/RunCMake/file-DOWNLOAD/file-without-path.cmake new file mode 100644 index 0000000..a628423 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/file-without-path.cmake @@ -0,0 +1,10 @@ +include(common.cmake) + +set(file_orig "${file}") +cmake_path(GET file_orig FILENAME file) + +file_download() + +if(NOT EXISTS "${file_orig}") + message(FATAL_ERROR "file not downloaded to expected path:\n ${file_orig}") +endif() diff --git a/Tests/RunCMake/file-DOWNLOAD/no-file-arg.cmake b/Tests/RunCMake/file-DOWNLOAD/no-file-arg.cmake new file mode 100644 index 0000000..6520940 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/no-file-arg.cmake @@ -0,0 +1,11 @@ +include(common.cmake) + +set(file "") + +file_download() + +set(file "${CMAKE_CURRENT_BINARY_DIR}/input.png") + +if(NOT EXISTS "${file}") + message(FATAL_ERROR "file not downloaded to expected path:\n ${file}") +endif() diff --git a/Tests/RunCMake/file-DOWNLOAD/no-file-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/no-file-stdout.txt new file mode 100644 index 0000000..701e995 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/no-file-stdout.txt @@ -0,0 +1 @@ +-- status='0;"No error"' diff --git a/Tests/RunCMake/file-DOWNLOAD/no-file.cmake b/Tests/RunCMake/file-DOWNLOAD/no-file.cmake new file mode 100644 index 0000000..dc234b2 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/no-file.cmake @@ -0,0 +1,11 @@ +include(common.cmake) + +# Test downloading without saving to a file. +set(file "") +file_download() + +foreach(name input.png output.png TIMEOUT) + if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${name}") + message(FATAL_ERROR "file incorrectly saved to:\n ${CMAKE_CURRENT_BINARY_DIR}/${name}") + endif() +endforeach() diff --git a/Tests/RunCMake/file-DOWNLOAD/range-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/range-stdout.txt new file mode 100644 index 0000000..e2ed7aa --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/range-stdout.txt @@ -0,0 +1,4 @@ +-- status='0;"No error"' +-- status='0;"No error"' +-- status='0;"No error"' +-- status='0;"No error"' diff --git a/Tests/RunCMake/file-DOWNLOAD/range.cmake b/Tests/RunCMake/file-DOWNLOAD/range.cmake new file mode 100644 index 0000000..f77bb28 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/range.cmake @@ -0,0 +1,15 @@ +include(common.cmake) + +set(file ${CMAKE_CURRENT_BINARY_DIR}/output1.png) +file_download(RANGE_START 0 EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92) + +set(file ${CMAKE_CURRENT_BINARY_DIR}/output2.png) +file_download(RANGE_END 50 EXPECTED_MD5 8592e5665b839b5d23825dc84c135b61) + +set(file ${CMAKE_CURRENT_BINARY_DIR}/output3.png) +file_download(RANGE_START 10 RANGE_END 50 EXPECTED_MD5 36cd52681e6c6c8fef85fcd9e86fc30d) + +set(file ${CMAKE_CURRENT_BINARY_DIR}/output4.png) +file_download(RANGE_START 0 RANGE_END 50 + RANGE_START 60 RANGE_END 100 + EXPECTED_MD5 c5c9e74e82d493dd901eecccd659cebc) |