summaryrefslogtreecommitdiff
path: root/Source/cmAddTestCommand.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 10:34:04 -0400
committerBrad King <brad.king@kitware.com>2016-05-16 16:05:19 -0400
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/cmAddTestCommand.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadcmake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/cmAddTestCommand.cxx')
-rw-r--r--Source/cmAddTestCommand.cxx101
1 files changed, 36 insertions, 65 deletions
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index e81341581e..204dd970e7 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -15,24 +15,21 @@
#include "cmTest.h"
-
// cmExecutableCommand
-bool cmAddTestCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddTestCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(!args.empty() && args[0] == "NAME")
- {
+ if (!args.empty() && args[0] == "NAME") {
return this->HandleNameMode(args);
- }
+ }
// First argument is the name of the test Second argument is the name of
// the executable to run (a target or external program) Remaining arguments
// are the arguments to pass to the executable
- if(args.size() < 2 )
- {
+ if (args.size() < 2) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// Collect the command with arguments.
std::vector<std::string> command;
@@ -41,25 +38,21 @@ bool cmAddTestCommand
// Create the test but add a generator only the first time it is
// seen. This preserves behavior from before test generators.
cmTest* test = this->Makefile->GetTest(args[0]);
- if(test)
- {
+ if (test) {
// If the test was already added by a new-style signature do not
// allow it to be duplicated.
- if(!test->GetOldStyle())
- {
+ if (!test->GetOldStyle()) {
std::ostringstream e;
e << " given test name \"" << args[0]
<< "\" which already exists in this directory.";
this->SetError(e.str());
return false;
- }
}
- else
- {
+ } else {
test = this->Makefile->CreateTest(args[0]);
test->SetOldStyle(true);
this->Makefile->AddTestGenerator(new cmTestGenerator(test));
- }
+ }
test->SetCommand(command);
return true;
@@ -73,7 +66,8 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
std::vector<std::string> command;
// Read the arguments.
- enum Doing {
+ enum Doing
+ {
DoingName,
DoingCommand,
DoingConfigs,
@@ -81,94 +75,71 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
DoingNone
};
Doing doing = DoingName;
- for(unsigned int i=1; i < args.size(); ++i)
- {
- if(args[i] == "COMMAND")
- {
- if(!command.empty())
- {
+ for (unsigned int i = 1; i < args.size(); ++i) {
+ if (args[i] == "COMMAND") {
+ if (!command.empty()) {
this->SetError(" may be given at most one COMMAND.");
return false;
- }
- doing = DoingCommand;
}
- else if(args[i] == "CONFIGURATIONS")
- {
- if(!configurations.empty())
- {
+ doing = DoingCommand;
+ } else if (args[i] == "CONFIGURATIONS") {
+ if (!configurations.empty()) {
this->SetError(" may be given at most one set of CONFIGURATIONS.");
return false;
- }
- doing = DoingConfigs;
}
- else if(args[i] == "WORKING_DIRECTORY")
- {
- if(!working_directory.empty())
- {
+ doing = DoingConfigs;
+ } else if (args[i] == "WORKING_DIRECTORY") {
+ if (!working_directory.empty()) {
this->SetError(" may be given at most one WORKING_DIRECTORY.");
return false;
- }
- doing = DoingWorkingDirectory;
}
- else if(doing == DoingName)
- {
+ doing = DoingWorkingDirectory;
+ } else if (doing == DoingName) {
name = args[i];
doing = DoingNone;
- }
- else if(doing == DoingCommand)
- {
+ } else if (doing == DoingCommand) {
command.push_back(args[i]);
- }
- else if(doing == DoingConfigs)
- {
+ } else if (doing == DoingConfigs) {
configurations.push_back(args[i]);
- }
- else if(doing == DoingWorkingDirectory)
- {
+ } else if (doing == DoingWorkingDirectory) {
working_directory = args[i];
doing = DoingNone;
- }
- else
- {
+ } else {
std::ostringstream e;
e << " given unknown argument:\n " << args[i] << "\n";
this->SetError(e.str());
return false;
- }
}
+ }
// Require a test name.
- if(name.empty())
- {
+ if (name.empty()) {
this->SetError(" must be given non-empty NAME.");
return false;
- }
+ }
// Require a command.
- if(command.empty())
- {
+ if (command.empty()) {
this->SetError(" must be given non-empty COMMAND.");
return false;
- }
+ }
// Require a unique test name within the directory.
- if(this->Makefile->GetTest(name))
- {
+ if (this->Makefile->GetTest(name)) {
std::ostringstream e;
e << " given test NAME \"" << name
<< "\" which already exists in this directory.";
this->SetError(e.str());
return false;
- }
+ }
// Add the test.
cmTest* test = this->Makefile->CreateTest(name);
test->SetOldStyle(false);
test->SetCommand(command);
- if(!working_directory.empty())
- {
+ if (!working_directory.empty()) {
test->SetProperty("WORKING_DIRECTORY", working_directory.c_str());
- }
+ }
this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations));
return true;