summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-08-20 19:39:35 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-08-20 19:39:35 (GMT)
commit9f555e805dd025f6428e5dff7f4a928c5dc5fbbb (patch)
tree97c3714aec7c6e68e8f792d32c3703b0d0a727a4
parent14c8096ba88502409f076cf0b0e5fe471c18f11b (diff)
parent08c71acc8729aa51b389c0583bca351077e5e44e (diff)
downloadCMake-9f555e805dd025f6428e5dff7f4a928c5dc5fbbb.zip
CMake-9f555e805dd025f6428e5dff7f4a928c5dc5fbbb.tar.gz
CMake-9f555e805dd025f6428e5dff7f4a928c5dc5fbbb.tar.bz2
Merge topic 'list-command-argument-fixes'
08c71ac CMake.List test: explicitely test with lists containing only an empty string 52d9c38 list command: error on too many arguments
-rw-r--r--Source/cmListCommand.cxx18
-rw-r--r--Tests/CMakeTests/ListTest.cmake.in11
2 files changed, 29 insertions, 0 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 9d4f175..7848424 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -429,6 +429,12 @@ bool cmListCommand
this->SetError("sub-command REVERSE requires a list as an argument.");
return false;
}
+ else if(args.size() > 2)
+ {
+ this->SetError(
+ "sub-command REVERSE only takes one argument.");
+ return false;
+ }
const std::string& listName = args[1];
// expand the variable
@@ -463,6 +469,12 @@ bool cmListCommand
"sub-command REMOVE_DUPLICATES requires a list as an argument.");
return false;
}
+ else if(args.size() > 2)
+ {
+ this->SetError(
+ "sub-command REMOVE_DUPLICATES only takes one argument.");
+ return false;
+ }
const std::string& listName = args[1];
// expand the variable
@@ -506,6 +518,12 @@ bool cmListCommand
this->SetError("sub-command SORT requires a list as an argument.");
return false;
}
+ else if(args.size() > 2)
+ {
+ this->SetError(
+ "sub-command SORT only takes one argument.");
+ return false;
+ }
const std::string& listName = args[1];
// expand the variable
diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in
index 07fc7c6..a167503 100644
--- a/Tests/CMakeTests/ListTest.cmake.in
+++ b/Tests/CMakeTests/ListTest.cmake.in
@@ -86,3 +86,14 @@ TEST("REVERSE result" "ken;brad;bill;andy")
set(result bill andy bill brad ken ken ken)
list(REMOVE_DUPLICATES result)
TEST("REMOVE_DUPLICATES result" "bill;andy;brad;ken")
+
+# these commands should just do nothing if the list is already empty
+set(result "")
+list(REMOVE_DUPLICATES result)
+TEST("REMOVE_DUPLICATES empty result" "")
+
+list(REVERSE result)
+TEST("REVERSE empty result" "")
+
+list(SORT result)
+TEST("SORT empty result" "")