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:
Brad King 2012-08-06 09:29:20 -04:00
parent 87e0e6e497
commit f3155cd62a
19 changed files with 53 additions and 0 deletions

View File

@ -85,6 +85,7 @@ if(NOT WIN32)
endif()
endif()
add_RunCMake_test(CompatibleInterface)
add_RunCMake_test(Syntax)
add_RunCMake_test(add_dependencies)
add_RunCMake_test(build_command)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.9)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -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)

View File

@ -0,0 +1 @@
^1 2;3 4$

View File

@ -0,0 +1,2 @@
set(var 2 3)
message("1 ${var} 4")

View File

@ -0,0 +1,3 @@
^
1 \${var} 4
$

View File

@ -0,0 +1,3 @@
message("
1 \${var} 4
")

View File

@ -0,0 +1,3 @@
^\[1 \${var} \\n 4\]
\[x\]
\[y\]$

View File

@ -0,0 +1,4 @@
# Quoted arguments may be immediately followed by another argument.
foreach(x "1 \${var} \\n 4""x"y)
message("[${x}]")
endforeach()

View File

@ -0,0 +1 @@
^1234$

View File

@ -0,0 +1,2 @@
set(var 2 3)
message(1 ${var} 4)

View File

@ -0,0 +1 @@
^\[\]\[=\]\[\$\$\(MV\)-DSTR=" \[="\[;\]$

View File

@ -0,0 +1 @@
message([] [=] [$ $(MV) -DSTR=" [=" [;])

View File

@ -0,0 +1 @@
1

View File

@ -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

View File

@ -0,0 +1 @@
message(

View File

@ -0,0 +1 @@
1

View File

@ -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$

View File

@ -0,0 +1 @@
set(var ")