summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-01-25 16:39:57 -0500
committerBrad King <brad.king@kitware.com>2013-01-30 10:04:54 -0500
commit4befecc77caa97aeb450d9a2b6bcbe0985dc4054 (patch)
tree466fb00e26d9db362d64b530bc7bda952106e3d8
parentbcd25808ac540d279a36a9e0f1b60f152fc0d6bb (diff)
downloadcmake-4befecc77caa97aeb450d9a2b6bcbe0985dc4054.tar.gz
ExternalData: Add tests covering interfaces and errors
Add a Module.ExternalData test to verify data retrieval and test argument DATA{} references. Add a RunCMake.ExternalData test to verify error handling and automatic transformation of a raw data to a content link and staged object.
-rw-r--r--Tests/CMakeLists.txt12
-rw-r--r--Tests/Module/ExternalData/CMakeLists.txt32
-rw-r--r--Tests/Module/ExternalData/Data.dat.md51
-rw-r--r--Tests/Module/ExternalData/Data1Check.cmake40
-rw-r--r--Tests/Module/ExternalData/Data2.dat.md51
-rw-r--r--Tests/Module/ExternalData/Data2/CMakeLists.txt10
-rw-r--r--Tests/Module/ExternalData/Data2/Data2Check.cmake9
-rw-r--r--Tests/Module/ExternalData/Data2/SeriesC_1_.my.dat.md51
-rw-r--r--Tests/Module/ExternalData/Data2/SeriesC_2_.my.dat.md51
-rw-r--r--Tests/Module/ExternalData/Data2/SeriesC_3_.my.dat.md51
-rw-r--r--Tests/Module/ExternalData/Data3/CMakeLists.txt14
-rw-r--r--Tests/Module/ExternalData/Data3/Data.dat.md51
-rw-r--r--Tests/Module/ExternalData/Data3/Data3Check.cmake25
-rw-r--r--Tests/Module/ExternalData/Data3/Other.dat.md51
-rw-r--r--Tests/Module/ExternalData/MD5/.gitattributes1
-rw-r--r--Tests/Module/ExternalData/MD5/08cfcf221f76ace7b906b312284e73d71
-rw-r--r--Tests/Module/ExternalData/MD5/30ba0acdee9096b3b9fc6c69362c6b421
-rw-r--r--Tests/Module/ExternalData/MD5/31eff09e84fca01415f8cd9d82ec432b1
-rw-r--r--Tests/Module/ExternalData/MD5/401767f22a456b3522953722090a2c361
-rw-r--r--Tests/Module/ExternalData/MD5/8c018830e3efa5caf3c7415028335a571
-rw-r--r--Tests/Module/ExternalData/MD5/8f4add4581551facf27237e6577fd6621
-rw-r--r--Tests/Module/ExternalData/MD5/9d980b06c2f0fec3d4872d68175b98221
-rw-r--r--Tests/Module/ExternalData/MD5/aaad162b85f60d1eb57ca71a23e8efd71
-rw-r--r--Tests/Module/ExternalData/MD5/c1030719c95f3435d8abc39c0d4429461
-rw-r--r--Tests/Module/ExternalData/MD5/ecfa1ecd417d4253af81ae04d1bd65811
-rw-r--r--Tests/Module/ExternalData/MD5/f41c94425d01ecbbee70440b951cb0581
-rw-r--r--Tests/Module/ExternalData/MD5/f7ab5a04aae9cb9a520e70b20b9c8ed71
-rw-r--r--Tests/Module/ExternalData/MetaA.dat.md51
-rw-r--r--Tests/Module/ExternalData/MetaB.dat.md51
-rw-r--r--Tests/Module/ExternalData/MetaC.dat.md51
-rw-r--r--Tests/Module/ExternalData/MetaTop.dat.md51
-rw-r--r--Tests/Module/ExternalData/PairedA.dat.md51
-rw-r--r--Tests/Module/ExternalData/PairedB.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesA.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesA1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesA2.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesA3.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesAn1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesAn2.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesAn3.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesB.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesB_1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesB_2.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesB_3.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesBn_1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesBn_2.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesBn_3.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesC.1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesC.2.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesC.3.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesC.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesCn.1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesCn.2.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesCn.3.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesD-1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesD-2.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesD-3.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesD.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesDn-1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesDn-2.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesDn-3.dat.md51
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/ExternalData/BadHashAlgo1-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt8
-rw-r--r--Tests/RunCMake/ExternalData/BadHashAlgo1.cmake3
-rw-r--r--Tests/RunCMake/ExternalData/BadHashAlgo1.txt1
-rw-r--r--Tests/RunCMake/ExternalData/BadOption1-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/BadOption1-stderr.txt9
-rw-r--r--Tests/RunCMake/ExternalData/BadOption1.cmake5
-rw-r--r--Tests/RunCMake/ExternalData/BadOption2-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/BadOption2-stderr.txt9
-rw-r--r--Tests/RunCMake/ExternalData/BadOption2.cmake5
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries1-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries1-stderr.txt19
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries1.cmake3
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries2-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries2-stderr.txt16
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries2.cmake3
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries3-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries3-stderr.txt6
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries3.cmake2
-rw-r--r--Tests/RunCMake/ExternalData/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/ExternalData/Data.txt.md51
-rw-r--r--Tests/RunCMake/ExternalData/Directory1-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/Directory1-stderr.txt14
-rw-r--r--Tests/RunCMake/ExternalData/Directory1.cmake6
-rw-r--r--Tests/RunCMake/ExternalData/Directory1/DirData1.txt0
-rw-r--r--Tests/RunCMake/ExternalData/Directory2-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/Directory2-stderr.txt10
-rw-r--r--Tests/RunCMake/ExternalData/Directory2.cmake6
-rw-r--r--Tests/RunCMake/ExternalData/Directory2.md51
-rw-r--r--Tests/RunCMake/ExternalData/Directory2/DirData2.txt0
-rw-r--r--Tests/RunCMake/ExternalData/Directory3-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/Directory3-stderr.txt14
-rw-r--r--Tests/RunCMake/ExternalData/Directory3.cmake6
-rw-r--r--Tests/RunCMake/ExternalData/Directory3/DirData3.txt0
-rw-r--r--Tests/RunCMake/ExternalData/LinkContentMD5-stdout.txt3
-rw-r--r--Tests/RunCMake/ExternalData/LinkContentMD5.cmake22
-rw-r--r--Tests/RunCMake/ExternalData/MissingData-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/MissingData-stderr.txt14
-rw-r--r--Tests/RunCMake/ExternalData/MissingData.cmake5
-rw-r--r--Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt6
-rw-r--r--Tests/RunCMake/ExternalData/NoLinkInSource-stdout.txt1
-rw-r--r--Tests/RunCMake/ExternalData/NoLinkInSource.cmake14
-rw-r--r--Tests/RunCMake/ExternalData/NoURLTemplates-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt5
-rw-r--r--Tests/RunCMake/ExternalData/NoURLTemplates.cmake2
-rw-r--r--Tests/RunCMake/ExternalData/NormalData1-stdout.txt1
-rw-r--r--Tests/RunCMake/ExternalData/NormalData1.cmake13
-rw-r--r--Tests/RunCMake/ExternalData/NormalData2-stdout.txt1
-rw-r--r--Tests/RunCMake/ExternalData/NormalData2.cmake14
-rw-r--r--Tests/RunCMake/ExternalData/NormalData3-stdout.txt1
-rw-r--r--Tests/RunCMake/ExternalData/NormalData3.cmake14
-rw-r--r--Tests/RunCMake/ExternalData/NormalDataSub1-stdout.txt1
-rw-r--r--Tests/RunCMake/ExternalData/NormalDataSub1.cmake13
-rw-r--r--Tests/RunCMake/ExternalData/NotUnderRoot-result.txt1
-rw-r--r--Tests/RunCMake/ExternalData/NotUnderRoot-stderr.txt12
-rw-r--r--Tests/RunCMake/ExternalData/NotUnderRoot.cmake5
-rw-r--r--Tests/RunCMake/ExternalData/RunCMakeTest.cmake21
-rw-r--r--Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt2
-rw-r--r--Tests/RunCMake/ExternalData/SubDirectory1.cmake5
-rw-r--r--Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt19
-rw-r--r--Tests/RunCMake/ExternalData/SubDirectory1/Data.txt.md51
123 files changed, 554 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 0c75892384..c21922e65c 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -312,6 +312,18 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)
+ add_test(Module.ExternalData ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/Module/ExternalData"
+ "${CMake_BINARY_DIR}/Tests/Module/ExternalData"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-project ExternalDataTest
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --force-new-ctest-process
+ --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
+
ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader)
if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt
new file mode 100644
index 0000000000..55326100d5
--- /dev/null
+++ b/Tests/Module/ExternalData/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 2.8.10.20130115)
+project(ExternalDataTest NONE)
+
+include(CTest)
+
+include(ExternalData)
+set(ExternalData_URL_TEMPLATES
+ "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
+ )
+set(ExternalData_BINARY_ROOT "${CMAKE_CURRENT_BINARY_DIR}/ExternalData")
+file(REMOVE_RECURSE ${ExternalData_BINARY_ROOT}) # clean test
+
+ExternalData_Add_Test(Data1
+ NAME Data1Check
+ COMMAND ${CMAKE_COMMAND}
+ -D Data=DATA{Data.dat}
+ -D SeriesA=DATA{SeriesA.dat,:}
+ -D SeriesB=DATA{SeriesB.dat,:}
+ -D SeriesC=DATA{SeriesC.dat,:}
+ -D SeriesD=DATA{SeriesD.dat,:}
+ -D SeriesAn=DATA{SeriesAn1.dat,:}
+ -D SeriesBn=DATA{SeriesBn_1.dat,:}
+ -D SeriesCn=DATA{SeriesCn.1.dat,:}
+ -D SeriesDn=DATA{SeriesDn-1.dat,:}
+ -D Paired=DATA{PairedA.dat,PairedB.dat}
+ -D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/Data1Check.cmake
+ )
+ExternalData_Add_Target(Data1)
+
+add_subdirectory(Data2)
+add_subdirectory(Data3)
diff --git a/Tests/Module/ExternalData/Data.dat.md5 b/Tests/Module/ExternalData/Data.dat.md5
new file mode 100644
index 0000000000..70e39bd5d1
--- /dev/null
+++ b/Tests/Module/ExternalData/Data.dat.md5
@@ -0,0 +1 @@
+8c018830e3efa5caf3c7415028335a57
diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake
new file mode 100644
index 0000000000..fd18cdf5fd
--- /dev/null
+++ b/Tests/Module/ExternalData/Data1Check.cmake
@@ -0,0 +1,40 @@
+file(STRINGS "${Data}" lines LIMIT_INPUT 1024)
+if(NOT "x${lines}" STREQUAL "xInput file already transformed.")
+ message(SEND_ERROR "Input file:\n ${Data}\ndoes not have expected content, but [[${lines}]]")
+endif()
+set(SeriesAn1 "1\\.dat")
+set(SeriesBn1 "_1\\.dat")
+set(SeriesCn1 "\\.1\\.dat")
+set(SeriesDn1 "-1\\.dat")
+set(SeriesAl 1 2 3)
+set(SeriesBl _1 _2 _3)
+set(SeriesCl .1 .2 .3)
+set(SeriesDl -1 -2 -3)
+foreach(s A B C D)
+ foreach(n "" ${Series${s}l})
+ string(REGEX REPLACE "\\.dat$" "${n}.dat" file "${Series${s}}")
+ if(NOT EXISTS "${file}")
+ message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
+ endif()
+ endforeach()
+endforeach()
+foreach(s A B C D)
+ foreach(n ${Series${s}l})
+ string(REGEX REPLACE "${Series${s}n1}$" "${n}.dat" file "${Series${s}n}")
+ if(NOT EXISTS "${file}")
+ message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
+ endif()
+ endforeach()
+endforeach()
+foreach(n A B)
+ string(REGEX REPLACE "A\\.dat$" "${n}.dat" file "${Paired}")
+ if(NOT EXISTS "${file}")
+ message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
+ endif()
+endforeach()
+foreach(n Top A B C)
+ string(REGEX REPLACE "Top\\.dat$" "${n}.dat" file "${Meta}")
+ if(NOT EXISTS "${file}")
+ message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
+ endif()
+endforeach()
diff --git a/Tests/Module/ExternalData/Data2.dat.md5 b/Tests/Module/ExternalData/Data2.dat.md5
new file mode 100644
index 0000000000..70e39bd5d1
--- /dev/null
+++ b/Tests/Module/ExternalData/Data2.dat.md5
@@ -0,0 +1 @@
+8c018830e3efa5caf3c7415028335a57
diff --git a/Tests/Module/ExternalData/Data2/CMakeLists.txt b/Tests/Module/ExternalData/Data2/CMakeLists.txt
new file mode 100644
index 0000000000..f8eedff642
--- /dev/null
+++ b/Tests/Module/ExternalData/Data2/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(ExternalData_SERIES_PARSE "([0-9]+)(_\\.my\\.dat)$")
+set(ExternalData_SERIES_MATCH "[0-9]+")
+ExternalData_Add_Test(Data2
+ NAME Data2Check
+ COMMAND ${CMAKE_COMMAND}
+ -D Data2=DATA{../Data2.dat}
+ -D SeriesC=DATA{SeriesC_1_.my.dat,:}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/Data2Check.cmake
+ )
+ExternalData_Add_Target(Data2)
diff --git a/Tests/Module/ExternalData/Data2/Data2Check.cmake b/Tests/Module/ExternalData/Data2/Data2Check.cmake
new file mode 100644
index 0000000000..a1dd5091d1
--- /dev/null
+++ b/Tests/Module/ExternalData/Data2/Data2Check.cmake
@@ -0,0 +1,9 @@
+if(NOT EXISTS "${Data2}")
+ message(SEND_ERROR "Input file:\n ${Data2}\ndoes not exist!")
+endif()
+foreach(n 1 2 3)
+ string(REGEX REPLACE "_1_\\.my\\.dat$" "_${n}_.my.dat" SeriesCFile "${SeriesC}")
+ if(NOT EXISTS "${SeriesCFile}")
+ message(SEND_ERROR "Input file:\n ${SeriesCFile}\ndoes not exist!")
+ endif()
+endforeach()
diff --git a/Tests/Module/ExternalData/Data2/SeriesC_1_.my.dat.md5 b/Tests/Module/ExternalData/Data2/SeriesC_1_.my.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/Data2/SeriesC_1_.my.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/Data2/SeriesC_2_.my.dat.md5 b/Tests/Module/ExternalData/Data2/SeriesC_2_.my.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/Data2/SeriesC_2_.my.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/Data2/SeriesC_3_.my.dat.md5 b/Tests/Module/ExternalData/Data2/SeriesC_3_.my.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/Data2/SeriesC_3_.my.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/Module/ExternalData/Data3/CMakeLists.txt b/Tests/Module/ExternalData/Data3/CMakeLists.txt
new file mode 100644
index 0000000000..a7c2b6e068
--- /dev/null
+++ b/Tests/Module/ExternalData/Data3/CMakeLists.txt
@@ -0,0 +1,14 @@
+set(Store0 ${CMAKE_BINARY_DIR}/ExternalData/Other)
+set(Store1 ${CMAKE_BINARY_DIR}/ExternalData/Objects)
+set(ExternalData_OBJECT_STORES ${Store0} ${Store1})
+ExternalData_Add_Test(Data3
+ NAME Data3Check
+ COMMAND ${CMAKE_COMMAND}
+ -D Data=DATA{Data.dat}
+ -D Other=DATA{Other.dat}
+ -D Store0=${Store0}
+ -D Store1=${Store1}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/Data3Check.cmake
+ )
+ExternalData_Add_Target(Data3)
+add_dependencies(Data3 Data1 Data2)
diff --git a/Tests/Module/ExternalData/Data3/Data.dat.md5 b/Tests/Module/ExternalData/Data3/Data.dat.md5
new file mode 100644
index 0000000000..70e39bd5d1
--- /dev/null
+++ b/Tests/Module/ExternalData/Data3/Data.dat.md5
@@ -0,0 +1 @@
+8c018830e3efa5caf3c7415028335a57
diff --git a/Tests/Module/ExternalData/Data3/Data3Check.cmake b/Tests/Module/ExternalData/Data3/Data3Check.cmake
new file mode 100644
index 0000000000..de9883948d
--- /dev/null
+++ b/Tests/Module/ExternalData/Data3/Data3Check.cmake
@@ -0,0 +1,25 @@
+if(NOT EXISTS "${Data}")
+ message(SEND_ERROR "Input file:\n ${Data}\ndoes not exist!")
+endif()
+if(NOT EXISTS "${Other}")
+ message(SEND_ERROR "Input file:\n ${Other}\ndoes not exist!")
+endif()
+# Verify that the 'Data' object was found in the second store location left
+# from Data1 target downloads and that the 'Other' object was downloaded to
+# our first store location. Neither object should exist in the other store.
+foreach(should_exist
+ "${Store0}/MD5/aaad162b85f60d1eb57ca71a23e8efd7"
+ "${Store1}/MD5/8c018830e3efa5caf3c7415028335a57"
+ )
+ if(NOT EXISTS ${should_exist})
+ message(SEND_ERROR "Store file:\n ${should_exist}\nshould exist!")
+ endif()
+endforeach()
+foreach(should_not_exist
+ "${Store0}/MD5/8c018830e3efa5caf3c7415028335a57"
+ "${Store1}/MD5/aaad162b85f60d1eb57ca71a23e8efd7"
+ )
+ if(EXISTS ${should_not_exist})
+ message(SEND_ERROR "Store file:\n ${should_not_exist}\nshould not exist!")
+ endif()
+endforeach()
diff --git a/Tests/Module/ExternalData/Data3/Other.dat.md5 b/Tests/Module/ExternalData/Data3/Other.dat.md5
new file mode 100644
index 0000000000..5312faac0a
--- /dev/null
+++ b/Tests/Module/ExternalData/Data3/Other.dat.md5
@@ -0,0 +1 @@
+aaad162b85f60d1eb57ca71a23e8efd7
diff --git a/Tests/Module/ExternalData/MD5/.gitattributes b/Tests/Module/ExternalData/MD5/.gitattributes
new file mode 100644
index 0000000000..3e51d39dba
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/.gitattributes
@@ -0,0 +1 @@
+* -crlf
diff --git a/Tests/Module/ExternalData/MD5/08cfcf221f76ace7b906b312284e73d7 b/Tests/Module/ExternalData/MD5/08cfcf221f76ace7b906b312284e73d7
new file mode 100644
index 0000000000..a689e3cc49
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/08cfcf221f76ace7b906b312284e73d7
@@ -0,0 +1 @@
+MetaTop
diff --git a/Tests/Module/ExternalData/MD5/30ba0acdee9096b3b9fc6c69362c6b42 b/Tests/Module/ExternalData/MD5/30ba0acdee9096b3b9fc6c69362c6b42
new file mode 100644
index 0000000000..5491241b0b
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/30ba0acdee9096b3b9fc6c69362c6b42
@@ -0,0 +1 @@
+Series.3
diff --git a/Tests/Module/ExternalData/MD5/31eff09e84fca01415f8cd9d82ec432b b/Tests/Module/ExternalData/MD5/31eff09e84fca01415f8cd9d82ec432b
new file mode 100644
index 0000000000..4d0475e228
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/31eff09e84fca01415f8cd9d82ec432b
@@ -0,0 +1 @@
+Series.1
diff --git a/Tests/Module/ExternalData/MD5/401767f22a456b3522953722090a2c36 b/Tests/Module/ExternalData/MD5/401767f22a456b3522953722090a2c36
new file mode 100644
index 0000000000..9dec116617
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/401767f22a456b3522953722090a2c36
@@ -0,0 +1 @@
+PairedA
diff --git a/Tests/Module/ExternalData/MD5/8c018830e3efa5caf3c7415028335a57 b/Tests/Module/ExternalData/MD5/8c018830e3efa5caf3c7415028335a57
new file mode 100644
index 0000000000..fa701e21bb
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/8c018830e3efa5caf3c7415028335a57
@@ -0,0 +1 @@
+Input file already transformed.
diff --git a/Tests/Module/ExternalData/MD5/8f4add4581551facf27237e6577fd662 b/Tests/Module/ExternalData/MD5/8f4add4581551facf27237e6577fd662
new file mode 100644
index 0000000000..69ba09c86c
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/8f4add4581551facf27237e6577fd662
@@ -0,0 +1 @@
+MetaB
diff --git a/Tests/Module/ExternalData/MD5/9d980b06c2f0fec3d4872d68175b9822 b/Tests/Module/ExternalData/MD5/9d980b06c2f0fec3d4872d68175b9822
new file mode 100644
index 0000000000..000e7b2bf3
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/9d980b06c2f0fec3d4872d68175b9822
@@ -0,0 +1 @@
+MetaA
diff --git a/Tests/Module/ExternalData/MD5/aaad162b85f60d1eb57ca71a23e8efd7 b/Tests/Module/ExternalData/MD5/aaad162b85f60d1eb57ca71a23e8efd7
new file mode 100644
index 0000000000..df0510c3c0
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/aaad162b85f60d1eb57ca71a23e8efd7
@@ -0,0 +1 @@
+Another input file already transformed.
diff --git a/Tests/Module/ExternalData/MD5/c1030719c95f3435d8abc39c0d442946 b/Tests/Module/ExternalData/MD5/c1030719c95f3435d8abc39c0d442946
new file mode 100644
index 0000000000..3fac5e63d3
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/c1030719c95f3435d8abc39c0d442946
@@ -0,0 +1 @@
+MetaC
diff --git a/Tests/Module/ExternalData/MD5/ecfa1ecd417d4253af81ae04d1bd6581 b/Tests/Module/ExternalData/MD5/ecfa1ecd417d4253af81ae04d1bd6581
new file mode 100644
index 0000000000..8c414f53bf
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/ecfa1ecd417d4253af81ae04d1bd6581
@@ -0,0 +1 @@
+PairedB
diff --git a/Tests/Module/ExternalData/MD5/f41c94425d01ecbbee70440b951cb058 b/Tests/Module/ExternalData/MD5/f41c94425d01ecbbee70440b951cb058
new file mode 100644
index 0000000000..3503da4f28
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/f41c94425d01ecbbee70440b951cb058
@@ -0,0 +1 @@
+Series
diff --git a/Tests/Module/ExternalData/MD5/f7ab5a04aae9cb9a520e70b20b9c8ed7 b/Tests/Module/ExternalData/MD5/f7ab5a04aae9cb9a520e70b20b9c8ed7
new file mode 100644
index 0000000000..29d727b8fe
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/f7ab5a04aae9cb9a520e70b20b9c8ed7
@@ -0,0 +1 @@
+Series.2
diff --git a/Tests/Module/ExternalData/MetaA.dat.md5 b/Tests/Module/ExternalData/MetaA.dat.md5
new file mode 100644
index 0000000000..4a78fc7834
--- /dev/null
+++ b/Tests/Module/ExternalData/MetaA.dat.md5
@@ -0,0 +1 @@
+9d980b06c2f0fec3d4872d68175b9822
diff --git a/Tests/Module/ExternalData/MetaB.dat.md5 b/Tests/Module/ExternalData/MetaB.dat.md5
new file mode 100644
index 0000000000..4557a216ad
--- /dev/null
+++ b/Tests/Module/ExternalData/MetaB.dat.md5
@@ -0,0 +1 @@
+8f4add4581551facf27237e6577fd662
diff --git a/Tests/Module/ExternalData/MetaC.dat.md5 b/Tests/Module/ExternalData/MetaC.dat.md5
new file mode 100644
index 0000000000..a7f23dd7fe
--- /dev/null
+++ b/Tests/Module/ExternalData/MetaC.dat.md5
@@ -0,0 +1 @@
+c1030719c95f3435d8abc39c0d442946
diff --git a/Tests/Module/ExternalData/MetaTop.dat.md5 b/Tests/Module/ExternalData/MetaTop.dat.md5
new file mode 100644
index 0000000000..1906cbf7ff
--- /dev/null
+++ b/Tests/Module/ExternalData/MetaTop.dat.md5
@@ -0,0 +1 @@
+08cfcf221f76ace7b906b312284e73d7
diff --git a/Tests/Module/ExternalData/PairedA.dat.md5 b/Tests/Module/ExternalData/PairedA.dat.md5
new file mode 100644
index 0000000000..1ffe035e03
--- /dev/null
+++ b/Tests/Module/ExternalData/PairedA.dat.md5
@@ -0,0 +1 @@
+401767f22a456b3522953722090a2c36
diff --git a/Tests/Module/ExternalData/PairedB.dat.md5 b/Tests/Module/ExternalData/PairedB.dat.md5
new file mode 100644
index 0000000000..89c942b636
--- /dev/null
+++ b/Tests/Module/ExternalData/PairedB.dat.md5
@@ -0,0 +1 @@
+ecfa1ecd417d4253af81ae04d1bd6581
diff --git a/Tests/Module/ExternalData/SeriesA.dat.md5 b/Tests/Module/ExternalData/SeriesA.dat.md5
new file mode 100644
index 0000000000..be2d6878b0
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesA.dat.md5
@@ -0,0 +1 @@
+f41c94425d01ecbbee70440b951cb058
diff --git a/Tests/Module/ExternalData/SeriesA1.dat.md5 b/Tests/Module/ExternalData/SeriesA1.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesA1.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/SeriesA2.dat.md5 b/Tests/Module/ExternalData/SeriesA2.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesA2.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/SeriesA3.dat.md5 b/Tests/Module/ExternalData/SeriesA3.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesA3.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/Module/ExternalData/SeriesAn1.dat.md5 b/Tests/Module/ExternalData/SeriesAn1.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesAn1.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/SeriesAn2.dat.md5 b/Tests/Module/ExternalData/SeriesAn2.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesAn2.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/SeriesAn3.dat.md5 b/Tests/Module/ExternalData/SeriesAn3.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesAn3.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/Module/ExternalData/SeriesB.dat.md5 b/Tests/Module/ExternalData/SeriesB.dat.md5
new file mode 100644
index 0000000000..be2d6878b0
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesB.dat.md5
@@ -0,0 +1 @@
+f41c94425d01ecbbee70440b951cb058
diff --git a/Tests/Module/ExternalData/SeriesB_1.dat.md5 b/Tests/Module/ExternalData/SeriesB_1.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesB_1.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/SeriesB_2.dat.md5 b/Tests/Module/ExternalData/SeriesB_2.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesB_2.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/SeriesB_3.dat.md5 b/Tests/Module/ExternalData/SeriesB_3.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesB_3.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/Module/ExternalData/SeriesBn_1.dat.md5 b/Tests/Module/ExternalData/SeriesBn_1.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesBn_1.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/SeriesBn_2.dat.md5 b/Tests/Module/ExternalData/SeriesBn_2.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesBn_2.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/SeriesBn_3.dat.md5 b/Tests/Module/ExternalData/SeriesBn_3.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesBn_3.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/Module/ExternalData/SeriesC.1.dat.md5 b/Tests/Module/ExternalData/SeriesC.1.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesC.1.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/SeriesC.2.dat.md5 b/Tests/Module/ExternalData/SeriesC.2.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesC.2.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/SeriesC.3.dat.md5 b/Tests/Module/ExternalData/SeriesC.3.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesC.3.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/Module/ExternalData/SeriesC.dat.md5 b/Tests/Module/ExternalData/SeriesC.dat.md5
new file mode 100644
index 0000000000..be2d6878b0
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesC.dat.md5
@@ -0,0 +1 @@
+f41c94425d01ecbbee70440b951cb058
diff --git a/Tests/Module/ExternalData/SeriesCn.1.dat.md5 b/Tests/Module/ExternalData/SeriesCn.1.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesCn.1.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/SeriesCn.2.dat.md5 b/Tests/Module/ExternalData/SeriesCn.2.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesCn.2.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/SeriesCn.3.dat.md5 b/Tests/Module/ExternalData/SeriesCn.3.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesCn.3.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/Module/ExternalData/SeriesD-1.dat.md5 b/Tests/Module/ExternalData/SeriesD-1.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesD-1.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/SeriesD-2.dat.md5 b/Tests/Module/ExternalData/SeriesD-2.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesD-2.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/SeriesD-3.dat.md5 b/Tests/Module/ExternalData/SeriesD-3.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesD-3.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/Module/ExternalData/SeriesD.dat.md5 b/Tests/Module/ExternalData/SeriesD.dat.md5
new file mode 100644
index 0000000000..be2d6878b0
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesD.dat.md5
@@ -0,0 +1 @@
+f41c94425d01ecbbee70440b951cb058
diff --git a/Tests/Module/ExternalData/SeriesDn-1.dat.md5 b/Tests/Module/ExternalData/SeriesDn-1.dat.md5
new file mode 100644
index 0000000000..f22e266a6d
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesDn-1.dat.md5
@@ -0,0 +1 @@
+31eff09e84fca01415f8cd9d82ec432b
diff --git a/Tests/Module/ExternalData/SeriesDn-2.dat.md5 b/Tests/Module/ExternalData/SeriesDn-2.dat.md5
new file mode 100644
index 0000000000..2b917e793f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesDn-2.dat.md5
@@ -0,0 +1 @@
+f7ab5a04aae9cb9a520e70b20b9c8ed7
diff --git a/Tests/Module/ExternalData/SeriesDn-3.dat.md5 b/Tests/Module/ExternalData/SeriesDn-3.dat.md5
new file mode 100644
index 0000000000..b9c9760c43
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesDn-3.dat.md5
@@ -0,0 +1 @@
+30ba0acdee9096b3b9fc6c69362c6b42
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 35b9a43d4b..e55cf6952b 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -46,6 +46,7 @@ macro(add_RunCMake_test test)
endmacro()
add_RunCMake_test(CMP0019)
+add_RunCMake_test(ExternalData)
add_RunCMake_test(GeneratorExpression)
add_RunCMake_test(TargetPropertyGeneratorExpressions)
add_RunCMake_test(Languages)
diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1-result.txt b/Tests/RunCMake/ExternalData/BadHashAlgo1-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadHashAlgo1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt b/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt
new file mode 100644
index 0000000000..f68f0be6b1
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Unknown hash algorithm specified by ExternalData_LINK_CONTENT:
+
+ BAD
+Call Stack \(most recent call first\):
+ .*
+ BadHashAlgo1.cmake:3 \(ExternalData_Expand_Arguments\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1.cmake b/Tests/RunCMake/ExternalData/BadHashAlgo1.cmake
new file mode 100644
index 0000000000..19e2e412dc
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadHashAlgo1.cmake
@@ -0,0 +1,3 @@
+include(ExternalData)
+set(ExternalData_LINK_CONTENT BAD)
+ExternalData_Expand_Arguments(Data args DATA{BadHashAlgo1.txt})
diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1.txt b/Tests/RunCMake/ExternalData/BadHashAlgo1.txt
new file mode 100644
index 0000000000..bfa2818c23
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadHashAlgo1.txt
@@ -0,0 +1 @@
+Sample input file that should not be transformed.
diff --git a/Tests/RunCMake/ExternalData/BadOption1-result.txt b/Tests/RunCMake/ExternalData/BadOption1-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadOption1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/BadOption1-stderr.txt b/Tests/RunCMake/ExternalData/BadOption1-stderr.txt
new file mode 100644
index 0000000000..b63d098c0b
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadOption1-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Unknown option "Bad/Option" in argument
+
+ DATA{Data.txt,Bad/Option}
+
+Call Stack \(most recent call first\):
+ .*
+ BadOption1.cmake:2 \(ExternalData_Add_Test\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadOption1.cmake b/Tests/RunCMake/ExternalData/BadOption1.cmake
new file mode 100644
index 0000000000..1303d7f1a1
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadOption1.cmake
@@ -0,0 +1,5 @@
+include(ExternalData)
+ExternalData_Add_Test(Data
+ NAME Test
+ COMMAND ${CMAKE_COMMAND} -E echo DATA{Data.txt,Bad/Option}
+ )
diff --git a/Tests/RunCMake/ExternalData/BadOption2-result.txt b/Tests/RunCMake/ExternalData/BadOption2-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadOption2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/BadOption2-stderr.txt b/Tests/RunCMake/ExternalData/BadOption2-stderr.txt
new file mode 100644
index 0000000000..d114c8aa9b
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadOption2-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Unknown option "Bad:Option" in argument
+
+ DATA{Data.txt,Bad:Option}
+
+Call Stack \(most recent call first\):
+ .*
+ BadOption2.cmake:2 \(ExternalData_Add_Test\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadOption2.cmake b/Tests/RunCMake/ExternalData/BadOption2.cmake
new file mode 100644
index 0000000000..6269b064c1
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadOption2.cmake
@@ -0,0 +1,5 @@
+include(ExternalData)
+ExternalData_Add_Test(Data
+ NAME Test
+ COMMAND ${CMAKE_COMMAND} -E echo DATA{Data.txt,Bad:Option}
+ )
diff --git a/Tests/RunCMake/ExternalData/BadSeries1-result.txt b/Tests/RunCMake/ExternalData/BadSeries1-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt
new file mode 100644
index 0000000000..3099be579c
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt
@@ -0,0 +1,19 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ ExternalData_SERIES_PARSE is set to
+
+ NotASeriesRegex
+
+ which is not of the form
+
+ \(<number>\)\(<suffix>\)\$
+
+ Fix the regular expression or set variables
+
+ ExternalData_SERIES_PARSE_PREFIX = <prefix> regex group number, if any
+ ExternalData_SERIES_PARSE_NUMBER = <number> regex group number
+ ExternalData_SERIES_PARSE_SUFFIX = <suffix> regex group number
+
+Call Stack \(most recent call first\):
+ .*
+ BadSeries1.cmake:3 \(ExternalData_Expand_Arguments\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadSeries1.cmake b/Tests/RunCMake/ExternalData/BadSeries1.cmake
new file mode 100644
index 0000000000..7d712106f1
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries1.cmake
@@ -0,0 +1,3 @@
+include(ExternalData)
+set(ExternalData_SERIES_PARSE NotASeriesRegex)
+ExternalData_Expand_Arguments(Data args DATA{Data.txt,:})
diff --git a/Tests/RunCMake/ExternalData/BadSeries2-result.txt b/Tests/RunCMake/ExternalData/BadSeries2-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt
new file mode 100644
index 0000000000..3a02c25e94
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt
@@ -0,0 +1,16 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Data file referenced by argument
+
+ DATA{Data.txt,:}
+
+ corresponds to path
+
+ Data.txt
+
+ that does not match regular expression
+
+ \(x\)\(y\)\$
+Call Stack \(most recent call first\):
+ .*
+ BadSeries2.cmake:3 \(ExternalData_Expand_Arguments\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadSeries2.cmake b/Tests/RunCMake/ExternalData/BadSeries2.cmake
new file mode 100644
index 0000000000..e81993b8fd
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries2.cmake
@@ -0,0 +1,3 @@
+include(ExternalData)
+set(ExternalData_SERIES_PARSE "(x)(y)$")
+ExternalData_Expand_Arguments(Data args DATA{Data.txt,:})
diff --git a/Tests/RunCMake/ExternalData/BadSeries3-result.txt b/Tests/RunCMake/ExternalData/BadSeries3-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt
new file mode 100644
index 0000000000..594cb6f6a4
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Series option ":" not allowed with associated files.
+Call Stack \(most recent call first\):
+ .*
+ BadSeries3.cmake:2 \(ExternalData_Expand_Arguments\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadSeries3.cmake b/Tests/RunCMake/ExternalData/BadSeries3.cmake
new file mode 100644
index 0000000000..b640df8781
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/BadSeries3.cmake
@@ -0,0 +1,2 @@
+include(ExternalData)
+ExternalData_Expand_Arguments(Data args DATA{PairA.txt,PairB.txt,:})
diff --git a/Tests/RunCMake/ExternalData/CMakeLists.txt b/Tests/RunCMake/ExternalData/CMakeLists.txt
new file mode 100644
index 0000000000..e8db6b05be
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ExternalData/Data.txt.md5 b/Tests/RunCMake/ExternalData/Data.txt.md5
new file mode 100644
index 0000000000..93b3485e94
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Data.txt.md5
@@ -0,0 +1 @@
+e8bb14af900b998b5a3df7e21dd07d58
diff --git a/Tests/RunCMake/ExternalData/Directory1-result.txt b/Tests/RunCMake/ExternalData/Directory1-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/Directory1-stderr.txt b/Tests/RunCMake/ExternalData/Directory1-stderr.txt
new file mode 100644
index 0000000000..85c250f027
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory1-stderr.txt
@@ -0,0 +1,14 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Data file referenced by argument
+
+ DATA{Directory1}
+
+ corresponds to source tree path
+
+ Directory1
+
+ that does not exist as a file \(with or without an extension\)!
+Call Stack \(most recent call first\):
+ .*
+ Directory1.cmake:3 \(ExternalData_Add_Test\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/Directory1.cmake b/Tests/RunCMake/ExternalData/Directory1.cmake
new file mode 100644
index 0000000000..68f1b54bea
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory1.cmake
@@ -0,0 +1,6 @@
+include(CTest)
+include(ExternalData)
+ExternalData_Add_Test(Data
+ NAME Test
+ COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory1}
+ )
diff --git a/Tests/RunCMake/ExternalData/Directory1/DirData1.txt b/Tests/RunCMake/ExternalData/Directory1/DirData1.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory1/DirData1.txt
diff --git a/Tests/RunCMake/ExternalData/Directory2-result.txt b/Tests/RunCMake/ExternalData/Directory2-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/Directory2-stderr.txt b/Tests/RunCMake/ExternalData/Directory2-stderr.txt
new file mode 100644
index 0000000000..dc1a59a0b8
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory2-stderr.txt
@@ -0,0 +1,10 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Data file reference in argument
+
+ DATA{Directory2/}
+
+ may not end in a slash!
+Call Stack \(most recent call first\):
+ .*
+ Directory2.cmake:3 \(ExternalData_Add_Test\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/Directory2.cmake b/Tests/RunCMake/ExternalData/Directory2.cmake
new file mode 100644
index 0000000000..30b992e6eb
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory2.cmake
@@ -0,0 +1,6 @@
+include(CTest)
+include(ExternalData)
+ExternalData_Add_Test(Data
+ NAME Test
+ COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory2/}
+ )
diff --git a/Tests/RunCMake/ExternalData/Directory2.md5 b/Tests/RunCMake/ExternalData/Directory2.md5
new file mode 100644
index 0000000000..93b3485e94
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory2.md5
@@ -0,0 +1 @@
+e8bb14af900b998b5a3df7e21dd07d58
diff --git a/Tests/RunCMake/ExternalData/Directory2/DirData2.txt b/Tests/RunCMake/ExternalData/Directory2/DirData2.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory2/DirData2.txt
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/ExternalData/Directory3-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/Directory3-stderr.txt b/Tests/RunCMake/ExternalData/Directory3-stderr.txt
new file mode 100644
index 0000000000..56a341e035
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory3-stderr.txt
@@ -0,0 +1,14 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Data file referenced by argument
+
+ DATA{Directory3/\*}
+
+ corresponds to source tree path
+
+ Directory3/.
+
+ that does not exist as a file \(with or without an extension\)!
+Call Stack \(most recent call first\):
+ .*
+ Directory3.cmake:3 \(ExternalData_Add_Test\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/Directory3.cmake b/Tests/RunCMake/ExternalData/Directory3.cmake
new file mode 100644
index 0000000000..55d8be9dd3
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory3.cmake
@@ -0,0 +1,6 @@
+include(CTest)
+include(ExternalData)
+ExternalData_Add_Test(Data
+ NAME Test
+ COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory3/*}
+ )
diff --git a/Tests/RunCMake/ExternalData/Directory3/DirData3.txt b/Tests/RunCMake/ExternalData/Directory3/DirData3.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/Directory3/DirData3.txt
diff --git a/Tests/RunCMake/ExternalData/LinkContentMD5-stdout.txt b/Tests/RunCMake/ExternalData/LinkContentMD5-stdout.txt
new file mode 100644
index 0000000000..f77fca9b51
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/LinkContentMD5-stdout.txt
@@ -0,0 +1,3 @@
+-- Linked ToLink.txt.md5 to ExternalData MD5/c18ff9804c8deec9eaeb17063cda8b7b
+-- Raw data correctly transformed to content link!
+-- Staged content exists!
diff --git a/Tests/RunCMake/ExternalData/LinkContentMD5.cmake b/Tests/RunCMake/ExternalData/LinkContentMD5.cmake
new file mode 100644
index 0000000000..41b4deebfd
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/LinkContentMD5.cmake
@@ -0,0 +1,22 @@
+include(ExternalData)
+set(ExternalData_LINK_CONTENT MD5)
+set(ExternalData_SOURCE_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData)
+set(input ${CMAKE_CURRENT_BINARY_DIR}/ToLink.txt)
+set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/ToLink.txt)
+set(staged "${CMAKE_CURRENT_BINARY_DIR}/.ExternalData_MD5_c18ff9804c8deec9eaeb17063cda8b7b")
+file(REMOVE ${staged})
+file(REMOVE ${input}.md5)
+file(WRITE ${input} "To be transformed into a content link.")
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Raw data correctly transformed to content link!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
+if(EXISTS "${staged}")
+ message(STATUS "Staged content exists!")
+else()
+ message(FATAL_ERROR "Staged content missing!")
+endif()
diff --git a/Tests/RunCMake/ExternalData/MissingData-result.txt b/Tests/RunCMake/ExternalData/MissingData-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingData-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/MissingData-stderr.txt b/Tests/RunCMake/ExternalData/MissingData-stderr.txt
new file mode 100644
index 0000000000..e794f955da
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingData-stderr.txt
@@ -0,0 +1,14 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Data file referenced by argument
+
+ DATA{MissingData.txt}
+
+ corresponds to source tree path
+
+ MissingData.txt
+
+ that does not exist as a file \(with or without an extension\)!
+Call Stack \(most recent call first\):
+ .*
+ MissingData.cmake:2 \(ExternalData_Add_Test\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/MissingData.cmake b/Tests/RunCMake/ExternalData/MissingData.cmake
new file mode 100644
index 0000000000..b3c8a5cdc0
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingData.cmake
@@ -0,0 +1,5 @@
+include(ExternalData)
+ExternalData_Add_Test(Data
+ NAME Test
+ COMMAND ${CMAKE_COMMAND} -E echo DATA{MissingData.txt}
+ )
diff --git a/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt b/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt
new file mode 100644
index 0000000000..496ad8ae4e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt
@@ -0,0 +1,6 @@
+CMake Warning at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ ExternalData_LINK_CONTENT cannot be used in-source
+Call Stack \(most recent call first\):
+ .*
+ NoLinkInSource.cmake:8 \(ExternalData_Expand_Arguments\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/NoLinkInSource-stdout.txt b/Tests/RunCMake/ExternalData/NoLinkInSource-stdout.txt
new file mode 100644
index 0000000000..18946f0ecb
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NoLinkInSource-stdout.txt
@@ -0,0 +1 @@
+-- Data reference correctly not transformed!
diff --git a/Tests/RunCMake/ExternalData/NoLinkInSource.cmake b/Tests/RunCMake/ExternalData/NoLinkInSource.cmake
new file mode 100644
index 0000000000..cbf45ebbf7
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NoLinkInSource.cmake
@@ -0,0 +1,14 @@
+include(ExternalData)
+set(ExternalData_LINK_CONTENT MD5)
+set(ExternalData_SOURCE_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+set(input ${CMAKE_CURRENT_BINARY_DIR}/ToLink.txt)
+file(REMOVE ${input}.md5)
+file(WRITE ${input} "To be transformed into a content link.")
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${input}")
+ message(STATUS "Data reference correctly not transformed!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected no transformation.")
+endif()
diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates-result.txt b/Tests/RunCMake/ExternalData/NoURLTemplates-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NoURLTemplates-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt
new file mode 100644
index 0000000000..ad059d434f
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ ExternalData_URL_TEMPLATES is not set!
+Call Stack \(most recent call first\):
+ NoURLTemplates.cmake:2 \(ExternalData_Add_Target\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates.cmake b/Tests/RunCMake/ExternalData/NoURLTemplates.cmake
new file mode 100644
index 0000000000..8f0e069c22
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NoURLTemplates.cmake
@@ -0,0 +1,2 @@
+include(ExternalData)
+ExternalData_Add_Target(Data)
diff --git a/Tests/RunCMake/ExternalData/NormalData1-stdout.txt b/Tests/RunCMake/ExternalData/NormalData1-stdout.txt
new file mode 100644
index 0000000000..2f2c770cbf
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NormalData1-stdout.txt
@@ -0,0 +1 @@
+-- Data reference correctly transformed!
diff --git a/Tests/RunCMake/ExternalData/NormalData1.cmake b/Tests/RunCMake/ExternalData/NormalData1.cmake
new file mode 100644
index 0000000000..d6cc384c85
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NormalData1.cmake
@@ -0,0 +1,13 @@
+include(ExternalData)
+set(ExternalData_URL_TEMPLATES
+ "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
+ )
+set(input Data.txt)
+set(output ${CMAKE_CURRENT_BINARY_DIR}/Data.txt)
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Data reference correctly transformed!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/NormalData2-stdout.txt b/Tests/RunCMake/ExternalData/NormalData2-stdout.txt
new file mode 100644
index 0000000000..2f2c770cbf
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NormalData2-stdout.txt
@@ -0,0 +1 @@
+-- Data reference correctly transformed!
diff --git a/Tests/RunCMake/ExternalData/NormalData2.cmake b/Tests/RunCMake/ExternalData/NormalData2.cmake
new file mode 100644
index 0000000000..c979b48ea9
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NormalData2.cmake
@@ -0,0 +1,14 @@
+include(ExternalData)
+set(ExternalData_URL_TEMPLATES
+ "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
+ )
+set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData)
+set(input Data.txt)
+set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/Data.txt)
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Data reference correctly transformed!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/NormalData3-stdout.txt b/Tests/RunCMake/ExternalData/NormalData3-stdout.txt
new file mode 100644
index 0000000000..2f2c770cbf
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NormalData3-stdout.txt
@@ -0,0 +1 @@
+-- Data reference correctly transformed!
diff --git a/Tests/RunCMake/ExternalData/NormalData3.cmake b/Tests/RunCMake/ExternalData/NormalData3.cmake
new file mode 100644
index 0000000000..e99112267a
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NormalData3.cmake
@@ -0,0 +1,14 @@
+include(ExternalData)
+set(ExternalData_URL_TEMPLATES
+ "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
+ )
+set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData)
+set(input ${CMAKE_CURRENT_SOURCE_DIR}/Data.txt)
+set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/Data.txt)
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Data reference correctly transformed!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/NormalDataSub1-stdout.txt b/Tests/RunCMake/ExternalData/NormalDataSub1-stdout.txt
new file mode 100644
index 0000000000..2f2c770cbf
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NormalDataSub1-stdout.txt
@@ -0,0 +1 @@
+-- Data reference correctly transformed!
diff --git a/Tests/RunCMake/ExternalData/NormalDataSub1.cmake b/Tests/RunCMake/ExternalData/NormalDataSub1.cmake
new file mode 100644
index 0000000000..015e94c0a7
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NormalDataSub1.cmake
@@ -0,0 +1,13 @@
+include(ExternalData)
+set(ExternalData_URL_TEMPLATES
+ "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
+ )
+set(input SubDirectory1/Data.txt)
+set(output ${CMAKE_CURRENT_BINARY_DIR}/SubDirectory1/Data.txt)
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Data reference correctly transformed!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/NotUnderRoot-result.txt b/Tests/RunCMake/ExternalData/NotUnderRoot-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NotUnderRoot-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalData/NotUnderRoot-stderr.txt b/Tests/RunCMake/ExternalData/NotUnderRoot-stderr.txt
new file mode 100644
index 0000000000..1f2eb1c7af
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NotUnderRoot-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Data file referenced by argument
+
+ DATA{../NotUnderRoot.txt}
+
+ does not lie under the top-level source directory
+
+ .*/Tests/RunCMake/ExternalData
+
+Call Stack \(most recent call first\):
+ .*
+ NotUnderRoot.cmake:2 \(ExternalData_Add_Test\)
diff --git a/Tests/RunCMake/ExternalData/NotUnderRoot.cmake b/Tests/RunCMake/ExternalData/NotUnderRoot.cmake
new file mode 100644
index 0000000000..c7942d678d
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/NotUnderRoot.cmake
@@ -0,0 +1,5 @@
+include(ExternalData)
+ExternalData_Add_Test(Data
+ NAME Test
+ COMMAND ${CMAKE_COMMAND} -E echo DATA{../NotUnderRoot.txt}
+ )
diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
new file mode 100644
index 0000000000..c61527e484
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
@@ -0,0 +1,21 @@
+include(RunCMake)
+
+run_cmake(BadHashAlgo1)
+run_cmake(BadOption1)
+run_cmake(BadOption2)
+run_cmake(BadSeries1)
+run_cmake(BadSeries2)
+run_cmake(BadSeries3)
+run_cmake(Directory1)
+run_cmake(Directory2)
+run_cmake(Directory3)
+run_cmake(LinkContentMD5)
+run_cmake(MissingData)
+run_cmake(NoLinkInSource)
+run_cmake(NoURLTemplates)
+run_cmake(NormalData1)
+run_cmake(NormalData2)
+run_cmake(NormalData3)
+run_cmake(NormalDataSub1)
+run_cmake(NotUnderRoot)
+run_cmake(SubDirectory1)
diff --git a/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt b/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt
new file mode 100644
index 0000000000..35a8cc172a
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt
@@ -0,0 +1,2 @@
+-- Data reference correctly transformed in parent dir!
+-- Data reference correctly transformed in current dir!
diff --git a/Tests/RunCMake/ExternalData/SubDirectory1.cmake b/Tests/RunCMake/ExternalData/SubDirectory1.cmake
new file mode 100644
index 0000000000..29894710ac
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/SubDirectory1.cmake
@@ -0,0 +1,5 @@
+include(ExternalData)
+set(ExternalData_URL_TEMPLATES
+ "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)"
+ )
+add_subdirectory(SubDirectory1)
diff --git a/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt b/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt
new file mode 100644
index 0000000000..07824608cd
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt
@@ -0,0 +1,19 @@
+set(input ../Data.txt)
+set(output ${CMAKE_BINARY_DIR}/Data.txt)
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Data reference correctly transformed in parent dir!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
+
+set(input Data.txt)
+set(output ${CMAKE_CURRENT_BINARY_DIR}/Data.txt)
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Data reference correctly transformed in current dir!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/SubDirectory1/Data.txt.md5 b/Tests/RunCMake/ExternalData/SubDirectory1/Data.txt.md5
new file mode 100644
index 0000000000..93b3485e94
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/SubDirectory1/Data.txt.md5
@@ -0,0 +1 @@
+e8bb14af900b998b5a3df7e21dd07d58