diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2018-10-11 21:26:44 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2018-10-16 18:31:39 (GMT) |
commit | 121a036f73665a18ccadeaf50b00cc623d8ed9df (patch) | |
tree | f361e2403c53546425781713b7bdeb57e5ba9389 /Tests | |
parent | acfe53c58817c662b935fbe0f0443de298371731 (diff) | |
download | CMake-121a036f73665a18ccadeaf50b00cc623d8ed9df.zip CMake-121a036f73665a18ccadeaf50b00cc623d8ed9df.tar.gz CMake-121a036f73665a18ccadeaf50b00cc623d8ed9df.tar.bz2 |
cmListCommand: handle empty lists for list(REMOVE_AT)
Treat an empty list as a list with no valid bounds and return an error
message indicating that any given indices are out-of-bounds.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/list/REMOVE_AT-NotList.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/list/RunCMakeTest.cmake | 2 |
7 files changed, 19 insertions, 2 deletions
diff --git a/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt index b24a0ed..9368e88 100644 --- a/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt +++ b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt @@ -1,4 +1,4 @@ CMake Error at EmptyRemoveAt0.cmake:2 \(list\): - list REMOVE_AT given empty list + list index: mylist, 0 out of range \(0, 0\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt b/Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt b/Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt new file mode 100644 index 0000000..582b74b --- /dev/null +++ b/Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at REMOVE_AT-EmptyList.cmake:2 \(list\): + list index: nosuchlist, 0 out of range \(0, 0\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake b/Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake new file mode 100644 index 0000000..ff0dde8 --- /dev/null +++ b/Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake @@ -0,0 +1,6 @@ +set(nosuchlist "") +list(REMOVE_AT nosuchlist 0) +if (NOT DEFINED nosuchlist OR NOT nosuchlist STREQUAL "") + message(FATAL_ERROR + "list(REMOVE_AT) modified our list") +endif () diff --git a/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt b/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt index d6e8d85..563d865 100644 --- a/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt +++ b/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at REMOVE_AT-NotList.cmake:2 \(list\): - list sub-command REMOVE_AT requires list to be present. + list index: nosuchlist, 0 out of range \(0, 0\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/REMOVE_AT-NotList.cmake b/Tests/RunCMake/list/REMOVE_AT-NotList.cmake index 5266c7f..090df49 100644 --- a/Tests/RunCMake/list/REMOVE_AT-NotList.cmake +++ b/Tests/RunCMake/list/REMOVE_AT-NotList.cmake @@ -1,2 +1,6 @@ unset(nosuchlist) list(REMOVE_AT nosuchlist 0) +if (DEFINED nosuchlist) + message(FATAL_ERROR + "list(REMOVE_AT) created our list") +endif () diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index a8a0b57..bf3d22d 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -22,6 +22,8 @@ run_cmake(REMOVE_DUPLICATES-TooManyArguments) run_cmake(REVERSE-TooManyArguments) run_cmake(SUBLIST-TooManyArguments) +run_cmake(REMOVE_AT-EmptyList) + run_cmake(FILTER-NotList) run_cmake(REMOVE_AT-NotList) run_cmake(REMOVE_DUPLICATES-NotList) |