summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2015-03-17 22:34:03 (GMT)
committerBrad King <brad.king@kitware.com>2015-03-20 13:45:25 (GMT)
commita2c068a7ce47ab5934735b9f9168dda9760646ec (patch)
treeb6619fd89eebce8675685db87ab7deadc28b39de /Tests
parenta5cab2e7391df8d2072f1083c075a69bc746c7aa (diff)
downloadCMake-a2c068a7ce47ab5934735b9f9168dda9760646ec.zip
CMake-a2c068a7ce47ab5934735b9f9168dda9760646ec.tar.gz
CMake-a2c068a7ce47ab5934735b9f9168dda9760646ec.tar.bz2
file: Teach GLOB to list directories optionally
GLOB lists directories by default and GLOB_RECURSE does not. LIST_DIRECTORIES enables user to control the behavior explicitly for consistently for both GLOB and GLOB_RECURSE.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-result.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-stderr.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg.cmake1
-rw-r--r--Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-result.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-stderr.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean.cmake1
-rw-r--r--Tests/RunCMake/file/GLOB-stderr.txt6
-rw-r--r--Tests/RunCMake/file/GLOB.cmake28
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion-stderr.txt15
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake23
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-stderr.txt6
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE.cmake28
-rw-r--r--Tests/RunCMake/file/RunCMakeTest.cmake10
13 files changed, 122 insertions, 0 deletions
diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-result.txt b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-stderr.txt b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-stderr.txt
new file mode 100644
index 0000000..9629cfd
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-stderr.txt
@@ -0,0 +1 @@
+.*file LIST_DIRECTORIES missing bool value\.
diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg.cmake b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg.cmake
new file mode 100644
index 0000000..a8e15f2
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg.cmake
@@ -0,0 +1 @@
+file(GLOB CONTENT_LIST LIST_DIRECTORIES)
diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-result.txt b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-stderr.txt b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-stderr.txt
new file mode 100644
index 0000000..9629cfd
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-stderr.txt
@@ -0,0 +1 @@
+.*file LIST_DIRECTORIES missing bool value\.
diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean.cmake b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean.cmake
new file mode 100644
index 0000000..f735433
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean.cmake
@@ -0,0 +1 @@
+file(GLOB CONTENT_LIST LIST_DIRECTORIES 13)
diff --git a/Tests/RunCMake/file/GLOB-stderr.txt b/Tests/RunCMake/file/GLOB-stderr.txt
new file mode 100644
index 0000000..c47dc40
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-stderr.txt
@@ -0,0 +1,6 @@
+content: 6[ ]
+.*/test/dir 1/dir 1 file;.*/test/dir 1/empty_dir;.*/test/dir 1/non_empty_dir;.*/test/dir 2/dir 2 file;.*/test/dir 2/empty_dir;.*/test/dir 2/non_empty_dir
+content: 6[ ]
+.*/test/dir 1/dir 1 file;.*/test/dir 1/empty_dir;.*/test/dir 1/non_empty_dir;.*/test/dir 2/dir 2 file;.*/test/dir 2/empty_dir;.*/test/dir 2/non_empty_dir
+content: 2[ ]
+.*/test/dir 1/dir 1 file;.*/test/dir 2/dir 2 file
diff --git a/Tests/RunCMake/file/GLOB.cmake b/Tests/RunCMake/file/GLOB.cmake
new file mode 100644
index 0000000..3d577e3
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB.cmake
@@ -0,0 +1,28 @@
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/empty_dir")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/empty_dir")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/dir 1 file" "test file")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir/dir 1 subdir file" "test file")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/dir 2 file" "test file")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir file" "test file")
+
+file(GLOB CONTENT_LIST "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
+
+file(GLOB CONTENT_LIST LIST_DIRECTORIES true "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
+
+file(GLOB CONTENT_LIST LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion-stderr.txt b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion-stderr.txt
new file mode 100644
index 0000000..f73aa83
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion-stderr.txt
@@ -0,0 +1,15 @@
+.*Cyclic recursion detected while globbing for.*
+.*/test/depth1/depth2/depth3.*
+.*/test/depth1/depth2/depth3/recursion.*
+content: 4[ ]
+.*/test/abc;.*/test/depth1/depth2/depth3/file_symlink;.*/test/depth1/depth2/depth3/recursion/abc;.*/test/depth1/depth2/depth3/recursion/depth1/depth2/depth3/file_symlink
+.*Cyclic recursion detected while globbing for.*
+.*/test/depth1/depth2/depth3.*
+.*/test/depth1/depth2/depth3/recursion.*
+content: 4[ ]
+.*/test/abc;.*/test/depth1/depth2/depth3/file_symlink;.*/test/depth1/depth2/depth3/recursion/abc;.*/test/depth1/depth2/depth3/recursion/depth1/depth2/depth3/file_symlink
+.*Cyclic recursion detected while globbing for.*
+.*/test/depth1/depth2/depth3.*
+.*/test/depth1/depth2/depth3/recursion.*
+content: 11[ ]
+.*/test/abc;.*/test/depth1;.*/test/depth1/depth2;.*/test/depth1/depth2/depth3;.*/test/depth1/depth2/depth3/file_symlink;.*/test/depth1/depth2/depth3/recursion;.*/test/depth1/depth2/depth3/recursion/abc;.*/test/depth1/depth2/depth3/recursion/depth1;.*/test/depth1/depth2/depth3/recursion/depth1/depth2;.*/test/depth1/depth2/depth3/recursion/depth1/depth2/depth3;.*/test/depth1/depth2/depth3/recursion/depth1/depth2/depth3/file_symlink
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake
new file mode 100644
index 0000000..a8c6784
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake
@@ -0,0 +1,23 @@
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/depth1/depth2/depth3")
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/test" "${CMAKE_CURRENT_BINARY_DIR}/test/depth1/depth2/depth3/recursion")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/abc" "message to write")
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/test/abc" "${CMAKE_CURRENT_BINARY_DIR}/test/depth1/depth2/depth3/file_symlink")
+
+file(GLOB_RECURSE CONTENT_LIST FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
+
+file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES false FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
+
+file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES true FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-stderr.txt b/Tests/RunCMake/file/GLOB_RECURSE-stderr.txt
new file mode 100644
index 0000000..5d48e47
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE-stderr.txt
@@ -0,0 +1,6 @@
+content: 4[ ]
+.*/test/dir 1/dir 1 file;.*/test/dir 1/non_empty_dir/dir 1 subdir file;.*/test/dir 2/dir 2 file;.*/test/dir 2/non_empty_dir/dir 2 subdir file
+content: 4[ ]
+.*/test/dir 1/dir 1 file;.*/test/dir 1/non_empty_dir/dir 1 subdir file;.*/test/dir 2/dir 2 file;.*/test/dir 2/non_empty_dir/dir 2 subdir file
+content: 8[ ]
+.*/test/dir 1/dir 1 file;.*/test/dir 1/empty_dir;.*/test/dir 1/non_empty_dir;.*/test/dir 1/non_empty_dir/dir 1 subdir file;.*/test/dir 2/dir 2 file;.*/test/dir 2/empty_dir;.*/test/dir 2/non_empty_dir;.*/test/dir 2/non_empty_dir/dir 2 subdir file
diff --git a/Tests/RunCMake/file/GLOB_RECURSE.cmake b/Tests/RunCMake/file/GLOB_RECURSE.cmake
new file mode 100644
index 0000000..6db377b
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE.cmake
@@ -0,0 +1,28 @@
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/empty_dir")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/empty_dir")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/dir 1 file" "test file")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir/dir 1 subdir file" "test file")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/dir 2 file" "test file")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir file" "test file")
+
+file(GLOB_RECURSE CONTENT_LIST "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
+
+file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
+
+file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES true "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+list(SORT CONTENT_LIST)
+message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake
index 14819e7..d3dfb1b 100644
--- a/Tests/RunCMake/file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/file/RunCMakeTest.cmake
@@ -17,3 +17,13 @@ run_cmake(LOCK-error-no-result-variable)
run_cmake(LOCK-error-no-timeout)
run_cmake(LOCK-error-timeout)
run_cmake(LOCK-error-unknown-option)
+run_cmake(GLOB)
+run_cmake(GLOB_RECURSE)
+# test is valid both for GLOB and GLOB_RECURSE
+run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean)
+# test is valid both for GLOB and GLOB_RECURSE
+run_cmake(GLOB-error-LIST_DIRECTORIES-no-arg)
+
+if(NOT WIN32 OR CYGWIN)
+ run_cmake(GLOB_RECURSE-cyclic-recursion)
+endif()