summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/foreach
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-16 16:06:11 (GMT)
committerBrad King <brad.king@kitware.com>2017-11-16 16:10:05 (GMT)
commitfb114a40aa29c73c067a357d843cd12e187e95dc (patch)
treef167a8397183cc49db0c81cd12d70d2db6307712 /Tests/RunCMake/foreach
parentc1930caffe827b937d05dca9ffb82ba0b0b20eb2 (diff)
downloadCMake-fb114a40aa29c73c067a357d843cd12e187e95dc.zip
CMake-fb114a40aa29c73c067a357d843cd12e187e95dc.tar.gz
CMake-fb114a40aa29c73c067a357d843cd12e187e95dc.tar.bz2
Tests: Add test for bad foreach inside a function
Add test for a case fixed by commit 6a4a61d9e1 (cmForEachCommand: prevent leakage, 2017-10-09). Prior to that fix, this test case could trigger an assertion failure. Fixes: #17464
Diffstat (limited to 'Tests/RunCMake/foreach')
-rw-r--r--Tests/RunCMake/foreach/BadRangeInFunction-result.txt1
-rw-r--r--Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt5
-rw-r--r--Tests/RunCMake/foreach/BadRangeInFunction.cmake5
-rw-r--r--Tests/RunCMake/foreach/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/foreach/RunCMakeTest.cmake3
5 files changed, 17 insertions, 0 deletions
diff --git a/Tests/RunCMake/foreach/BadRangeInFunction-result.txt b/Tests/RunCMake/foreach/BadRangeInFunction-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/foreach/BadRangeInFunction-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt b/Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt
new file mode 100644
index 0000000..e16a0f1
--- /dev/null
+++ b/Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at BadRangeInFunction.cmake:2 \(foreach\):
+ foreach called with incorrect range specification: start 2, stop 1, step 1
+Call Stack \(most recent call first\):
+ BadRangeInFunction.cmake:5 \(func\)
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/foreach/BadRangeInFunction.cmake b/Tests/RunCMake/foreach/BadRangeInFunction.cmake
new file mode 100644
index 0000000..f51cbbf
--- /dev/null
+++ b/Tests/RunCMake/foreach/BadRangeInFunction.cmake
@@ -0,0 +1,5 @@
+function(func)
+ foreach(bad_range RANGE 2 1 1)
+ endforeach()
+endfunction()
+func()
diff --git a/Tests/RunCMake/foreach/CMakeLists.txt b/Tests/RunCMake/foreach/CMakeLists.txt
new file mode 100644
index 0000000..bf2ef15
--- /dev/null
+++ b/Tests/RunCMake/foreach/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.10)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake
new file mode 100644
index 0000000..4b74cfe
--- /dev/null
+++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(BadRangeInFunction)