diff options
author | Brad King <brad.king@kitware.com> | 2011-11-16 01:39:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-11-16 15:15:01 (GMT) |
commit | 042f7965c3a5db7420363fdb76f9ebaa8e93efdc (patch) | |
tree | d6537eef3a37cbd65e3ea09da6df0b23cd192e9a /Tests/CMakeTests | |
parent | ed7cef563445644684af47720c2f7c6fb0a2e440 (diff) | |
download | CMake-042f7965c3a5db7420363fdb76f9ebaa8e93efdc.zip CMake-042f7965c3a5db7420363fdb76f9ebaa8e93efdc.tar.gz CMake-042f7965c3a5db7420363fdb76f9ebaa8e93efdc.tar.bz2 |
Add file(MD5) command to compute cryptographic hash
Provide a CMake-language binding to the md5sum function previously
available only by "cmake -E md5sum".
Diffstat (limited to 'Tests/CMakeTests')
-rw-r--r-- | Tests/CMakeTests/CheckCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/CMakeTests/File-MD5-BadArg1.cmake | 1 | ||||
-rw-r--r-- | Tests/CMakeTests/File-MD5-BadArg2.cmake | 1 | ||||
-rw-r--r-- | Tests/CMakeTests/File-MD5-BadArg4.cmake | 1 | ||||
-rw-r--r-- | Tests/CMakeTests/File-MD5-NoFile.cmake | 1 | ||||
-rw-r--r-- | Tests/CMakeTests/File-MD5-Works.cmake | 2 | ||||
-rw-r--r-- | Tests/CMakeTests/FileTest.cmake.in | 15 |
7 files changed, 22 insertions, 1 deletions
diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake index 2e4fedd..db92905 100644 --- a/Tests/CMakeTests/CheckCMakeTest.cmake +++ b/Tests/CMakeTests/CheckCMakeTest.cmake @@ -12,7 +12,7 @@ function(check_cmake_test prefix) ) string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") - if(NOT "${result}" STREQUAL ${${test}-RESULT}) + if(NOT "${result}" STREQUAL "${${test}-RESULT}") message(FATAL_ERROR "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" "Test ${test} output:\n" diff --git a/Tests/CMakeTests/File-MD5-BadArg1.cmake b/Tests/CMakeTests/File-MD5-BadArg1.cmake new file mode 100644 index 0000000..ac5f67a --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg1.cmake @@ -0,0 +1 @@ +file(MD5) diff --git a/Tests/CMakeTests/File-MD5-BadArg2.cmake b/Tests/CMakeTests/File-MD5-BadArg2.cmake new file mode 100644 index 0000000..68a172f --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg2.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake) diff --git a/Tests/CMakeTests/File-MD5-BadArg4.cmake b/Tests/CMakeTests/File-MD5-BadArg4.cmake new file mode 100644 index 0000000..a11efcb --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg4.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake md5 extra_arg) diff --git a/Tests/CMakeTests/File-MD5-NoFile.cmake b/Tests/CMakeTests/File-MD5-NoFile.cmake new file mode 100644 index 0000000..1b91bc8 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-NoFile.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/DoesNotExist.cmake md5) diff --git a/Tests/CMakeTests/File-MD5-Works.cmake b/Tests/CMakeTests/File-MD5-Works.cmake new file mode 100644 index 0000000..2989e98 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-Works.cmake @@ -0,0 +1,2 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake md5) +message("${md5}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index b6dcaa6..3aa88a7 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -12,6 +12,16 @@ set(Copy-NoDest-RESULT 1) set(Copy-NoDest-STDERR "given no DESTINATION") set(Copy-NoFile-RESULT 1) set(Copy-NoFile-STDERR "COPY cannot find.*/does_not_exist\\.txt") +set(MD5-NoFile-RESULT 1) +set(MD5-NoFile-STDERR "file MD5 failed to read file") +set(MD5-BadArg1-RESULT 1) +set(MD5-BadArg1-STDERR "file must be called with at least two arguments") +set(MD5-BadArg2-RESULT 1) +set(MD5-BadArg2-STDERR "file MD5 requires a file name and output variable") +set(MD5-BadArg4-RESULT 1) +set(MD5-BadArg4-STDERR "file MD5 requires a file name and output variable") +set(MD5-Works-RESULT 0) +set(MD5-Works-STDERR "a28a44fb5b58a6acf0cbec46557bc775") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(File @@ -22,6 +32,11 @@ check_cmake_test(File Copy-LateArg Copy-NoDest Copy-NoFile + MD5-NoFile + MD5-BadArg1 + MD5-BadArg2 + MD5-BadArg4 + MD5-Works ) # Also execute each test listed in FileTestScript.cmake: |