mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
set: Add test cases for setting ENV{VAR} to empty
The behavior differs by platform and if the variable is already set. Encode existing behavior in tests to preserve it until intentionally changed. Issue: #27285
This commit is contained in:
2
Tests/RunCMake/set/Env-stdout-windows.txt
Normal file
2
Tests/RunCMake/set/Env-stdout-windows.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
^-- ENV{UNSET_THEN_EMPTY} is not defined
|
||||
-- ENV{SET_THEN_EMPTY} is not defined$
|
2
Tests/RunCMake/set/Env-stdout.txt
Normal file
2
Tests/RunCMake/set/Env-stdout.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
^-- ENV{UNSET_THEN_EMPTY} is not defined
|
||||
-- ENV{SET_THEN_EMPTY} is defined to ''$
|
15
Tests/RunCMake/set/Env.cmake
Normal file
15
Tests/RunCMake/set/Env.cmake
Normal file
@@ -0,0 +1,15 @@
|
||||
unset(ENV{UNSET_THEN_EMPTY})
|
||||
set(ENV{UNSET_THEN_EMPTY} "")
|
||||
if(DEFINED ENV{UNSET_THEN_EMPTY})
|
||||
message(STATUS "ENV{UNSET_THEN_EMPTY} is defined to '$ENV{UNSET_THEN_EMPTY}'")
|
||||
else()
|
||||
message(STATUS "ENV{UNSET_THEN_EMPTY} is not defined")
|
||||
endif()
|
||||
|
||||
set(ENV{SET_THEN_EMPTY} "set")
|
||||
set(ENV{SET_THEN_EMPTY} "")
|
||||
if(DEFINED ENV{SET_THEN_EMPTY})
|
||||
message(STATUS "ENV{SET_THEN_EMPTY} is defined to '$ENV{SET_THEN_EMPTY}'")
|
||||
else()
|
||||
message(STATUS "ENV{SET_THEN_EMPTY} is not defined")
|
||||
endif()
|
@@ -12,3 +12,6 @@ run_cmake(CacheUnknownArguments)
|
||||
run_cmake(CacheMissingArguments)
|
||||
run_cmake(CacheWrongTYPE)
|
||||
run_cmake(CacheSetUnset)
|
||||
|
||||
# set(ENV{}) syntax
|
||||
run_cmake_script(Env)
|
||||
|
Reference in New Issue
Block a user