ExternalData: Add support for custom algorithm-to-URL mapping

Allow URL templates to contain a %(algo:<key>) placeholder that is
replaced by mapping the canonical hash algorithm name through a map
defined by the <key>.

Extend the Module.ExternalData test to cover the behavior.
Extend the RunCMake.ExternalData test to cover error cases.
This commit is contained in:
Brad King
2015-02-25 08:11:39 -05:00
parent ac80f0f95f
commit f7f4ca55bd
15 changed files with 96 additions and 1 deletions

View File

@@ -0,0 +1 @@
DataAlgoMap

View File

@@ -0,0 +1 @@
DataAlgoMap

View File

@@ -10,8 +10,10 @@ if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
endif()
set(ExternalData_URL_TEMPLATES
"file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
"file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/Alt/%(algo:MyAlgoMap1)/%(hash)"
"ExternalDataCustomScript://MyScript1/%(algo)/%(hash)"
)
set(ExternalData_URL_ALGO_MD5_MyAlgoMap1 MyAlgoMap1-md5)
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
@@ -26,6 +28,8 @@ ExternalData_Add_Test(Data1
-D Data=DATA{Data.dat}
${Data1CheckSpaces}
-D DataScript=DATA{DataScript.dat}
-D DataAlgoMapA=DATA{DataAlgoMapA.dat}
-D DataAlgoMapB=DATA{DataAlgoMapB.dat}
-D DataMissing=DATA{DataMissing.dat}
-D DataMissingWithAssociated=DATA{DataMissing.dat,Data.dat}
-D SeriesA=DATA{SeriesA.dat,:}

View File

@@ -12,6 +12,14 @@ 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()
file(STRINGS "${DataAlgoMapA}" lines LIMIT_INPUT 1024)
if(NOT "x${lines}" STREQUAL "xDataAlgoMap")
message(SEND_ERROR "Input file:\n ${DataAlgoMapA}\ndoes not have expected content, but [[${lines}]]")
endif()
file(STRINGS "${DataAlgoMapB}" lines LIMIT_INPUT 1024)
if(NOT "x${lines}" STREQUAL "xDataAlgoMap")
message(SEND_ERROR "Input file:\n ${DataAlgoMapB}\ndoes not have expected content, but [[${lines}]]")
endif()
if(DataMissing)
if(EXISTS "${DataMissing}")
message(SEND_ERROR

View File

@@ -0,0 +1 @@
dded55e43cd6529ee35d24113dfc87a3

View File

@@ -0,0 +1 @@
85158f0c1996837976e858c42a9a7634bfe91b93