Skip to content

Commit

Permalink
Improve debug output of TestFileExists
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwe committed Jan 12, 2025
1 parent 0c1c611 commit f783ee8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/TestFileExists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,19 @@ endif()
set(FILE_PATH "${CMAKE_ARGV3}")

if(NOT ( EXISTS "${FILE_PATH}" ))
message(FATAL_ERROR "Test failed: File `${FILE_PATH}` does not exist.")
set(error_details "File `${FILE_PATH}` does not exist!\n")
set(PARENT_TREE "${FILE_PATH}")
cmake_path(HAS_PARENT_PATH PARENT_TREE has_parent)
while(has_parent)
cmake_path(GET PARENT_TREE PARENT_PATH PARENT_TREE)
cmake_path(HAS_PARENT_PATH PARENT_TREE has_parent)
if(EXISTS "${PARENT_TREE}")
file(GLOB dir_contents LIST_DIRECTORIES true "${PARENT_TREE}/*")
list(APPEND error_details "Found Parent directory `${PARENT_TREE}` exists and contains:\n" ${dir_contents})
break()
else()
list(APPEND error_details "Parent directory `${PARENT_TREE}` also does not exist!")
endif()
endwhile()
message(FATAL_ERROR "Test failed: ${error_details}")
endif()

0 comments on commit f783ee8

Please sign in to comment.