2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2009-08-19 12:58:36 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2009-08-19 12:58:36 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2009-08-19 12:58:36 +00:00
|
|
|
#ifndef cmCTestRunTest_h
|
|
|
|
#define cmCTestRunTest_h
|
|
|
|
|
|
|
|
#include <cmStandardIncludes.h>
|
|
|
|
#include <cmCTestTestHandler.h>
|
2009-08-26 16:09:06 +00:00
|
|
|
#include <cmProcess.h>
|
2009-08-19 12:58:36 +00:00
|
|
|
|
|
|
|
/** \class cmRunTest
|
|
|
|
* \brief represents a single test to be run
|
|
|
|
*
|
|
|
|
* cmRunTest contains the information related to running a single test
|
|
|
|
*/
|
|
|
|
class cmCTestRunTest
|
|
|
|
{
|
|
|
|
public:
|
2009-09-11 14:09:48 +00:00
|
|
|
cmCTestRunTest(cmCTestTestHandler* handler);
|
2009-08-19 12:58:36 +00:00
|
|
|
~cmCTestRunTest();
|
|
|
|
|
|
|
|
void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties * prop)
|
|
|
|
{ this->TestProperties = prop; }
|
|
|
|
|
|
|
|
cmCTestTestHandler::cmCTestTestProperties * GetTestProperties()
|
|
|
|
{ return this->TestProperties; }
|
|
|
|
|
2009-08-26 16:09:06 +00:00
|
|
|
void SetIndex(int i) { this->Index = i; }
|
|
|
|
|
|
|
|
int GetIndex() { return this->Index; }
|
2009-08-19 12:58:36 +00:00
|
|
|
|
2009-08-26 16:09:06 +00:00
|
|
|
std::string GetProcessOutput() { return this->ProcessOutput; }
|
2009-08-19 12:58:36 +00:00
|
|
|
|
|
|
|
cmCTestTestHandler::cmCTestTestResult GetTestResults()
|
|
|
|
{ return this->TestResult; }
|
|
|
|
|
2009-09-11 16:26:41 +00:00
|
|
|
// Read and store output. Returns true if it must be called again.
|
|
|
|
bool CheckOutput();
|
|
|
|
|
2009-08-26 16:09:06 +00:00
|
|
|
//launch the test process, return whether it started correctly
|
|
|
|
bool StartTest();
|
2009-08-28 15:08:39 +00:00
|
|
|
//capture and report the test results
|
2009-09-03 19:33:44 +00:00
|
|
|
bool EndTest(size_t completed, size_t total, bool started);
|
2009-08-28 15:08:39 +00:00
|
|
|
//Called by ctest -N to log the command string
|
|
|
|
void ComputeArguments();
|
|
|
|
private:
|
2009-08-26 16:09:06 +00:00
|
|
|
void DartProcessing();
|
2009-08-28 15:08:39 +00:00
|
|
|
bool CreateProcess(double testTimeOut,
|
2009-08-19 12:58:36 +00:00
|
|
|
std::vector<std::string>* environment);
|
2009-08-31 13:50:35 +00:00
|
|
|
void WriteLogOutputTop(size_t completed, size_t total);
|
2009-08-28 19:08:03 +00:00
|
|
|
//Run post processing of the process output for MemCheck
|
|
|
|
void MemCheckPostProcess();
|
2009-08-27 14:37:30 +00:00
|
|
|
|
2009-08-19 12:58:36 +00:00
|
|
|
cmCTestTestHandler::cmCTestTestProperties * TestProperties;
|
|
|
|
//Pointer back to the "parent"; the handler that invoked this test run
|
|
|
|
cmCTestTestHandler * TestHandler;
|
|
|
|
cmCTest * CTest;
|
2009-08-26 16:09:06 +00:00
|
|
|
cmProcess * TestProcess;
|
2009-08-19 12:58:36 +00:00
|
|
|
//If the executable to run is ctest, don't create a new process;
|
|
|
|
//just instantiate a new cmTest. (Can be disabled for a single test
|
|
|
|
//if this option is set to false.)
|
2009-08-26 16:09:06 +00:00
|
|
|
//bool OptimizeForCTest;
|
|
|
|
|
|
|
|
//flag for whether the env was modified for this run
|
|
|
|
bool ModifyEnv;
|
|
|
|
//stores the original environment if we are modifying it
|
|
|
|
std::vector<std::string> OrigEnv;
|
2009-08-19 12:58:36 +00:00
|
|
|
std::string ProcessOutput;
|
|
|
|
//The test results
|
|
|
|
cmCTestTestHandler::cmCTestTestResult TestResult;
|
2009-08-26 16:09:06 +00:00
|
|
|
int Index;
|
|
|
|
std::string StartTime;
|
|
|
|
std::string TestCommand;
|
|
|
|
std::string ActualCommand;
|
2009-08-28 15:08:39 +00:00
|
|
|
std::vector<std::string> Arguments;
|
2009-08-19 12:58:36 +00:00
|
|
|
};
|
|
|
|
|
2009-09-08 13:12:44 +00:00
|
|
|
inline int getNumWidth(size_t n)
|
2009-09-02 14:08:40 +00:00
|
|
|
{
|
|
|
|
int numWidth = 1;
|
|
|
|
if(n >= 10)
|
|
|
|
{
|
|
|
|
numWidth = 2;
|
|
|
|
}
|
|
|
|
if(n >= 100)
|
|
|
|
{
|
|
|
|
numWidth = 3;
|
|
|
|
}
|
|
|
|
return numWidth;
|
|
|
|
}
|
2009-08-19 12:58:36 +00:00
|
|
|
#endif
|
|
|
|
|