summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-04-29 17:13:58 (GMT)
committerBrad King <brad.king@kitware.com>2009-04-29 17:13:58 (GMT)
commite0d3339e655049cc44e27861a5c65ce0dc2ef39a (patch)
treed723fdf56d25e225a701da5c51030bc65f7cad08 /Tests
parentc58ca242865118d65b5add11a256832d177afe6d (diff)
downloadCMake-e0d3339e655049cc44e27861a5c65ce0dc2ef39a.zip
CMake-e0d3339e655049cc44e27861a5c65ce0dc2ef39a.tar.gz
CMake-e0d3339e655049cc44e27861a5c65ce0dc2ef39a.tar.bz2
ENH: Test file(COPY) failure cases
This tests some cases of bad arguments to the file(COPY) signature. It checks that the proper error messages are produced.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeTests/CMakeLists.txt1
-rw-r--r--Tests/CMakeTests/File-Copy-BadArg.cmake1
-rw-r--r--Tests/CMakeTests/File-Copy-BadPerm.cmake1
-rw-r--r--Tests/CMakeTests/File-Copy-BadRegex.cmake1
-rw-r--r--Tests/CMakeTests/File-Copy-EarlyArg.cmake1
-rw-r--r--Tests/CMakeTests/File-Copy-LateArg.cmake1
-rw-r--r--Tests/CMakeTests/File-Copy-NoDest.cmake1
-rw-r--r--Tests/CMakeTests/File-Copy-NoFile.cmake1
-rw-r--r--Tests/CMakeTests/FileTest.cmake.in50
9 files changed, 58 insertions, 0 deletions
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt
index e197302..62e6133 100644
--- a/Tests/CMakeTests/CMakeLists.txt
+++ b/Tests/CMakeTests/CMakeLists.txt
@@ -17,6 +17,7 @@ AddCMakeTest(Toolchain "")
AddCMakeTest(GetFilenameComponentRealpath "")
AddCMakeTest(Version "")
AddCMakeTest(Message "")
+AddCMakeTest(File "")
SET(GetPrerequisites_PreArgs
"-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}"
diff --git a/Tests/CMakeTests/File-Copy-BadArg.cmake b/Tests/CMakeTests/File-Copy-BadArg.cmake
new file mode 100644
index 0000000..91952fc
--- /dev/null
+++ b/Tests/CMakeTests/File-Copy-BadArg.cmake
@@ -0,0 +1 @@
+file(COPY FileTest.cmake DESTINATION tmp PATTERN * BADARG)
diff --git a/Tests/CMakeTests/File-Copy-BadPerm.cmake b/Tests/CMakeTests/File-Copy-BadPerm.cmake
new file mode 100644
index 0000000..b5cc42f
--- /dev/null
+++ b/Tests/CMakeTests/File-Copy-BadPerm.cmake
@@ -0,0 +1 @@
+file(COPY FileTest.cmake DESTINATION tmp FILE_PERMISSIONS BADPERM)
diff --git a/Tests/CMakeTests/File-Copy-BadRegex.cmake b/Tests/CMakeTests/File-Copy-BadRegex.cmake
new file mode 100644
index 0000000..41340f6
--- /dev/null
+++ b/Tests/CMakeTests/File-Copy-BadRegex.cmake
@@ -0,0 +1 @@
+file(COPY FileTest.cmake DESTINATION tmp REGEX "(")
diff --git a/Tests/CMakeTests/File-Copy-EarlyArg.cmake b/Tests/CMakeTests/File-Copy-EarlyArg.cmake
new file mode 100644
index 0000000..03993de
--- /dev/null
+++ b/Tests/CMakeTests/File-Copy-EarlyArg.cmake
@@ -0,0 +1 @@
+file(COPY FileTest.cmake DESTINATION tmp PERMISSIONS)
diff --git a/Tests/CMakeTests/File-Copy-LateArg.cmake b/Tests/CMakeTests/File-Copy-LateArg.cmake
new file mode 100644
index 0000000..43d2168
--- /dev/null
+++ b/Tests/CMakeTests/File-Copy-LateArg.cmake
@@ -0,0 +1 @@
+file(COPY FileTest.cmake DESTINATION tmp PATTERN * FILE_PERMISSIONS)
diff --git a/Tests/CMakeTests/File-Copy-NoDest.cmake b/Tests/CMakeTests/File-Copy-NoDest.cmake
new file mode 100644
index 0000000..f6c6c6d
--- /dev/null
+++ b/Tests/CMakeTests/File-Copy-NoDest.cmake
@@ -0,0 +1 @@
+file(COPY FileTest.cmake)
diff --git a/Tests/CMakeTests/File-Copy-NoFile.cmake b/Tests/CMakeTests/File-Copy-NoFile.cmake
new file mode 100644
index 0000000..d5853d3
--- /dev/null
+++ b/Tests/CMakeTests/File-Copy-NoFile.cmake
@@ -0,0 +1 @@
+file(COPY does_not_exist.txt DESTINATION tmp)
diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in
new file mode 100644
index 0000000..c46138c
--- /dev/null
+++ b/Tests/CMakeTests/FileTest.cmake.in
@@ -0,0 +1,50 @@
+set(Copy-BadArg-RESULT 1)
+set(Copy-BadArg-STDERR "unknown argument \"BADARG\"")
+set(Copy-BadPerm-RESULT 1)
+set(Copy-BadPerm-STDERR "COPY given invalid permission \"BADPERM\"")
+set(Copy-BadRegex-RESULT 1)
+set(Copy-BadRegex-STDERR "could not compile REGEX")
+set(Copy-EarlyArg-RESULT 1)
+set(Copy-EarlyArg-STDERR "option PERMISSIONS may not appear before")
+set(Copy-LateArg-RESULT 1)
+set(Copy-LateArg-STDERR "option FILE_PERMISSIONS may not appear after")
+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")
+
+foreach(test
+ Copy-BadArg
+ Copy-BadPerm
+ Copy-BadRegex
+ Copy-EarlyArg
+ Copy-LateArg
+ Copy-NoDest
+ Copy-NoFile
+ )
+ message(STATUS "Test ${test}...")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -P
+ "@CMAKE_CURRENT_SOURCE_DIR@/File-${test}.cmake"
+ WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@"
+ OUTPUT_VARIABLE stdout
+ ERROR_VARIABLE stderr
+ RESULT_VARIABLE result
+ )
+ string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}")
+ string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}")
+ if(NOT "${result}" STREQUAL ${${test}-RESULT})
+ message(FATAL_ERROR
+ "Test ${test} result is [${result}], not [${${test}-RESULT}].\n"
+ "Test ${test} output:\n"
+ "${out}\n"
+ "${err}")
+ endif()
+ if(${test}-STDERR AND NOT "${err}" MATCHES "${${test}-STDERR}")
+ message(FATAL_ERROR
+ "Test ${test} stderr does not match\n ${${test}-STDERR}\n"
+ "Test ${test} output:\n"
+ "${out}\n"
+ "${err}")
+ endif()
+endforeach()