summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-08-06 13:29:20 (GMT)
committerBrad King <brad.king@kitware.com>2013-08-08 17:26:26 (GMT)
commitf3155cd62ab669afc9d21bc877d5eb452ed94a7d (patch)
tree05ac7c842e5df94dbd08894757893a14844d5fce
parent87e0e6e497b76f4ab7292cca34bd7c006832723b (diff)
downloadCMake-f3155cd62ab669afc9d21bc877d5eb452ed94a7d.zip
CMake-f3155cd62ab669afc9d21bc877d5eb452ed94a7d.tar.gz
CMake-f3155cd62ab669afc9d21bc877d5eb452ed94a7d.tar.bz2
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.
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/Syntax/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Syntax/RunCMakeTest.cmake9
-rw-r--r--Tests/RunCMake/Syntax/String0-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/String0.cmake2
-rw-r--r--Tests/RunCMake/Syntax/String1-stderr.txt3
-rw-r--r--Tests/RunCMake/Syntax/String1.cmake3
-rw-r--r--Tests/RunCMake/Syntax/StringNoSpace-stderr.txt3
-rw-r--r--Tests/RunCMake/Syntax/StringNoSpace.cmake4
-rw-r--r--Tests/RunCMake/Syntax/Unquoted0-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/Unquoted0.cmake2
-rw-r--r--Tests/RunCMake/Syntax/Unquoted1-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/Unquoted1.cmake1
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedCall1-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt7
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedCall1.cmake1
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedString-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedString-stderr.txt8
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedString.cmake1
19 files changed, 53 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1b9c17b..e45aba3 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 0000000..618473a
--- /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 0000000..4a3d462
--- /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 0000000..8eea069
--- /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 0000000..95281d7
--- /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 0000000..07e98da
--- /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 0000000..a94c9ff
--- /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 0000000..2d111aa
--- /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 0000000..76f22db
--- /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 0000000..ea68ebf
--- /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 0000000..c5314c9
--- /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 0000000..ff8194a
--- /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 0000000..0344fbd
--- /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 0000000..d00491f
--- /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 0000000..281ce0d
--- /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 0000000..1166109
--- /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 0000000..d00491f
--- /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 0000000..d925032
--- /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 0000000..721ae75
--- /dev/null
+++ b/Tests/RunCMake/Syntax/UnterminatedString.cmake
@@ -0,0 +1 @@
+set(var ")