cmCTestRunTest.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCTestRunTest_h
  11. #define cmCTestRunTest_h
  12. #include <cmStandardIncludes.h>
  13. #include <cmCTestTestHandler.h>
  14. #include <cmProcess.h>
  15. /** \class cmRunTest
  16. * \brief represents a single test to be run
  17. *
  18. * cmRunTest contains the information related to running a single test
  19. */
  20. class cmCTestRunTest
  21. {
  22. public:
  23. cmCTestRunTest(cmCTestTestHandler* handler);
  24. ~cmCTestRunTest();
  25. void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties * prop)
  26. { this->TestProperties = prop; }
  27. cmCTestTestHandler::cmCTestTestProperties * GetTestProperties()
  28. { return this->TestProperties; }
  29. void SetIndex(int i) { this->Index = i; }
  30. int GetIndex() { return this->Index; }
  31. std::string GetProcessOutput() { return this->ProcessOutput; }
  32. cmCTestTestHandler::cmCTestTestResult GetTestResults()
  33. { return this->TestResult; }
  34. // Read and store output. Returns true if it must be called again.
  35. bool CheckOutput();
  36. //launch the test process, return whether it started correctly
  37. bool StartTest();
  38. //capture and report the test results
  39. bool EndTest(size_t completed, size_t total, bool started);
  40. //Called by ctest -N to log the command string
  41. void ComputeArguments();
  42. private:
  43. void DartProcessing();
  44. bool CreateProcess(double testTimeOut,
  45. std::vector<std::string>* environment);
  46. void WriteLogOutputTop(size_t completed, size_t total);
  47. //Run post processing of the process output for MemCheck
  48. void MemCheckPostProcess();
  49. cmCTestTestHandler::cmCTestTestProperties * TestProperties;
  50. //Pointer back to the "parent"; the handler that invoked this test run
  51. cmCTestTestHandler * TestHandler;
  52. cmCTest * CTest;
  53. cmProcess * TestProcess;
  54. //If the executable to run is ctest, don't create a new process;
  55. //just instantiate a new cmTest. (Can be disabled for a single test
  56. //if this option is set to false.)
  57. //bool OptimizeForCTest;
  58. //flag for whether the env was modified for this run
  59. bool ModifyEnv;
  60. //stores the original environment if we are modifying it
  61. std::vector<std::string> OrigEnv;
  62. std::string ProcessOutput;
  63. //The test results
  64. cmCTestTestHandler::cmCTestTestResult TestResult;
  65. int Index;
  66. std::string StartTime;
  67. std::string TestCommand;
  68. std::string ActualCommand;
  69. std::vector<std::string> Arguments;
  70. };
  71. inline int getNumWidth(size_t n)
  72. {
  73. int numWidth = 1;
  74. if(n >= 10)
  75. {
  76. numWidth = 2;
  77. }
  78. if(n >= 100)
  79. {
  80. numWidth = 3;
  81. }
  82. return numWidth;
  83. }
  84. #endif