mirror of
https://github.com/reactos/CMake.git
synced 2024-11-25 12:40:06 +00:00
tests: Add variable expansion tests
There are some corner cases in variable expansion which would be nice to capture before going and rewriting the variable expansion code. The majority of these are related to configuring files and strings with '@' in them in conjunction with @ONLY being specified. Another is testing for '(' usage inside of ENV variable references based on whether it is quoted or not.
This commit is contained in:
parent
c0bbefbfe7
commit
a9bdef2dda
1
Tests/RunCMake/Syntax/AtWithVariable-stderr.txt
Normal file
1
Tests/RunCMake/Syntax/AtWithVariable-stderr.txt
Normal file
@ -0,0 +1 @@
|
||||
-->wrong<--
|
9
Tests/RunCMake/Syntax/AtWithVariable.cmake
Normal file
9
Tests/RunCMake/Syntax/AtWithVariable.cmake
Normal file
@ -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}<--")
|
1
Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt
Normal file
1
Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt
Normal file
@ -0,0 +1 @@
|
||||
-->\${right}<--
|
8
Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake
Normal file
8
Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake
Normal file
@ -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}<==
|
||||
<--
|
9
Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake
Normal file
9
Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake
Normal file
@ -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}<--
|
8
Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake
Normal file
8
Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake
Normal file
@ -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}<--")
|
5
Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt
Normal file
5
Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt
Normal file
@ -0,0 +1,5 @@
|
||||
-->==>\${right}<==
|
||||
==><==
|
||||
==>\${right}<==
|
||||
==><==
|
||||
<--
|
8
Tests/RunCMake/Syntax/AtWithVariableFile.cmake
Normal file
8
Tests/RunCMake/Syntax/AtWithVariableFile.cmake
Normal file
@ -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}<--")
|
1
Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt
Normal file
1
Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt
Normal file
@ -0,0 +1 @@
|
||||
-->"<--
|
9
Tests/RunCMake/Syntax/EscapeQuotes.cmake
Normal file
9
Tests/RunCMake/Syntax/EscapeQuotes.cmake
Normal file
@ -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}<--")
|
1
Tests/RunCMake/Syntax/EscapedAt-stderr.txt
Normal file
1
Tests/RunCMake/Syntax/EscapedAt-stderr.txt
Normal file
@ -0,0 +1 @@
|
||||
-->\\n<--
|
5
Tests/RunCMake/Syntax/EscapedAt.cmake
Normal file
5
Tests/RunCMake/Syntax/EscapedAt.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
set(var "n")
|
||||
set(ref "\\@var@")
|
||||
|
||||
string(CONFIGURE "${ref}" output)
|
||||
message("-->${output}<--")
|
1
Tests/RunCMake/Syntax/ExpandInAt-stderr.txt
Normal file
1
Tests/RunCMake/Syntax/ExpandInAt-stderr.txt
Normal file
@ -0,0 +1 @@
|
||||
-->@foo@<--
|
6
Tests/RunCMake/Syntax/ExpandInAt.cmake
Normal file
6
Tests/RunCMake/Syntax/ExpandInAt.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
set("\${varname}" bar)
|
||||
set(var foo)
|
||||
set(ref "@\${var}@")
|
||||
|
||||
string(CONFIGURE "${ref}" output)
|
||||
message("-->${output}<--")
|
1
Tests/RunCMake/Syntax/ParenInENV-result.txt
Normal file
1
Tests/RunCMake/Syntax/ParenInENV-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
20
Tests/RunCMake/Syntax/ParenInENV-stderr.txt
Normal file
20
Tests/RunCMake/Syntax/ParenInENV-stderr.txt
Normal file
@ -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\)
|
2
Tests/RunCMake/Syntax/ParenInENV.cmake
Normal file
2
Tests/RunCMake/Syntax/ParenInENV.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
set("ENV{e(x)}" value)
|
||||
message(-->$ENV{e(x)}<--)
|
1
Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt
Normal file
1
Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt
Normal file
@ -0,0 +1 @@
|
||||
-->value<--
|
2
Tests/RunCMake/Syntax/ParenInQuotedENV.cmake
Normal file
2
Tests/RunCMake/Syntax/ParenInQuotedENV.cmake
Normal file
@ -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)
|
||||
|
4
Tests/RunCMake/Syntax/atfile.txt.in
Normal file
4
Tests/RunCMake/Syntax/atfile.txt.in
Normal file
@ -0,0 +1,4 @@
|
||||
==>@var@<==
|
||||
==>@empty@<==
|
||||
==>${var}<==
|
||||
==>${empty}<==
|
Loading…
Reference in New Issue
Block a user