mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
Tests: Factor out common helper in RunCMake.file-DOWNLOAD cases
This commit is contained in:
15
Tests/RunCMake/file-DOWNLOAD/common.cmake
Normal file
15
Tests/RunCMake/file-DOWNLOAD/common.cmake
Normal file
@@ -0,0 +1,15 @@
|
||||
if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
|
||||
set(slash /)
|
||||
endif()
|
||||
set(url "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/input.png")
|
||||
set(file ${CMAKE_CURRENT_BINARY_DIR}/output.png)
|
||||
|
||||
function(file_download)
|
||||
file(DOWNLOAD "${url}"
|
||||
${file} # leave unquoted
|
||||
TIMEOUT 30
|
||||
STATUS status
|
||||
${ARGN}
|
||||
)
|
||||
message(STATUS "status='${status}'")
|
||||
endfunction()
|
||||
@@ -1,11 +1,11 @@
|
||||
^CMake Error at hash-mismatch.cmake:[0-9]+ \(file\):
|
||||
file DOWNLOAD HASH mismatch
|
||||
|
||||
for file: \[.*/Tests/RunCMake/file-DOWNLOAD/hash-mismatch-build/hash-mismatch.txt\]
|
||||
for file: \[.*/Tests/RunCMake/file-DOWNLOAD/hash-mismatch-build/output.png\]
|
||||
expected hash: \[0123456789abcdef0123456789abcdef01234567\]
|
||||
actual hash: \[da39a3ee5e6b4b0d3255bfef95601890afd80709\]
|
||||
actual hash: \[67eee17f79d9ac557284fc0b8ad19f25723fb578\]
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
+
|
||||
status='1;HASH mismatch: expected: 0123456789abcdef0123456789abcdef01234567 actual: da39a3ee5e6b4b0d3255bfef95601890afd80709'$
|
||||
status='1;HASH mismatch: expected: 0123456789abcdef0123456789abcdef01234567 actual: 67eee17f79d9ac557284fc0b8ad19f25723fb578'$
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
|
||||
set(slash /)
|
||||
endif()
|
||||
file(DOWNLOAD
|
||||
"file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/hash-mismatch.txt"
|
||||
${CMAKE_CURRENT_BINARY_DIR}/hash-mismatch.txt
|
||||
include(common.cmake)
|
||||
|
||||
file(DOWNLOAD ${url} ${file}
|
||||
EXPECTED_HASH SHA1=0123456789abcdef0123456789abcdef01234567
|
||||
TIMEOUT 30
|
||||
STATUS status
|
||||
)
|
||||
message("status='${status}'")
|
||||
|
||||
BIN
Tests/RunCMake/file-DOWNLOAD/input.png
Normal file
BIN
Tests/RunCMake/file-DOWNLOAD/input.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 194 B |
@@ -1,4 +1,5 @@
|
||||
^CMake Error at no-save-hash\.cmake:[0-9]+ \(file\):
|
||||
^CMake Error at common\.cmake:[0-9]+ \(file\):
|
||||
file DOWNLOAD cannot calculate hash if file is not saved\.
|
||||
Call Stack \(most recent call first\):
|
||||
no-save-hash.cmake:[0-9]+ \(file_download\)
|
||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
|
||||
set(slash /)
|
||||
endif()
|
||||
file(DOWNLOAD
|
||||
"file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/no-save-md5.txt"
|
||||
EXPECTED_HASH MD5=55555555555555555555555555555555
|
||||
STATUS status
|
||||
)
|
||||
include(common.cmake)
|
||||
|
||||
# Test downloading without saving to a file.
|
||||
set(file "")
|
||||
file_download(EXPECTED_HASH MD5=55555555555555555555555555555555)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
^CMake Warning \(dev\) at unused-argument.cmake:[0-9]+ \(file\):
|
||||
^CMake Warning \(dev\) at common.cmake:[0-9]+ \(file\):
|
||||
Unexpected argument: JUNK
|
||||
Call Stack \(most recent call first\):
|
||||
unused-argument.cmake:[0-9]+ \(file_download\)
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.$
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
|
||||
set(slash /)
|
||||
endif()
|
||||
file(DOWNLOAD
|
||||
"file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/unused-argument.txt"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/unused-argument.txt"
|
||||
JUNK
|
||||
)
|
||||
include(common.cmake)
|
||||
|
||||
file_download(JUNK)
|
||||
|
||||
Reference in New Issue
Block a user