diff options
author | Brad King <brad.king@kitware.com> | 2017-11-16 16:06:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-11-16 16:10:05 (GMT) |
commit | fb114a40aa29c73c067a357d843cd12e187e95dc (patch) | |
tree | f167a8397183cc49db0c81cd12d70d2db6307712 | |
parent | c1930caffe827b937d05dca9ffb82ba0b0b20eb2 (diff) | |
download | CMake-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
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/foreach/BadRangeInFunction-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/foreach/BadRangeInFunction.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/foreach/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/foreach/RunCMakeTest.cmake | 3 |
6 files changed, 18 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 5d584af..6b7b723 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -218,6 +218,7 @@ add_RunCMake_test(find_library) add_RunCMake_test(find_package) add_RunCMake_test(find_path) add_RunCMake_test(find_program -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(foreach) add_RunCMake_test(get_filename_component) add_RunCMake_test(get_property) add_RunCMake_test(if) 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) |