2009-08-19 16:58:36 +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.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#ifndef cmCTestRunTest_h
|
|
|
|
#define cmCTestRunTest_h
|
|
|
|
|
|
|
|
#include <cmStandardIncludes.h>
|
|
|
|
#include <cmCTestTestHandler.h>
|
2009-08-26 20:09:06 +04:00
|
|
|
#include <cmProcess.h>
|
2009-08-19 16:58:36 +04:00
|
|
|
|
|
|
|
/** \class cmRunTest
|
|
|
|
* \brief represents a single test to be run
|
|
|
|
*
|
|
|
|
* cmRunTest contains the information related to running a single test
|
|
|
|
*/
|
|
|
|
class cmCTestRunTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmCTestRunTest();
|
|
|
|
~cmCTestRunTest();
|
|
|
|
|
|
|
|
void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties * prop)
|
|
|
|
{ this->TestProperties = prop; }
|
|
|
|
|
|
|
|
cmCTestTestHandler::cmCTestTestProperties * GetTestProperties()
|
|
|
|
{ return this->TestProperties; }
|
|
|
|
|
|
|
|
void SetTestHandler(cmCTestTestHandler * handler);
|
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
void SetIndex(int i) { this->Index = i; }
|
|
|
|
|
|
|
|
void SetCTest(cmCTest * ct) { this->CTest = ct; }
|
2009-08-19 16:58:36 +04:00
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
int GetIndex() { return this->Index; }
|
2009-08-19 16:58:36 +04:00
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
std::string GetProcessOutput() { return this->ProcessOutput; }
|
2009-08-19 16:58:36 +04:00
|
|
|
|
|
|
|
cmCTestTestHandler::cmCTestTestResult GetTestResults()
|
|
|
|
{ return this->TestResult; }
|
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
bool IsRunning();
|
|
|
|
void CheckOutput();
|
|
|
|
//launch the test process, return whether it started correctly
|
|
|
|
bool StartTest();
|
2009-08-28 19:08:39 +04:00
|
|
|
//capture and report the test results
|
2009-09-03 23:33:44 +04:00
|
|
|
bool EndTest(size_t completed, size_t total, bool started);
|
2009-08-28 19:08:39 +04:00
|
|
|
//Called by ctest -N to log the command string
|
|
|
|
void ComputeArguments();
|
|
|
|
private:
|
2009-08-26 20:09:06 +04:00
|
|
|
void DartProcessing();
|
2009-08-28 19:08:39 +04:00
|
|
|
bool CreateProcess(double testTimeOut,
|
2009-08-19 16:58:36 +04:00
|
|
|
std::vector<std::string>* environment);
|
2009-08-31 17:50:35 +04:00
|
|
|
void WriteLogOutputTop(size_t completed, size_t total);
|
2009-08-28 23:08:03 +04:00
|
|
|
//Run post processing of the process output for MemCheck
|
|
|
|
void MemCheckPostProcess();
|
2009-08-27 18:37:30 +04:00
|
|
|
|
2009-08-19 16:58:36 +04:00
|
|
|
cmCTestTestHandler::cmCTestTestProperties * TestProperties;
|
|
|
|
//Pointer back to the "parent"; the handler that invoked this test run
|
|
|
|
cmCTestTestHandler * TestHandler;
|
|
|
|
cmCTest * CTest;
|
2009-08-26 20:09:06 +04:00
|
|
|
cmProcess * TestProcess;
|
2009-08-19 16:58:36 +04: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 20:09:06 +04: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 16:58:36 +04:00
|
|
|
std::string ProcessOutput;
|
|
|
|
//The test results
|
|
|
|
cmCTestTestHandler::cmCTestTestResult TestResult;
|
2009-08-26 20:09:06 +04:00
|
|
|
int Index;
|
|
|
|
std::string StartTime;
|
|
|
|
std::string TestCommand;
|
|
|
|
std::string ActualCommand;
|
2009-08-28 19:08:39 +04:00
|
|
|
std::vector<std::string> Arguments;
|
2009-08-19 16:58:36 +04:00
|
|
|
};
|
|
|
|
|
2009-09-02 18:08:40 +04:00
|
|
|
inline int getNumWidth(int n)
|
|
|
|
{
|
|
|
|
int numWidth = 1;
|
|
|
|
if(n >= 10)
|
|
|
|
{
|
|
|
|
numWidth = 2;
|
|
|
|
}
|
|
|
|
if(n >= 100)
|
|
|
|
{
|
|
|
|
numWidth = 3;
|
|
|
|
}
|
|
|
|
return numWidth;
|
|
|
|
}
|
2009-08-19 16:58:36 +04:00
|
|
|
#endif
|
|
|
|
|