From f3155cd62ab669afc9d21bc877d5eb452ed94a7d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 6 Aug 2012 09:29:20 -0400 Subject: [PATCH] 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. --- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/Syntax/CMakeLists.txt | 3 +++ Tests/RunCMake/Syntax/RunCMakeTest.cmake | 9 +++++++++ Tests/RunCMake/Syntax/String0-stderr.txt | 1 + Tests/RunCMake/Syntax/String0.cmake | 2 ++ Tests/RunCMake/Syntax/String1-stderr.txt | 3 +++ Tests/RunCMake/Syntax/String1.cmake | 3 +++ Tests/RunCMake/Syntax/StringNoSpace-stderr.txt | 3 +++ Tests/RunCMake/Syntax/StringNoSpace.cmake | 4 ++++ Tests/RunCMake/Syntax/Unquoted0-stderr.txt | 1 + Tests/RunCMake/Syntax/Unquoted0.cmake | 2 ++ Tests/RunCMake/Syntax/Unquoted1-stderr.txt | 1 + Tests/RunCMake/Syntax/Unquoted1.cmake | 1 + Tests/RunCMake/Syntax/UnterminatedCall1-result.txt | 1 + Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt | 7 +++++++ Tests/RunCMake/Syntax/UnterminatedCall1.cmake | 1 + Tests/RunCMake/Syntax/UnterminatedString-result.txt | 1 + Tests/RunCMake/Syntax/UnterminatedString-stderr.txt | 8 ++++++++ Tests/RunCMake/Syntax/UnterminatedString.cmake | 1 + 19 files changed, 53 insertions(+) create mode 100644 Tests/RunCMake/Syntax/CMakeLists.txt create mode 100644 Tests/RunCMake/Syntax/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/Syntax/String0-stderr.txt create mode 100644 Tests/RunCMake/Syntax/String0.cmake create mode 100644 Tests/RunCMake/Syntax/String1-stderr.txt create mode 100644 Tests/RunCMake/Syntax/String1.cmake create mode 100644 Tests/RunCMake/Syntax/StringNoSpace-stderr.txt create mode 100644 Tests/RunCMake/Syntax/StringNoSpace.cmake create mode 100644 Tests/RunCMake/Syntax/Unquoted0-stderr.txt create mode 100644 Tests/RunCMake/Syntax/Unquoted0.cmake create mode 100644 Tests/RunCMake/Syntax/Unquoted1-stderr.txt create mode 100644 Tests/RunCMake/Syntax/Unquoted1.cmake create mode 100644 Tests/RunCMake/Syntax/UnterminatedCall1-result.txt create mode 100644 Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt create mode 100644 Tests/RunCMake/Syntax/UnterminatedCall1.cmake create mode 100644 Tests/RunCMake/Syntax/UnterminatedString-result.txt create mode 100644 Tests/RunCMake/Syntax/UnterminatedString-stderr.txt create mode 100644 Tests/RunCMake/Syntax/UnterminatedString.cmake diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 1b9c17bd7..e45aba378 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -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) diff --git a/Tests/RunCMake/Syntax/CMakeLists.txt b/Tests/RunCMake/Syntax/CMakeLists.txt new file mode 100644 index 000000000..618473aaa --- /dev/null +++ b/Tests/RunCMake/Syntax/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.9) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake new file mode 100644 index 000000000..4a3d462b7 --- /dev/null +++ b/Tests/RunCMake/Syntax/RunCMakeTest.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) diff --git a/Tests/RunCMake/Syntax/String0-stderr.txt b/Tests/RunCMake/Syntax/String0-stderr.txt new file mode 100644 index 000000000..8eea0695c --- /dev/null +++ b/Tests/RunCMake/Syntax/String0-stderr.txt @@ -0,0 +1 @@ +^1 2;3 4$ diff --git a/Tests/RunCMake/Syntax/String0.cmake b/Tests/RunCMake/Syntax/String0.cmake new file mode 100644 index 000000000..95281d73f --- /dev/null +++ b/Tests/RunCMake/Syntax/String0.cmake @@ -0,0 +1,2 @@ +set(var 2 3) +message("1 ${var} 4") diff --git a/Tests/RunCMake/Syntax/String1-stderr.txt b/Tests/RunCMake/Syntax/String1-stderr.txt new file mode 100644 index 000000000..07e98dae0 --- /dev/null +++ b/Tests/RunCMake/Syntax/String1-stderr.txt @@ -0,0 +1,3 @@ +^ + 1 \${var} 4 + $ diff --git a/Tests/RunCMake/Syntax/String1.cmake b/Tests/RunCMake/Syntax/String1.cmake new file mode 100644 index 000000000..a94c9ffdb --- /dev/null +++ b/Tests/RunCMake/Syntax/String1.cmake @@ -0,0 +1,3 @@ +message(" + 1 \${var} 4 + ") diff --git a/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt b/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt new file mode 100644 index 000000000..2d111aaa8 --- /dev/null +++ b/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt @@ -0,0 +1,3 @@ +^\[1 \${var} \\n 4\] +\[x\] +\[y\]$ diff --git a/Tests/RunCMake/Syntax/StringNoSpace.cmake b/Tests/RunCMake/Syntax/StringNoSpace.cmake new file mode 100644 index 000000000..76f22db9a --- /dev/null +++ b/Tests/RunCMake/Syntax/StringNoSpace.cmake @@ -0,0 +1,4 @@ +# Quoted arguments may be immediately followed by another argument. +foreach(x "1 \${var} \\n 4""x"y) + message("[${x}]") +endforeach() diff --git a/Tests/RunCMake/Syntax/Unquoted0-stderr.txt b/Tests/RunCMake/Syntax/Unquoted0-stderr.txt new file mode 100644 index 000000000..ea68ebfa9 --- /dev/null +++ b/Tests/RunCMake/Syntax/Unquoted0-stderr.txt @@ -0,0 +1 @@ +^1234$ diff --git a/Tests/RunCMake/Syntax/Unquoted0.cmake b/Tests/RunCMake/Syntax/Unquoted0.cmake new file mode 100644 index 000000000..c5314c9f0 --- /dev/null +++ b/Tests/RunCMake/Syntax/Unquoted0.cmake @@ -0,0 +1,2 @@ +set(var 2 3) +message(1 ${var} 4) diff --git a/Tests/RunCMake/Syntax/Unquoted1-stderr.txt b/Tests/RunCMake/Syntax/Unquoted1-stderr.txt new file mode 100644 index 000000000..ff8194a6f --- /dev/null +++ b/Tests/RunCMake/Syntax/Unquoted1-stderr.txt @@ -0,0 +1 @@ +^\[\]\[=\]\[\$\$\(MV\)-DSTR=" \[="\[;\]$ diff --git a/Tests/RunCMake/Syntax/Unquoted1.cmake b/Tests/RunCMake/Syntax/Unquoted1.cmake new file mode 100644 index 000000000..0344fbd59 --- /dev/null +++ b/Tests/RunCMake/Syntax/Unquoted1.cmake @@ -0,0 +1 @@ +message([] [=] [$ $(MV) -DSTR=" [=" [;]) diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1-result.txt b/Tests/RunCMake/Syntax/UnterminatedCall1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/Syntax/UnterminatedCall1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt new file mode 100644 index 000000000..281ce0da8 --- /dev/null +++ b/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt @@ -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 diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1.cmake b/Tests/RunCMake/Syntax/UnterminatedCall1.cmake new file mode 100644 index 000000000..1166109c9 --- /dev/null +++ b/Tests/RunCMake/Syntax/UnterminatedCall1.cmake @@ -0,0 +1 @@ +message( diff --git a/Tests/RunCMake/Syntax/UnterminatedString-result.txt b/Tests/RunCMake/Syntax/UnterminatedString-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/Syntax/UnterminatedString-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Syntax/UnterminatedString-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedString-stderr.txt new file mode 100644 index 000000000..d9250328d --- /dev/null +++ b/Tests/RunCMake/Syntax/UnterminatedString-stderr.txt @@ -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$ diff --git a/Tests/RunCMake/Syntax/UnterminatedString.cmake b/Tests/RunCMake/Syntax/UnterminatedString.cmake new file mode 100644 index 000000000..721ae7510 --- /dev/null +++ b/Tests/RunCMake/Syntax/UnterminatedString.cmake @@ -0,0 +1 @@ +set(var ")