Merge topic 'variable-expansion-tests'
a9bdef2d
tests: Add variable expansion tests
This commit is contained in:
commit
fb5b48bb27
|
@ -0,0 +1 @@
|
|||
-->wrong<--
|
|
@ -0,0 +1,9 @@
|
|||
set(right "wrong")
|
||||
set(var "\${right}")
|
||||
# Expanded here.
|
||||
set(ref "@var@")
|
||||
|
||||
# 'right' is dereferenced because 'var' was dereferenced when
|
||||
# assigning to 'ref' above.
|
||||
string(CONFIGURE "${ref}" output)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1 @@
|
|||
-->\${right}<--
|
|
@ -0,0 +1,8 @@
|
|||
set(right "wrong")
|
||||
set(var "\${right}")
|
||||
# Expanded here.
|
||||
set(ref "@var@")
|
||||
|
||||
# No dereference done at all.
|
||||
string(CONFIGURE "${ref}" output @ONLY)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1,5 @@
|
|||
-->==>\${right}<==
|
||||
==><==
|
||||
==>\${var}<==
|
||||
==>\${empty}<==
|
||||
<--
|
|
@ -0,0 +1,9 @@
|
|||
set(right "wrong")
|
||||
set(var "\${right}")
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/atfile.txt"
|
||||
@ONLY)
|
||||
file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1 @@
|
|||
-->\${right}<--
|
|
@ -0,0 +1,8 @@
|
|||
# Literal since 'var' is not defined.
|
||||
set(ref "@var@")
|
||||
set(right "wrong")
|
||||
set(var "\${right}")
|
||||
|
||||
# 'var' is dereferenced here.
|
||||
string(CONFIGURE "${ref}" output)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1 @@
|
|||
-->\${right}<--
|
|
@ -0,0 +1,8 @@
|
|||
# Literal since 'var' is not defined.
|
||||
set(ref "@var@")
|
||||
set(right "wrong")
|
||||
set(var "\${right}")
|
||||
|
||||
# 'var' is dereferenced, but now 'right'
|
||||
string(CONFIGURE "${ref}" output @ONLY)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1,5 @@
|
|||
-->==>\${right}<==
|
||||
==><==
|
||||
==>\${right}<==
|
||||
==><==
|
||||
<--
|
|
@ -0,0 +1,8 @@
|
|||
set(right "wrong")
|
||||
set(var "\${right}")
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/atfile.txt")
|
||||
file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1 @@
|
|||
-->"<--
|
|
@ -0,0 +1,9 @@
|
|||
set(var "\"")
|
||||
set(ref "@var@")
|
||||
set(rref "\${var}")
|
||||
|
||||
string(CONFIGURE "${ref}" output ESCAPE_QUOTES)
|
||||
message("-->${output}<--")
|
||||
|
||||
string(CONFIGURE "${rref}" output ESCAPE_QUOTES)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1 @@
|
|||
-->\\n<--
|
|
@ -0,0 +1,5 @@
|
|||
set(var "n")
|
||||
set(ref "\\@var@")
|
||||
|
||||
string(CONFIGURE "${ref}" output)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1 @@
|
|||
-->@foo@<--
|
|
@ -0,0 +1,6 @@
|
|||
set("\${varname}" bar)
|
||||
set(var foo)
|
||||
set(ref "@\${var}@")
|
||||
|
||||
string(CONFIGURE "${ref}" output)
|
||||
message("-->${output}<--")
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1,20 @@
|
|||
CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Error at ParenInENV.cmake:2 \(message\):
|
||||
Syntax error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/ParenInENV.cmake:2
|
||||
|
||||
when parsing string
|
||||
|
||||
-->\$ENV{e
|
||||
|
||||
syntax error, unexpected \$end, expecting } \(9\)
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,2 @@
|
|||
set("ENV{e(x)}" value)
|
||||
message(-->$ENV{e(x)}<--)
|
|
@ -0,0 +1 @@
|
|||
-->value<--
|
|
@ -0,0 +1,2 @@
|
|||
set("ENV{e(x)}" value)
|
||||
message("-->$ENV{e(x)}<--")
|
|
@ -52,3 +52,16 @@ run_cmake(UnterminatedString)
|
|||
run_cmake(UnterminatedBracket0)
|
||||
run_cmake(UnterminatedBracket1)
|
||||
run_cmake(UnterminatedBracketComment)
|
||||
|
||||
# Variable expansion tests
|
||||
run_cmake(ExpandInAt)
|
||||
run_cmake(EscapedAt)
|
||||
run_cmake(EscapeQuotes)
|
||||
run_cmake(AtWithVariable)
|
||||
run_cmake(AtWithVariableEmptyExpansion)
|
||||
run_cmake(AtWithVariableAtOnly)
|
||||
run_cmake(AtWithVariableEmptyExpansionAtOnly)
|
||||
run_cmake(AtWithVariableFile)
|
||||
run_cmake(AtWithVariableAtOnlyFile)
|
||||
run_cmake(ParenInENV)
|
||||
run_cmake(ParenInQuotedENV)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
==>@var@<==
|
||||
==>@empty@<==
|
||||
==>${var}<==
|
||||
==>${empty}<==
|
Loading…
Reference in New Issue