Skip to content

Commit f783ee8

Browse files
committed
Improve debug output of TestFileExists
1 parent 0c1c611 commit f783ee8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/TestFileExists.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,19 @@ endif()
99
set(FILE_PATH "${CMAKE_ARGV3}")
1010

1111
if(NOT ( EXISTS "${FILE_PATH}" ))
12-
message(FATAL_ERROR "Test failed: File `${FILE_PATH}` does not exist.")
12+
set(error_details "File `${FILE_PATH}` does not exist!\n")
13+
set(PARENT_TREE "${FILE_PATH}")
14+
cmake_path(HAS_PARENT_PATH PARENT_TREE has_parent)
15+
while(has_parent)
16+
cmake_path(GET PARENT_TREE PARENT_PATH PARENT_TREE)
17+
cmake_path(HAS_PARENT_PATH PARENT_TREE has_parent)
18+
if(EXISTS "${PARENT_TREE}")
19+
file(GLOB dir_contents LIST_DIRECTORIES true "${PARENT_TREE}/*")
20+
list(APPEND error_details "Found Parent directory `${PARENT_TREE}` exists and contains:\n" ${dir_contents})
21+
break()
22+
else()
23+
list(APPEND error_details "Parent directory `${PARENT_TREE}` also does not exist!")
24+
endif()
25+
endwhile()
26+
message(FATAL_ERROR "Test failed: ${error_details}")
1327
endif()

0 commit comments

Comments
 (0)