mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-25 18:28:57 -06:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
1
Tests/RunCMake/foreach/BadRangeInFunction-result.txt
Normal file
1
Tests/RunCMake/foreach/BadRangeInFunction-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
5
Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt
Normal file
5
Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt
Normal file
@@ -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\)$
|
||||
5
Tests/RunCMake/foreach/BadRangeInFunction.cmake
Normal file
5
Tests/RunCMake/foreach/BadRangeInFunction.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
function(func)
|
||||
foreach(bad_range RANGE 2 1 1)
|
||||
endforeach()
|
||||
endfunction()
|
||||
func()
|
||||
3
Tests/RunCMake/foreach/CMakeLists.txt
Normal file
3
Tests/RunCMake/foreach/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
3
Tests/RunCMake/foreach/RunCMakeTest.cmake
Normal file
3
Tests/RunCMake/foreach/RunCMakeTest.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(BadRangeInFunction)
|
||||
Reference in New Issue
Block a user