if: Add test for IS_DIRECTORY
Add a RunCMake.if test to cover if() command behavior. Start with a test for IS_DIRECTORY cases with an existing directory and a long path, both with a trailing slash.
This commit is contained in:
parent
4ab10e063d
commit
7378792b49
@ -72,6 +72,7 @@ add_RunCMake_test(add_dependencies)
|
||||
add_RunCMake_test(build_command)
|
||||
add_RunCMake_test(find_package)
|
||||
add_RunCMake_test(get_filename_component)
|
||||
add_RunCMake_test(if)
|
||||
add_RunCMake_test(include)
|
||||
add_RunCMake_test(include_directories)
|
||||
add_RunCMake_test(list)
|
||||
|
3
Tests/RunCMake/if/CMakeLists.txt
Normal file
3
Tests/RunCMake/if/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
1
Tests/RunCMake/if/IsDirectory-stdout.txt
Normal file
1
Tests/RunCMake/if/IsDirectory-stdout.txt
Normal file
@ -0,0 +1 @@
|
||||
CMAKE_CURRENT_SOURCE_DIR exists, tested with trailing slash
|
5
Tests/RunCMake/if/IsDirectory.cmake
Normal file
5
Tests/RunCMake/if/IsDirectory.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/")
|
||||
message(STATUS "CMAKE_CURRENT_SOURCE_DIR exists, tested with trailing slash")
|
||||
else()
|
||||
message(FATAL_ERROR "CMAKE_CURRENT_SOURCE_DIR does not exist!")
|
||||
endif()
|
1
Tests/RunCMake/if/IsDirectoryLong-stdout.txt
Normal file
1
Tests/RunCMake/if/IsDirectoryLong-stdout.txt
Normal file
@ -0,0 +1 @@
|
||||
Directory path with length 94208 correctly does not exist.
|
10
Tests/RunCMake/if/IsDirectoryLong.cmake
Normal file
10
Tests/RunCMake/if/IsDirectoryLong.cmake
Normal file
@ -0,0 +1,10 @@
|
||||
set(d "/long/path/to/directory")
|
||||
foreach(i RANGE 11)
|
||||
set(d "${d}${d}")
|
||||
endforeach()
|
||||
string(LENGTH "${d}" dl)
|
||||
if(IS_DIRECTORY "${d}/")
|
||||
message(FATAL_ERROR "Directory should not exist!")
|
||||
else()
|
||||
message(STATUS "Directory path with length ${dl} correctly does not exist.")
|
||||
endif()
|
4
Tests/RunCMake/if/RunCMakeTest.cmake
Normal file
4
Tests/RunCMake/if/RunCMakeTest.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(IsDirectory)
|
||||
run_cmake(IsDirectoryLong)
|
Loading…
x
Reference in New Issue
Block a user