Add RunCMake.Syntax test to cover argument parsing
Test basic unquoted and quoted argument parsing cases including failure on an unterminated string and an unterminated command invocation. Also cover arguments not separated by any spaces, which is accidentally allowed by the current parser.
This commit is contained in:
parent
87e0e6e497
commit
f3155cd62a
|
@ -85,6 +85,7 @@ if(NOT WIN32)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
add_RunCMake_test(CompatibleInterface)
|
add_RunCMake_test(CompatibleInterface)
|
||||||
|
add_RunCMake_test(Syntax)
|
||||||
|
|
||||||
add_RunCMake_test(add_dependencies)
|
add_RunCMake_test(add_dependencies)
|
||||||
add_RunCMake_test(build_command)
|
add_RunCMake_test(build_command)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8.9)
|
||||||
|
project(${RunCMake_TEST} NONE)
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
|
@ -0,0 +1,9 @@
|
||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
run_cmake(String0)
|
||||||
|
run_cmake(String1)
|
||||||
|
run_cmake(StringNoSpace)
|
||||||
|
run_cmake(Unquoted0)
|
||||||
|
run_cmake(Unquoted1)
|
||||||
|
run_cmake(UnterminatedCall1)
|
||||||
|
run_cmake(UnterminatedString)
|
|
@ -0,0 +1 @@
|
||||||
|
^1 2;3 4$
|
|
@ -0,0 +1,2 @@
|
||||||
|
set(var 2 3)
|
||||||
|
message("1 ${var} 4")
|
|
@ -0,0 +1,3 @@
|
||||||
|
^
|
||||||
|
1 \${var} 4
|
||||||
|
$
|
|
@ -0,0 +1,3 @@
|
||||||
|
message("
|
||||||
|
1 \${var} 4
|
||||||
|
")
|
|
@ -0,0 +1,3 @@
|
||||||
|
^\[1 \${var} \\n 4\]
|
||||||
|
\[x\]
|
||||||
|
\[y\]$
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Quoted arguments may be immediately followed by another argument.
|
||||||
|
foreach(x "1 \${var} \\n 4""x"y)
|
||||||
|
message("[${x}]")
|
||||||
|
endforeach()
|
|
@ -0,0 +1 @@
|
||||||
|
^1234$
|
|
@ -0,0 +1,2 @@
|
||||||
|
set(var 2 3)
|
||||||
|
message(1 ${var} 4)
|
|
@ -0,0 +1 @@
|
||||||
|
^\[\]\[=\]\[\$\$\(MV\)-DSTR=" \[="\[;\]$
|
|
@ -0,0 +1 @@
|
||||||
|
message([] [=] [$ $(MV) -DSTR=" [=" [;])
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,7 @@
|
||||||
|
CMake Error: Error in cmake code at
|
||||||
|
.*/Syntax/UnterminatedCall1.cmake:2:
|
||||||
|
Parse error. Function missing ending "\)". End of file reached.
|
||||||
|
CMake Error at CMakeLists.txt:3 \(include\):
|
||||||
|
include could not find load file:
|
||||||
|
|
||||||
|
UnterminatedCall1.cmake
|
|
@ -0,0 +1 @@
|
||||||
|
message(
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,8 @@
|
||||||
|
CMake Error: Error in cmake code at
|
||||||
|
.*/Syntax/UnterminatedString.cmake:2:
|
||||||
|
Parse error. Function missing ending "\)". Instead found unterminated string with text "\)
|
||||||
|
".
|
||||||
|
CMake Error at CMakeLists.txt:3 \(include\):
|
||||||
|
include could not find load file:
|
||||||
|
|
||||||
|
UnterminatedString.cmake$
|
|
@ -0,0 +1 @@
|
||||||
|
set(var ")
|
Loading…
Reference in New Issue