mirror of
https://github.com/reactos/CMake.git
synced 2024-11-25 04:29:52 +00:00
Add tests for list() invalid arguments
Add tests for error reporting when list() arguments are invalid.
This commit is contained in:
parent
f560977540
commit
1b078c304d
2
Tests/CMakeTests/List-Get-Invalid-Index.cmake
Normal file
2
Tests/CMakeTests/List-Get-Invalid-Index.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
set(mylist alpha bravo charlie)
|
||||
list(GET mylist 3 result)
|
2
Tests/CMakeTests/List-Insert-Invalid-Index.cmake
Normal file
2
Tests/CMakeTests/List-Insert-Invalid-Index.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
set(mylist alpha bravo charlie)
|
||||
list(INSERT mylist 3 delta)
|
1
Tests/CMakeTests/List-Invalid-Subcommand.cmake
Normal file
1
Tests/CMakeTests/List-Invalid-Subcommand.cmake
Normal file
@ -0,0 +1 @@
|
||||
list(NO_SUCH_SUBCOMMAND)
|
2
Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake
Normal file
2
Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
set(mylist alpha bravo charlie)
|
||||
list(REMOVE_AT mylist 3)
|
2
Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake
Normal file
2
Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
unset(nosuchlist)
|
||||
list(REMOVE_AT nosuchlist 0)
|
@ -0,0 +1,2 @@
|
||||
unset(nosuchlist)
|
||||
list(REMOVE_DUPLICATES nosuchlist)
|
2
Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake
Normal file
2
Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
unset(nosuchlist)
|
||||
list(REMOVE_ITEM nosuchlist alpha)
|
2
Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake
Normal file
2
Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
unset(nosuchlist)
|
||||
list(REVERSE nosuchlist)
|
2
Tests/CMakeTests/List-Sort-Nonexistent-List.cmake
Normal file
2
Tests/CMakeTests/List-Sort-Nonexistent-List.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
unset(nosuchlist)
|
||||
list(SORT nosuchlist)
|
@ -133,6 +133,19 @@ set(Remove_Duplicates-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURREN
|
||||
set(Sort-Too-Many-Arguments-RESULT 1)
|
||||
set(Sort-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Sort-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command SORT only takes one argument.*")
|
||||
|
||||
set(Invalid-Subcommand-RESULT 1)
|
||||
set(Invalid-Subcommand-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Invalid-Subcommand.cmake:1 \\(list\\):.*list does not recognize sub-command NO_SUCH_SUBCOMMAND.*")
|
||||
|
||||
foreach(cmd Get Insert Remove_At)
|
||||
set(${cmd}-Invalid-Index-RESULT 1)
|
||||
set(${cmd}-Invalid-Index-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-${cmd}-Invalid-Index.cmake:2 \\(list\\):.*list index: 3 out of range \\(-3, 2\\).*")
|
||||
endforeach()
|
||||
|
||||
foreach(cmd Remove_Item Reverse Remove_Duplicates Sort Remove_At)
|
||||
string(TOUPPER ${cmd} Cmd)
|
||||
set(${cmd}-Nonexistent-List-RESULT 1)
|
||||
set(${cmd}-Nonexistent-List-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-${cmd}-Nonexistent-List.cmake:2 \\(list\\):.*sub-command ${Cmd} requires list to be present.*")
|
||||
endforeach()
|
||||
|
||||
check_cmake_test(List
|
||||
No-Arguments
|
||||
@ -140,4 +153,13 @@ check_cmake_test(List
|
||||
Reverse-Too-Many-Arguments
|
||||
Remove_Duplicates-Too-Many-Arguments
|
||||
Sort-Too-Many-Arguments
|
||||
Invalid-Subcommand
|
||||
Get-Invalid-Index
|
||||
Insert-Invalid-Index
|
||||
Remove_Item-Nonexistent-List
|
||||
Reverse-Nonexistent-List
|
||||
Remove_Duplicates-Nonexistent-List
|
||||
Sort-Nonexistent-List
|
||||
Remove_At-Nonexistent-List
|
||||
Remove_At-Invalid-Index
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user