summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestTestCommand.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-05-04 15:13:35 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-05-04 15:13:35 (GMT)
commit9619d54003970f9160b31ad6e04c85b1812faf3f (patch)
treee64ba872c0c683417d41dd884decce63c4488c9e /Source/CTest/cmCTestTestCommand.cxx
parent082b3b44d73b19aa1461eaa91e228317d9373d67 (diff)
downloadCMake-9619d54003970f9160b31ad6e04c85b1812faf3f.zip
CMake-9619d54003970f9160b31ad6e04c85b1812faf3f.tar.gz
CMake-9619d54003970f9160b31ad6e04c85b1812faf3f.tar.bz2
ENH: Improve syntax
Diffstat (limited to 'Source/CTest/cmCTestTestCommand.cxx')
-rw-r--r--Source/CTest/cmCTestTestCommand.cxx63
1 files changed, 52 insertions, 11 deletions
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx
index c0a48f3..38b7051 100644
--- a/Source/CTest/cmCTestTestCommand.cxx
+++ b/Source/CTest/cmCTestTestCommand.cxx
@@ -22,16 +22,54 @@
bool cmCTestTestCommand::InitialPass(
std::vector<std::string> const& args)
{
- if (args.size() != 2)
+ const char* build_dir = 0;
+ const char* res_var = 0;
+
+ bool havereturn_variable = false;
+ bool havesource = false;
+ for(size_t i=0; i < args.size(); ++i)
{
- this->SetError("called with incorrect number of arguments");
- return false;
+ if ( havereturn_variable )
+ {
+ res_var = args[i].c_str();
+ havereturn_variable = false;
+ }
+ else if ( havesource )
+ {
+ build_dir = args[i].c_str();
+ havesource = false;
+ }
+ else if(args[i] == "RETURN_VALUE")
+ {
+ if ( res_var )
+ {
+ this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice.");
+ return false;
+ }
+ havereturn_variable = true;
+ }
+ else if(args[i] == "BUILD")
+ {
+ if ( build_dir )
+ {
+ this->SetError("called with incorrect number of arguments. BUILD specified twice.");
+ return false;
+ }
+ havesource = true;
+ }
+ else
+ {
+ cmOStringStream str;
+ str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << ".";
+ this->SetError(str.str().c_str());
+ return false;
+ }
}
- const char* build_dir = args[0].c_str();
- const char* res_var = args[1].c_str();
-
- m_CTest->SetCTestConfiguration("BuildDirectory", build_dir);
+ if ( build_dir )
+ {
+ m_CTest->SetCTestConfiguration("BuildDirectory", build_dir);
+ }
cmCTestGenericHandler* handler = m_CTest->GetHandler("test");
if ( !handler )
@@ -40,12 +78,15 @@ bool cmCTestTestCommand::InitialPass(
return false;
}
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(build_dir);
+ cmSystemTools::ChangeDirectory(m_CTest->GetCTestConfiguration("BuildDirectory").c_str());
int res = handler->ProcessHandler();
+ if ( res_var )
+ {
+ cmOStringStream str;
+ str << res;
+ m_Makefile->AddDefinition(res_var, str.str().c_str());
+ }
cmSystemTools::ChangeDirectory(current_dir.c_str());
- cmOStringStream str;
- str << res;
- m_Makefile->AddDefinition(res_var, str.str().c_str());
return true;
}