2005-06-23 21:04:18 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
2005-06-23 21:04:18 +04:00
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmCTestHandlerCommand.h"
|
|
|
|
|
|
|
|
#include "cmCTest.h"
|
|
|
|
#include "cmCTestGenericHandler.h"
|
|
|
|
|
|
|
|
cmCTestHandlerCommand::cmCTestHandlerCommand()
|
|
|
|
{
|
|
|
|
const size_t INIT_SIZE = 100;
|
|
|
|
size_t cc;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Arguments.reserve(INIT_SIZE);
|
2005-06-23 21:04:18 +04:00
|
|
|
for ( cc = 0; cc < INIT_SIZE; ++ cc )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Arguments.push_back(0);
|
2005-06-23 21:04:18 +04:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE";
|
|
|
|
this->Arguments[ct_SOURCE] = "SOURCE";
|
|
|
|
this->Arguments[ct_BUILD] = "BUILD";
|
|
|
|
this->Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX";
|
|
|
|
this->Last = ct_LAST;
|
2005-06-23 21:04:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCTestHandlerCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args)
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( !this->ProcessArguments(args, this->Last, &*this->Arguments.begin(),
|
|
|
|
this->Values) )
|
2005-06-23 21:04:18 +04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCTestGenericHandler* handler = this->InitializeHandler();
|
|
|
|
if ( !handler )
|
|
|
|
{
|
|
|
|
this->SetError("internal CTest error. Cannot instantiate test handler");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->Values[ct_BUILD] )
|
2005-06-23 21:04:18 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->SetCTestConfiguration("BuildDirectory",
|
|
|
|
this->Values[ct_BUILD]);
|
2005-06-23 21:04:18 +04:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->Values[ct_SUBMIT_INDEX] )
|
2005-06-23 21:04:18 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->CTest->GetDartVersion() <= 1 )
|
2005-06-23 21:04:18 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +03:00
|
|
|
"Dart before version 2.0 does not support collecting submissions."
|
|
|
|
<< std::endl
|
|
|
|
<< "Please upgrade the server to Dart 2 or higher, or do not use "
|
|
|
|
"SUBMIT_INDEX." << std::endl);
|
2005-06-23 21:04:18 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
|
2005-06-23 21:04:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
|
2006-03-09 19:17:10 +03:00
|
|
|
cmSystemTools::ChangeDirectory(
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetCTestConfiguration("BuildDirectory").c_str());
|
2005-06-23 21:04:18 +04:00
|
|
|
int res = handler->ProcessHandler();
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE])
|
2005-06-23 21:04:18 +04:00
|
|
|
{
|
|
|
|
cmOStringStream str;
|
|
|
|
str << res;
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->AddDefinition(
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Values[ct_RETURN_VALUE], str.str().c_str());
|
2005-06-23 21:04:18 +04:00
|
|
|
}
|
|
|
|
cmSystemTools::ChangeDirectory(current_dir.c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
bool cmCTestHandlerCommand::ProcessArguments(
|
|
|
|
std::vector<std::string> const& args, int last, const char** strings,
|
|
|
|
std::vector<const char*>& values)
|
2005-06-23 21:04:18 +04:00
|
|
|
{
|
|
|
|
int state = 0;
|
|
|
|
int cc;
|
|
|
|
values.resize(last);
|
|
|
|
for ( cc = 0; cc < last; ++ cc )
|
|
|
|
{
|
|
|
|
values[cc] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(size_t i=0; i < args.size(); ++i)
|
|
|
|
{
|
|
|
|
if ( state > 0 && state < last )
|
|
|
|
{
|
|
|
|
values[state] = args[i].c_str();
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "Set " << strings[state] << " to "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< args[i].c_str() << std::endl);
|
2005-06-23 21:04:18 +04:00
|
|
|
state = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
for ( cc = 0; cc < last; ++ cc )
|
|
|
|
{
|
|
|
|
if ( strings[cc] && args[i] == strings[cc] )
|
|
|
|
{
|
|
|
|
state = cc;
|
|
|
|
if ( values[state] )
|
|
|
|
{
|
|
|
|
cmOStringStream ostr;
|
2006-03-09 19:17:10 +03:00
|
|
|
ostr << "called with incorrect number of arguments. "
|
|
|
|
<< strings[state] << " specified twice.";
|
2005-06-23 21:04:18 +04:00
|
|
|
this->SetError(ostr.str().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !found )
|
|
|
|
{
|
|
|
|
cmOStringStream str;
|
2006-03-09 19:17:10 +03:00
|
|
|
str
|
|
|
|
<< "called with incorrect number of arguments. Extra argument is: "
|
|
|
|
<< args[i].c_str() << ".";
|
2005-06-23 21:04:18 +04:00
|
|
|
this->SetError(str.str().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|