summaryrefslogtreecommitdiffstats
path: root/Tests/Module
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-01-13 15:03:56 (GMT)
committerBrad King <brad.king@kitware.com>2015-01-15 15:48:09 (GMT)
commit0fe4d8bb3b9e8074f7efd95ae92fa32fe29a2c02 (patch)
tree57fe3394bf95b2c1ccf758d568cb366259006213 /Tests/Module
parent945571db747fd09036d0efd55b538dd4b3c8b874 (diff)
downloadCMake-0fe4d8bb3b9e8074f7efd95ae92fa32fe29a2c02.zip
CMake-0fe4d8bb3b9e8074f7efd95ae92fa32fe29a2c02.tar.gz
CMake-0fe4d8bb3b9e8074f7efd95ae92fa32fe29a2c02.tar.bz2
ExternalData: Add support for custom download scripts
Add support for a special URL template to map the fetch operation to a project-specified .cmake script insead of using file(DOWNLOAD). Extend the Module.ExternalData test to cover the behavior. Extend the RunCMake.ExternalData test to cover error cases.
Diffstat (limited to 'Tests/Module')
-rw-r--r--Tests/Module/ExternalData/CMakeLists.txt3
-rw-r--r--Tests/Module/ExternalData/Data1Check.cmake4
-rw-r--r--Tests/Module/ExternalData/DataScript.dat.md51
-rw-r--r--Tests/Module/ExternalData/MyScript1.cmake5
4 files changed, 13 insertions, 0 deletions
diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt
index ebca48e..f99f6af 100644
--- a/Tests/Module/ExternalData/CMakeLists.txt
+++ b/Tests/Module/ExternalData/CMakeLists.txt
@@ -10,7 +10,9 @@ if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
endif()
set(ExternalData_URL_TEMPLATES
"file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
+ "ExternalDataCustomScript://MyScript1/%(algo)/%(hash)"
)
+set(ExternalData_CUSTOM_SCRIPT_MyScript1 "${CMAKE_CURRENT_SOURCE_DIR}/MyScript1.cmake")
set(ExternalData_BINARY_ROOT "${CMAKE_CURRENT_BINARY_DIR}/ExternalData")
file(REMOVE_RECURSE ${ExternalData_BINARY_ROOT}) # clean test
@@ -23,6 +25,7 @@ ExternalData_Add_Test(Data1
COMMAND ${CMAKE_COMMAND}
-D Data=DATA{Data.dat}
${Data1CheckSpaces}
+ -D DataScript=DATA{DataScript.dat}
-D DataMissing=DATA{DataMissing.dat}
-D DataMissingWithAssociated=DATA{DataMissing.dat,Data.dat}
-D SeriesA=DATA{SeriesA.dat,:}
diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake
index 485b5c6..a7aa4ae 100644
--- a/Tests/Module/ExternalData/Data1Check.cmake
+++ b/Tests/Module/ExternalData/Data1Check.cmake
@@ -8,6 +8,10 @@ if(DEFINED DataSpace)
message(SEND_ERROR "Input file:\n ${DataSpace}\ndoes not have expected content, but [[${lines}]]")
endif()
endif()
+file(STRINGS "${DataScript}" lines LIMIT_INPUT 1024)
+if(NOT "x${lines}" STREQUAL "xDataScript")
+ message(SEND_ERROR "Input file:\n ${DataScript}\ndoes not have expected content, but [[${lines}]]")
+endif()
if(DataMissing)
if(EXISTS "${DataMissing}")
message(SEND_ERROR
diff --git a/Tests/Module/ExternalData/DataScript.dat.md5 b/Tests/Module/ExternalData/DataScript.dat.md5
new file mode 100644
index 0000000..74b4616
--- /dev/null
+++ b/Tests/Module/ExternalData/DataScript.dat.md5
@@ -0,0 +1 @@
+fd95c03719e8626c0d10a818f9996dc5
diff --git a/Tests/Module/ExternalData/MyScript1.cmake b/Tests/Module/ExternalData/MyScript1.cmake
new file mode 100644
index 0000000..242c64d
--- /dev/null
+++ b/Tests/Module/ExternalData/MyScript1.cmake
@@ -0,0 +1,5 @@
+if(ExternalData_CUSTOM_LOCATION STREQUAL "MD5/fd95c03719e8626c0d10a818f9996dc5")
+ file(WRITE "${ExternalData_CUSTOM_FILE}" "DataScript")
+else()
+ set(ExternalData_CUSTOM_ERROR "no ${ExternalData_CUSTOM_LOCATION} known")
+endif()