summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmForEachCommand.cxx1
-rw-r--r--Tests/RunCMake/foreach/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt1
-rw-r--r--Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt4
-rw-r--r--Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake2
5 files changed, 9 insertions, 0 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 08e51ad..0546186 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -428,6 +428,7 @@ bool cmForEachCommand(std::vector<std::string> const& args,
status.SetError(
cmStrCat("called with incorrect range specification: start ", start,
", stop ", stop, ", step ", step));
+ cmSystemTools::SetFatalErrorOccured();
return false;
}
diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake
index 6bb0683..22a0a75 100644
--- a/Tests/RunCMake/foreach/RunCMakeTest.cmake
+++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake
@@ -18,3 +18,4 @@ run_cmake(foreach-RANGE-non-int-test-2-2)
run_cmake(foreach-RANGE-non-int-test-3-1)
run_cmake(foreach-RANGE-non-int-test-3-2)
run_cmake(foreach-RANGE-non-int-test-3-3)
+run_cmake(foreach-RANGE-invalid-test)
diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt
new file mode 100644
index 0000000..66efdc1
--- /dev/null
+++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at foreach-RANGE-invalid-test\.cmake:[0-9]+ \(foreach\):
+ foreach called with incorrect range specification: start 2, stop 1, step 1
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:3 \(include\)$
diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake
new file mode 100644
index 0000000..2f8eaba
--- /dev/null
+++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake
@@ -0,0 +1,2 @@
+foreach(a RANGE 2 1 1)
+endforeach()