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.
This commit is contained in:
Brad King 2013-01-25 16:39:57 -05:00
parent bcd25808ac
commit 4befecc77c
123 changed files with 554 additions and 0 deletions

View File

@ -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")

View File

@ -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)

View File

@ -0,0 +1 @@
8c018830e3efa5caf3c7415028335a57

View File

@ -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()

View File

@ -0,0 +1 @@
8c018830e3efa5caf3c7415028335a57

View File

@ -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)

View File

@ -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()

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -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)

View File

@ -0,0 +1 @@
8c018830e3efa5caf3c7415028335a57

View File

@ -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()

View File

@ -0,0 +1 @@
aaad162b85f60d1eb57ca71a23e8efd7

View File

@ -0,0 +1 @@
* -crlf

View File

@ -0,0 +1 @@
MetaTop

View File

@ -0,0 +1 @@
Series.3

View File

@ -0,0 +1 @@
Series.1

View File

@ -0,0 +1 @@
PairedA

View File

@ -0,0 +1 @@
Input file already transformed.

View File

@ -0,0 +1 @@
MetaB

View File

@ -0,0 +1 @@
MetaA

View File

@ -0,0 +1 @@
Another input file already transformed.

View File

@ -0,0 +1 @@
MetaC

View File

@ -0,0 +1 @@
PairedB

View File

@ -0,0 +1 @@
Series

View File

@ -0,0 +1 @@
Series.2

View File

@ -0,0 +1 @@
9d980b06c2f0fec3d4872d68175b9822

View File

@ -0,0 +1 @@
8f4add4581551facf27237e6577fd662

View File

@ -0,0 +1 @@
c1030719c95f3435d8abc39c0d442946

View File

@ -0,0 +1 @@
08cfcf221f76ace7b906b312284e73d7

View File

@ -0,0 +1 @@
401767f22a456b3522953722090a2c36

View File

@ -0,0 +1 @@
ecfa1ecd417d4253af81ae04d1bd6581

View File

@ -0,0 +1 @@
f41c94425d01ecbbee70440b951cb058

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -0,0 +1 @@
f41c94425d01ecbbee70440b951cb058

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -0,0 +1 @@
f41c94425d01ecbbee70440b951cb058

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -0,0 +1 @@
f41c94425d01ecbbee70440b951cb058

View File

@ -0,0 +1 @@
31eff09e84fca01415f8cd9d82ec432b

View File

@ -0,0 +1 @@
f7ab5a04aae9cb9a520e70b20b9c8ed7

View File

@ -0,0 +1 @@
30ba0acdee9096b3b9fc6c69362c6b42

View File

@ -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)

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,3 @@
include(ExternalData)
set(ExternalData_LINK_CONTENT BAD)
ExternalData_Expand_Arguments(Data args DATA{BadHashAlgo1.txt})

View File

@ -0,0 +1 @@
Sample input file that should not be transformed.

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,5 @@
include(ExternalData)
ExternalData_Add_Test(Data
NAME Test
COMMAND ${CMAKE_COMMAND} -E echo DATA{Data.txt,Bad/Option}
)

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,5 @@
include(ExternalData)
ExternalData_Add_Test(Data
NAME Test
COMMAND ${CMAKE_COMMAND} -E echo DATA{Data.txt,Bad:Option}
)

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,3 @@
include(ExternalData)
set(ExternalData_SERIES_PARSE NotASeriesRegex)
ExternalData_Expand_Arguments(Data args DATA{Data.txt,:})

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,3 @@
include(ExternalData)
set(ExternalData_SERIES_PARSE "(x)(y)$")
ExternalData_Expand_Arguments(Data args DATA{Data.txt,:})

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,2 @@
include(ExternalData)
ExternalData_Expand_Arguments(Data args DATA{PairA.txt,PairB.txt,:})

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1 @@
e8bb14af900b998b5a3df7e21dd07d58

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,6 @@
include(CTest)
include(ExternalData)
ExternalData_Add_Test(Data
NAME Test
COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory1}
)

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,6 @@
include(CTest)
include(ExternalData)
ExternalData_Add_Test(Data
NAME Test
COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory2/}
)

View File

@ -0,0 +1 @@
e8bb14af900b998b5a3df7e21dd07d58

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,6 @@
include(CTest)
include(ExternalData)
ExternalData_Add_Test(Data
NAME Test
COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory3/*}
)

View File

@ -0,0 +1,3 @@
-- Linked ToLink.txt.md5 to ExternalData MD5/c18ff9804c8deec9eaeb17063cda8b7b
-- Raw data correctly transformed to content link!
-- Staged content exists!

View File

@ -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()

View File

@ -0,0 +1 @@
1

View File

@ -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\)

Some files were not shown because too many files have changed in this diff Show More