This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, next has been updated via 6596b6248fad49fcc70fafcb83352cf30df31179 (commit) via 828d4f514d04eb522e70173ac1e4f6790fac1460 (commit) via 82106e3783b8c9a5f21f7ffea336c38b1f13c33f (commit) via 56125a3f363272568c578c7e329af37d97b24df0 (commit) via 48ed48f7ad4c2da8037e997129b5ae8923ab7268 (commit) via c2a6cb64af7fdb0e31d5c0781cbd0dabb4197b5a (commit) via 07251a8ea5322f957adfcbb2fffb6c5ca121418c (commit) via 1b078c304db63eb6cd46fe0f22988f8241a389b2 (commit) via f560977540215e533c5360e1ab84dd0846d18310 (commit) via d211e5d20324783b7c5eb06725dda08c12c41787 (commit) from 108910ed07828f4d919572bbc613f82b6d196564 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6596b6248fad49fcc70fafcb83352cf30df31179 commit 6596b6248fad49fcc70fafcb83352cf30df31179 Merge: 108910e 828d4f5 Author: Rolf Eike Beer <e...@sf-mail.de> AuthorDate: Fri Nov 2 12:31:26 2012 -0400 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Fri Nov 2 12:31:26 2012 -0400 Merge topic 'start-contributing-irc-session' into next 828d4f5 Add several get_property() tests 82106e3 GetProperty test: move doc property tests into main process 56125a3 list: add tests for CMP0007 behavior 48ed48f Add test to secure the file(GLOB empty) behavior. c2a6cb6 file: remove dead code 07251a8 Consolidate list() argument count testing 1b078c3 Add tests for list() invalid arguments f560977 Add tests for list() argument count d211e5d CMakeTests: allow to call the check_cmake_test macro with a given file http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=828d4f514d04eb522e70173ac1e4f6790fac1460 commit 828d4f514d04eb522e70173ac1e4f6790fac1460 Author: Petr Kmoch <petr.km...@gmail.com> AuthorDate: Wed Oct 3 17:09:09 2012 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 17:10:07 2012 +0100 Add several get_property() tests Add tests for some get_property() uses not covered by existing tests. diff --git a/Tests/CMakeTests/GetPropertyTest.cmake.in b/Tests/CMakeTests/GetPropertyTest.cmake.in index 7d6e013..306ab72 100644 --- a/Tests/CMakeTests/GetPropertyTest.cmake.in +++ b/Tests/CMakeTests/GetPropertyTest.cmake.in @@ -11,6 +11,23 @@ if (NOT FOO_FULL STREQUAL "NOTFOUND") message(SEND_ERROR "property FOO has FULL_DOCS set to '${FOO_FULL}'") endif () +get_property(test_brief GLOBAL PROPERTY ENABLED_FEATURES BRIEF_DOCS) +get_property(test_full GLOBAL PROPERTY ENABLED_FEATURES FULL_DOCS) + +if(test_brief STREQUAL "NOTFOUND") + message(SEND_ERROR "property ENABLED_FEATURES has no BRIEF_DOCS") +endif() + +if(test_full STREQUAL "NOTFOUND") + message(SEND_ERROR "property ENABLED_FEATURES has no FULL_DOCS") +endif() + +set(test_var alpha) +get_property(result VARIABLE PROPERTY test_var) +if(NOT result STREQUAL "alpha") + message(SEND_ERROR "bad value of VARIABLE PROPERTY test_var: got '${result}' instead of 'alpha'") +endif() + set(Missing-Argument-RESULT 1) set(Missing-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Missing-Argument.cmake:1 \\(get_property\\):.*get_property called with incorrect number of arguments.*") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82106e3783b8c9a5f21f7ffea336c38b1f13c33f commit 82106e3783b8c9a5f21f7ffea336c38b1f13c33f Author: Rolf Eike Beer <e...@sf-mail.de> AuthorDate: Mon Oct 8 19:31:59 2012 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 17:10:07 2012 +0100 GetProperty test: move doc property tests into main process They will not raise an error in the normal case so we do not need to run them in their own process. diff --git a/Tests/CMakeTests/GetProperty-Doc-Properties.cmake b/Tests/CMakeTests/GetProperty-Doc-Properties.cmake deleted file mode 100644 index 6c2c362..0000000 --- a/Tests/CMakeTests/GetProperty-Doc-Properties.cmake +++ /dev/null @@ -1,10 +0,0 @@ -get_property(FOO_BRIEF GLOBAL PROPERTY FOO BRIEF_DOCS) -get_property(FOO_FULL GLOBAL PROPERTY FOO FULL_DOCS) - -if (NOT FOO_BRIEF STREQUAL "NOTFOUND") - message(SEND_ERROR "property FOO has BRIEF_DOCS set to '${FOO_BRIEF}'") -endif () - -if (NOT FOO_FULL STREQUAL "NOTFOUND") - message(SEND_ERROR "property FOO has FULL_DOCS set to '${FOO_FULL}'") -endif () diff --git a/Tests/CMakeTests/GetPropertyTest.cmake.in b/Tests/CMakeTests/GetPropertyTest.cmake.in index ab96e5b..7d6e013 100644 --- a/Tests/CMakeTests/GetPropertyTest.cmake.in +++ b/Tests/CMakeTests/GetPropertyTest.cmake.in @@ -1,5 +1,16 @@ include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +get_property(FOO_BRIEF GLOBAL PROPERTY FOO BRIEF_DOCS) +get_property(FOO_FULL GLOBAL PROPERTY FOO FULL_DOCS) + +if (NOT FOO_BRIEF STREQUAL "NOTFOUND") + message(SEND_ERROR "property FOO has BRIEF_DOCS set to '${FOO_BRIEF}'") +endif () + +if (NOT FOO_FULL STREQUAL "NOTFOUND") + message(SEND_ERROR "property FOO has FULL_DOCS set to '${FOO_FULL}'") +endif () + set(Missing-Argument-RESULT 1) set(Missing-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Missing-Argument.cmake:1 \\(get_property\\):.*get_property called with incorrect number of arguments.*") @@ -28,12 +39,6 @@ check_cmake_test(GetProperty No-Property ) -set(Doc-Properties-RESULT 0) - -check_cmake_test(GetProperty - Doc-Properties -) - set(Global-Name-RESULT 1) set(Global-Name-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Global-Name.cmake:1 \\(get_property\\):.*get_property given name for GLOBAL scope\\..*") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=56125a3f363272568c578c7e329af37d97b24df0 commit 56125a3f363272568c578c7e329af37d97b24df0 Author: Rolf Eike Beer <e...@sf-mail.de> AuthorDate: Sun Sep 30 10:44:18 2012 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 17:10:07 2012 +0100 list: add tests for CMP0007 behavior diff --git a/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake b/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake new file mode 100644 index 0000000..0a9264f --- /dev/null +++ b/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake @@ -0,0 +1,6 @@ +set(thelist "" NEW OLD) + +list(GET thelist 1 thevalue) +if (NOT thevalue STREQUAL "OLD") + message(SEND_ERROR "returned element '${thevalue}', but expected 'OLD'") +endif() diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index 53559eb..f0ed70f 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -155,6 +155,9 @@ foreach(cmd Remove_Item Reverse Remove_Duplicates Sort Remove_At) 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() +set(Get-CMP0007-Warn-RESULT 0) +set(Get-CMP0007-Warn-STDERR ".*CMake Warning \\(dev\\) at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Get-CMP0007-Warn.cmake:3 \\(list\\):.*Policy CMP0007 is not set:.*") + check_cmake_test(List No-Arguments Length-Too-Many-Arguments @@ -170,4 +173,15 @@ check_cmake_test(List Sort-Nonexistent-List Remove_At-Nonexistent-List Remove_At-Invalid-Index + Get-CMP0007-Warn ) + +set(thelist "" NEW OLD) + +foreach (_pol ${thelist}) + cmake_policy(SET CMP0007 ${_pol}) + list(GET thelist 1 thevalue) + if (NOT thevalue STREQUAL _pol) + message(SEND_ERROR "returned element '${thevalue}', but expected '${_pol}'") + endif() +endforeach (_pol) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=48ed48f7ad4c2da8037e997129b5ae8923ab7268 commit 48ed48f7ad4c2da8037e997129b5ae8923ab7268 Author: Amine Chadly <amine.cha...@gmail.com> AuthorDate: Sat Sep 29 20:27:21 2012 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 17:10:06 2012 +0100 Add test to secure the file(GLOB empty) behavior. diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 700f40b..960d3c1 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -60,6 +60,11 @@ check_cmake_test(File SHA512-Works ) +file(GLOB hum) +if (NOT hum STREQUAL "") + message(FATAL_ERROR "file(GLOB hum) did not return an empty string.") +endif() + # Also execute each test listed in FileTestScript.cmake: # set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/FileTestScript.cmake") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2a6cb64af7fdb0e31d5c0781cbd0dabb4197b5a commit c2a6cb64af7fdb0e31d5c0781cbd0dabb4197b5a Author: Amine Chadly <amine.cha...@gmail.com> AuthorDate: Sat Sep 29 19:33:39 2012 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 17:10:06 2012 +0100 file: remove dead code The file command requires at least two arguments, so guarding the GLOB and MAKE_DIRECTORY command is not necessary. Changed it for an assert to keep the protection. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 8de24b3..b877f3c 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -22,6 +22,7 @@ #endif #undef GetCurrentDirectory +#include <assert.h> #include <sys/types.h> #include <sys/stat.h> @@ -705,11 +706,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, bool recurse) { - if ( args.size() < 2 ) - { - this->SetError("GLOB requires at least a variable name"); - return false; - } + // File commands has at least one argument + assert(args.size() > 1); std::vector<std::string>::const_iterator i = args.begin(); @@ -843,11 +841,8 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, bool cmFileCommand::HandleMakeDirectoryCommand( std::vector<std::string> const& args) { - if(args.size() < 2 ) - { - this->SetError("called with incorrect number of arguments"); - return false; - } + // File command has at least one argument + assert(args.size() > 1); std::vector<std::string>::const_iterator i = args.begin(); diff --git a/Tests/CMakeTests/File-Glob-NoArg.cmake b/Tests/CMakeTests/File-Glob-NoArg.cmake new file mode 100644 index 0000000..486f366 --- /dev/null +++ b/Tests/CMakeTests/File-Glob-NoArg.cmake @@ -0,0 +1,2 @@ +# Checking that the call without arguments get caught by the file global protection. +file(GLOB) diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 3c3d85d..700f40b 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -12,6 +12,10 @@ set(Copy-NoDest-RESULT 1) set(Copy-NoDest-STDERR "given no DESTINATION") set(Copy-NoFile-RESULT 1) set(Copy-NoFile-STDERR "COPY cannot find.*/does_not_exist\\.txt") +set(Glob-NoArg-RESULT 1) +set(Glob-NoArg-STDERR "file must be called with at least two arguments") +set(Make_Directory-NoArg-RESULT 1) +set(Make-Directory-NoArg-STDERR "file must be called with at least two arguments") set(MD5-NoFile-RESULT 1) set(MD5-NoFile-STDERR "file MD5 failed to read file") set(MD5-BadArg1-RESULT 1) @@ -42,6 +46,8 @@ check_cmake_test(File Copy-LateArg Copy-NoDest Copy-NoFile + Glob-NoArg + Make_Directory-NoArg MD5-NoFile MD5-BadArg1 MD5-BadArg2 diff --git a/Tests/CMakeTests/Make_Directory-NoArg.cmake b/Tests/CMakeTests/Make_Directory-NoArg.cmake new file mode 100644 index 0000000..25b6f89 --- /dev/null +++ b/Tests/CMakeTests/Make_Directory-NoArg.cmake @@ -0,0 +1 @@ +file(MAKE_DIRECTORY) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=07251a8ea5322f957adfcbb2fffb6c5ca121418c commit 07251a8ea5322f957adfcbb2fffb6c5ca121418c Author: Petr Kmoch <petr.km...@gmail.com> AuthorDate: Sat Sep 29 15:41:29 2012 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 17:09:55 2012 +0100 Consolidate list() argument count testing Move test for list() argument count >= 2 to InitialPass(). diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 7848424..df64695 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -15,13 +15,14 @@ #include <stdlib.h> // required for atoi #include <ctype.h> +#include <assert.h> //---------------------------------------------------------------------------- bool cmListCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { - if(args.size() < 1) + if(args.size() < 2) { - this->SetError("must be called with at least one argument."); + this->SetError("must be called with at least two arguments."); return false; } @@ -243,11 +244,7 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) //---------------------------------------------------------------------------- bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command APPEND requires at least one argument."); - return false; - } + assert(args.size() >= 2); // Skip if nothing to append. if(args.size() < 3) @@ -424,12 +421,8 @@ bool cmListCommand bool cmListCommand ::HandleReverseCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command REVERSE requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command REVERSE only takes one argument."); @@ -463,13 +456,8 @@ bool cmListCommand bool cmListCommand ::HandleRemoveDuplicatesCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError( - "sub-command REMOVE_DUPLICATES requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command REMOVE_DUPLICATES only takes one argument."); @@ -513,12 +501,8 @@ bool cmListCommand bool cmListCommand ::HandleSortCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command SORT requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command SORT only takes one argument."); diff --git a/Tests/CMakeTests/List-Invalid-Subcommand.cmake b/Tests/CMakeTests/List-Invalid-Subcommand.cmake index 40f2345..f35a118 100644 --- a/Tests/CMakeTests/List-Invalid-Subcommand.cmake +++ b/Tests/CMakeTests/List-Invalid-Subcommand.cmake @@ -1 +1 @@ -list(NO_SUCH_SUBCOMMAND) +list(NO_SUCH_SUBCOMMAND mylist) diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index b11a295..53559eb 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -101,26 +101,34 @@ list(SORT result) TEST("SORT empty result" "") set(No-Arguments-RESULT 1) -set(No-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-No-Arguments.cmake:1 \\(list\\):.*list must be called with at least one argument.*") - -set(Get-No-Arguments-STDERR ".*CMake Error at List-Get-No-Arguments.cmake:1 \\(list\\):.*list sub-command GET requires at least three arguments.*") -set(Append-No-Arguments-STDERR ".*CMake Error at List-Append-No-Arguments.cmake:1 \\(list\\):.*list sub-command APPEND requires at least one argument.*") -set(Find-No-Arguments-STDERR ".*CMake Error at List-Find-No-Arguments.cmake:1 \\(list\\):.*list sub-command FIND requires three arguments.*") -set(Insert-No-Arguments-STDERR ".*CMake Error at List-Insert-No-Arguments.cmake:1 \\(list\\):.*list sub-command INSERT requires at least three arguments.*") -set(Remove_Item-No-Arguments-STDERR ".*CMake Error at List-Remove_Item-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_ITEM requires two or more arguments.*") -set(Reverse-No-Arguments-STDERR ".*CMake Error at List-Reverse-No-Arguments.cmake:1 \\(list\\):.*list sub-command REVERSE requires a list as an argument.*") -set(Remove_Duplicates-No-Arguments-STDERR ".*CMake Error at List-Remove_Duplicates-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_DUPLICATES requires a list as an argument.*") -set(Sort-No-Arguments-STDERR ".*CMake Error at List-Sort-No-Arguments.cmake:1 \\(list\\):.*list sub-command SORT requires a list as an argument.*") -set(Remove_At-No-Arguments-STDERR ".*CMake Error at List-Remove_At-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_AT requires at least two arguments.*") +set(No-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-No-Arguments.cmake:1 \\(list\\):.*list must be called with at least two arguments.*") +# these trigger top-level condition foreach(cmd IN ITEMS Append Find Get Insert Length Reverse Remove_At Remove_Duplicates Remove_Item Sort) set(${cmd}-No-Arguments-RESULT 1) + set(${cmd}-No-Arguments-STDERR ".*CMake Error at List-${cmd}-No-Arguments.cmake:1 \\(list\\):.*list must be called with at least two arguments.*") string(TOUPPER ${cmd} cmd_upper) set(_test_file_name "${CMAKE_CURRENT_BINARY_DIR}/List-${cmd}-No-Arguments.cmake") file(WRITE "${_test_file_name}" "list(${cmd_upper})\n") check_cmake_test_single(List "${cmd}-No-Arguments" "${_test_file_name}") endforeach() +set(Get-List-Only-STDERR "at least three") +set(Find-List-Only-STDERR "three") +set(Insert-List-Only-STDERR "at least three") +set(Length-List-Only-STDERR "two") +set(Remove_At-List-Only-STDERR "at least two") +set(Remove_Item-List-Only-STDERR "two or more") + +foreach(cmd IN ITEMS Find Get Insert Length Remove_At Remove_Item) + string(TOUPPER ${cmd} cmd_upper) + set(${cmd}-List-Only-RESULT 1) + set(${cmd}-List-Only-STDERR ".*CMake Error at List-${cmd}-List-Only.cmake:1 \\(list\\):.*list sub-command ${cmd_upper} requires ${${cmd}-List-Only-STDERR} arguments.*") + set(_test_file_name "${CMAKE_CURRENT_BINARY_DIR}/List-${cmd}-List-Only.cmake") + file(WRITE "${_test_file_name}" "list(${cmd_upper} mylist)\n") + check_cmake_test_single(List "${cmd}-List-Only" "${_test_file_name}") +endforeach() + set(Length-Too-Many-Arguments-RESULT 1) set(Length-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Length-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command LENGTH requires two arguments.*") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1b078c304db63eb6cd46fe0f22988f8241a389b2 commit 1b078c304db63eb6cd46fe0f22988f8241a389b2 Author: Petr Kmoch <petr.km...@gmail.com> AuthorDate: Sat Sep 29 14:41:07 2012 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 17:08:49 2012 +0100 Add tests for list() invalid arguments Add tests for error reporting when list() arguments are invalid. diff --git a/Tests/CMakeTests/List-Get-Invalid-Index.cmake b/Tests/CMakeTests/List-Get-Invalid-Index.cmake new file mode 100644 index 0000000..178295a --- /dev/null +++ b/Tests/CMakeTests/List-Get-Invalid-Index.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(GET mylist 3 result) diff --git a/Tests/CMakeTests/List-Insert-Invalid-Index.cmake b/Tests/CMakeTests/List-Insert-Invalid-Index.cmake new file mode 100644 index 0000000..4103d97 --- /dev/null +++ b/Tests/CMakeTests/List-Insert-Invalid-Index.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(INSERT mylist 3 delta) diff --git a/Tests/CMakeTests/List-Invalid-Subcommand.cmake b/Tests/CMakeTests/List-Invalid-Subcommand.cmake new file mode 100644 index 0000000..40f2345 --- /dev/null +++ b/Tests/CMakeTests/List-Invalid-Subcommand.cmake @@ -0,0 +1 @@ +list(NO_SUCH_SUBCOMMAND) diff --git a/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake b/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake new file mode 100644 index 0000000..d4f3921 --- /dev/null +++ b/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(REMOVE_AT mylist 3) diff --git a/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake new file mode 100644 index 0000000..5266c7f --- /dev/null +++ b/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(REMOVE_AT nosuchlist 0) diff --git a/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake new file mode 100644 index 0000000..218f227 --- /dev/null +++ b/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(REMOVE_DUPLICATES nosuchlist) diff --git a/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake new file mode 100644 index 0000000..079e7fb --- /dev/null +++ b/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(REMOVE_ITEM nosuchlist alpha) diff --git a/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake b/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake new file mode 100644 index 0000000..977e2cc --- /dev/null +++ b/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(REVERSE nosuchlist) diff --git a/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake b/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake new file mode 100644 index 0000000..8f48e10 --- /dev/null +++ b/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(SORT nosuchlist) diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index 27858c0..b11a295 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -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 ) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f560977540215e533c5360e1ab84dd0846d18310 commit f560977540215e533c5360e1ab84dd0846d18310 Author: Petr Kmoch <petr.km...@gmail.com> AuthorDate: Sat Sep 29 13:02:38 2012 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 17:08:44 2012 +0100 Add tests for list() argument count Add test for error reporting when list() subcommands have wrong number of arguments. diff --git a/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake new file mode 100644 index 0000000..327db6a --- /dev/null +++ b/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake @@ -0,0 +1 @@ +list(LENGTH mylist result one_too_many) diff --git a/Tests/CMakeTests/List-No-Arguments.cmake b/Tests/CMakeTests/List-No-Arguments.cmake new file mode 100644 index 0000000..7916aaa --- /dev/null +++ b/Tests/CMakeTests/List-No-Arguments.cmake @@ -0,0 +1 @@ +list() diff --git a/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake new file mode 100644 index 0000000..b5eb46e --- /dev/null +++ b/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake @@ -0,0 +1 @@ +list(REMOVE_DUPLICATES mylist one_too_many) diff --git a/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake new file mode 100644 index 0000000..3a554a0 --- /dev/null +++ b/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake @@ -0,0 +1 @@ +list(REVERSE mylist one_too_many) diff --git a/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake new file mode 100644 index 0000000..81b195d --- /dev/null +++ b/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake @@ -0,0 +1 @@ +list(SORT mylist one_too_many) diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index a167503..27858c0 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -1,3 +1,5 @@ +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") + macro(TEST command expected) if("x${result}" STREQUAL "x${expected}") #message("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"") @@ -97,3 +99,45 @@ TEST("REVERSE empty result" "") list(SORT result) TEST("SORT empty result" "") + +set(No-Arguments-RESULT 1) +set(No-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-No-Arguments.cmake:1 \\(list\\):.*list must be called with at least one argument.*") + +set(Get-No-Arguments-STDERR ".*CMake Error at List-Get-No-Arguments.cmake:1 \\(list\\):.*list sub-command GET requires at least three arguments.*") +set(Append-No-Arguments-STDERR ".*CMake Error at List-Append-No-Arguments.cmake:1 \\(list\\):.*list sub-command APPEND requires at least one argument.*") +set(Find-No-Arguments-STDERR ".*CMake Error at List-Find-No-Arguments.cmake:1 \\(list\\):.*list sub-command FIND requires three arguments.*") +set(Insert-No-Arguments-STDERR ".*CMake Error at List-Insert-No-Arguments.cmake:1 \\(list\\):.*list sub-command INSERT requires at least three arguments.*") +set(Remove_Item-No-Arguments-STDERR ".*CMake Error at List-Remove_Item-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_ITEM requires two or more arguments.*") +set(Reverse-No-Arguments-STDERR ".*CMake Error at List-Reverse-No-Arguments.cmake:1 \\(list\\):.*list sub-command REVERSE requires a list as an argument.*") +set(Remove_Duplicates-No-Arguments-STDERR ".*CMake Error at List-Remove_Duplicates-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_DUPLICATES requires a list as an argument.*") +set(Sort-No-Arguments-STDERR ".*CMake Error at List-Sort-No-Arguments.cmake:1 \\(list\\):.*list sub-command SORT requires a list as an argument.*") +set(Remove_At-No-Arguments-STDERR ".*CMake Error at List-Remove_At-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_AT requires at least two arguments.*") + +foreach(cmd IN ITEMS Append Find Get Insert Length Reverse Remove_At Remove_Duplicates Remove_Item Sort) + set(${cmd}-No-Arguments-RESULT 1) + string(TOUPPER ${cmd} cmd_upper) + set(_test_file_name "${CMAKE_CURRENT_BINARY_DIR}/List-${cmd}-No-Arguments.cmake") + file(WRITE "${_test_file_name}" "list(${cmd_upper})\n") + check_cmake_test_single(List "${cmd}-No-Arguments" "${_test_file_name}") +endforeach() + +set(Length-Too-Many-Arguments-RESULT 1) +set(Length-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Length-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command LENGTH requires two arguments.*") + +set(Reverse-Too-Many-Arguments-RESULT 1) +set(Reverse-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Reverse-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command REVERSE only takes one argument.*") + +set(Remove_Duplicates-Too-Many-Arguments-RESULT 1) +set(Remove_Duplicates-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Remove_Duplicates-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_DUPLICATES only takes one argument.*") + +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.*") + + +check_cmake_test(List + No-Arguments + Length-Too-Many-Arguments + Reverse-Too-Many-Arguments + Remove_Duplicates-Too-Many-Arguments + Sort-Too-Many-Arguments +) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d211e5d20324783b7c5eb06725dda08c12c41787 commit d211e5d20324783b7c5eb06725dda08c12c41787 Author: Rolf Eike Beer <e...@sf-mail.de> AuthorDate: Thu Nov 1 13:26:23 2012 +0100 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Fri Nov 2 12:50:05 2012 +0100 CMakeTests: allow to call the check_cmake_test macro with a given file This allows to generate a lot of simple files directly in the test tree instead of having them all checked in. diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake index db92905..7be7b30 100644 --- a/Tests/CMakeTests/CheckCMakeTest.cmake +++ b/Tests/CMakeTests/CheckCMakeTest.cmake @@ -1,30 +1,35 @@ get_filename_component(CMakeTests_SRC_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(check_cmake_test_single prefix test testfile) + message(STATUS "Test ${prefix}-${test}...") + execute_process( + COMMAND ${CMAKE_COMMAND} -P "${testfile}" + WORKING_DIRECTORY "${CMakeTests_BIN_DIR}" + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + RESULT_VARIABLE result + ) + string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") + string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") + if(NOT "${result}" STREQUAL "${${test}-RESULT}") + message(FATAL_ERROR + "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" + "Test ${test} output:\n" + "${out}\n" + "${err}") + endif() + if(${test}-STDERR AND NOT "${err}" MATCHES "${${test}-STDERR}") + message(FATAL_ERROR + "Test ${test} stderr does not match\n ${${test}-STDERR}\n" + "Test ${test} output:\n" + "${out}\n" + "${err}") + endif() +endfunction() + function(check_cmake_test prefix) get_filename_component(CMakeTests_BIN_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) foreach(test ${ARGN}) - message(STATUS "Test ${prefix}-${test}...") - execute_process( - COMMAND ${CMAKE_COMMAND} -P "${CMakeTests_SRC_DIR}/${prefix}-${test}.cmake" - WORKING_DIRECTORY "${CMakeTests_BIN_DIR}" - OUTPUT_VARIABLE stdout - ERROR_VARIABLE stderr - RESULT_VARIABLE result - ) - string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") - string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") - if(NOT "${result}" STREQUAL "${${test}-RESULT}") - message(FATAL_ERROR - "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" - "Test ${test} output:\n" - "${out}\n" - "${err}") - endif() - if(${test}-STDERR AND NOT "${err}" MATCHES "${${test}-STDERR}") - message(FATAL_ERROR - "Test ${test} stderr does not match\n ${${test}-STDERR}\n" - "Test ${test} output:\n" - "${out}\n" - "${err}") - endif() + check_cmake_test_single("${prefix}" "${test}" "${CMakeTests_SRC_DIR}/${prefix}-${test}.cmake") endforeach() endfunction() ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-commits