cmCTestVC.cxx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. 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. #include "cmCTestVC.h"
  14. #include "cmCTest.h"
  15. #include <cmsys/Process.h>
  16. //----------------------------------------------------------------------------
  17. cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log): CTest(ct), Log(log)
  18. {
  19. }
  20. //----------------------------------------------------------------------------
  21. cmCTestVC::~cmCTestVC()
  22. {
  23. }
  24. //----------------------------------------------------------------------------
  25. void cmCTestVC::SetCommandLineTool(std::string const& tool)
  26. {
  27. this->CommandLineTool = tool;
  28. }
  29. //----------------------------------------------------------------------------
  30. void cmCTestVC::SetSourceDirectory(std::string const& dir)
  31. {
  32. this->SourceDirectory = dir;
  33. }
  34. //----------------------------------------------------------------------------
  35. bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
  36. OutputParser* err, const char* workDir)
  37. {
  38. this->Log << this->ComputeCommandLine(cmd) << "\n";
  39. cmsysProcess* cp = cmsysProcess_New();
  40. cmsysProcess_SetCommand(cp, cmd);
  41. workDir = workDir? workDir : this->SourceDirectory.c_str();
  42. cmsysProcess_SetWorkingDirectory(cp, workDir);
  43. this->RunProcess(cp, out, err);
  44. int result = cmsysProcess_GetExitValue(cp);
  45. cmsysProcess_Delete(cp);
  46. return result == 0;
  47. }
  48. //----------------------------------------------------------------------------
  49. std::string cmCTestVC::ComputeCommandLine(char const* const* cmd)
  50. {
  51. cmOStringStream line;
  52. const char* sep = "";
  53. for(const char* const* arg = cmd; *arg; ++arg)
  54. {
  55. line << sep << "\"" << *arg << "\"";
  56. sep = " ";
  57. }
  58. return line.str();
  59. }
  60. //----------------------------------------------------------------------------
  61. std::string cmCTestVC::GetNightlyTime()
  62. {
  63. // Get the nightly start time corresponding to the current dau.
  64. struct tm* t = this->CTest->GetNightlyTime(
  65. this->CTest->GetCTestConfiguration("NightlyStartTime"),
  66. this->CTest->GetTomorrowTag());
  67. char current_time[1024];
  68. sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d",
  69. t->tm_year + 1900,
  70. t->tm_mon + 1,
  71. t->tm_mday,
  72. t->tm_hour,
  73. t->tm_min,
  74. t->tm_sec);
  75. return current_time;
  76. }
  77. //----------------------------------------------------------------------------
  78. void cmCTestVC::Cleanup()
  79. {
  80. this->Log << "--- Begin Cleanup ---\n";
  81. this->CleanupImpl();
  82. this->Log << "--- End Cleanup ---\n";
  83. }
  84. //----------------------------------------------------------------------------
  85. void cmCTestVC::CleanupImpl()
  86. {
  87. // We do no cleanup by default.
  88. }
  89. //----------------------------------------------------------------------------
  90. void cmCTestVC::NoteOldRevision()
  91. {
  92. // We do nothing by default.
  93. }
  94. //----------------------------------------------------------------------------
  95. void cmCTestVC::NoteNewRevision()
  96. {
  97. // We do nothing by default.
  98. }