cmCTestRunTest.h 3.1 KB

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