ctest.cxx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. #include "cmCTest.h"
  14. #include "cmSystemTools.h"
  15. // this is a test driver program for cmCTest.
  16. int main (int argc, char *argv[])
  17. {
  18. cmSystemTools::EnableMSVCDebugHook();
  19. cmCTest inst;
  20. // look at the args
  21. std::vector<std::string> args;
  22. for(int i =0; i < argc; ++i)
  23. {
  24. args.push_back(argv[i]);
  25. }
  26. #ifdef _WIN32
  27. std::string comspec = "cmw9xcom.exe";
  28. cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
  29. #endif
  30. for(unsigned int i=1; i < args.size(); ++i)
  31. {
  32. std::string arg = args[i];
  33. if(arg.find("-C",0) == 0 && i < args.size() - 1)
  34. {
  35. inst.m_ConfigType = args[i+1];
  36. }
  37. if( arg.find("-V",0) == 0 || arg.find("--verbose",0) == 0 )
  38. {
  39. inst.m_Verbose = true;
  40. }
  41. if( arg.find("-N",0) == 0 || arg.find("--show-only",0) == 0 )
  42. {
  43. inst.m_ShowOnly = true;
  44. }
  45. if( arg.find("-D",0) == 0 && i < args.size() - 1 )
  46. {
  47. inst.m_DartMode = true;
  48. std::string targ = args[i+1];
  49. if ( targ == "Experimental" )
  50. {
  51. inst.SetTestModel(cmCTest::EXPERIMENTAL);
  52. inst.SetTest("Start");
  53. inst.SetTest("Configure");
  54. inst.SetTest("Build");
  55. inst.SetTest("Test");
  56. inst.SetTest("Coverage");
  57. inst.SetTest("Submit");
  58. }
  59. else if ( targ == "Continuous" )
  60. {
  61. inst.SetTestModel(cmCTest::CONTINUOUS);
  62. inst.SetTest("Start");
  63. inst.SetTest("Update");
  64. inst.SetTest("Configure");
  65. inst.SetTest("Build");
  66. inst.SetTest("Test");
  67. inst.SetTest("Coverage");
  68. inst.SetTest("Submit");
  69. }
  70. else if ( targ == "Nightly" )
  71. {
  72. inst.SetTestModel(cmCTest::NIGHTLY);
  73. inst.SetTest("Start");
  74. inst.SetTest("Update");
  75. inst.SetTest("Configure");
  76. inst.SetTest("Build");
  77. inst.SetTest("Test");
  78. inst.SetTest("Coverage");
  79. inst.SetTest("Submit");
  80. }
  81. else if ( targ == "MemoryCheck" )
  82. {
  83. inst.SetTestModel(cmCTest::EXPERIMENTAL);
  84. inst.SetTest("Start");
  85. inst.SetTest("Configure");
  86. inst.SetTest("Build");
  87. inst.SetTest("Purify");
  88. inst.SetTest("Coverage");
  89. inst.SetTest("Submit");
  90. }
  91. else if ( targ == "NightlyMemoryCheck" )
  92. {
  93. inst.SetTestModel(cmCTest::NIGHTLY);
  94. inst.SetTest("Start");
  95. inst.SetTest("Update");
  96. inst.SetTest("Configure");
  97. inst.SetTest("Build");
  98. inst.SetTest("Purify");
  99. inst.SetTest("Coverage");
  100. inst.SetTest("Submit");
  101. }
  102. }
  103. if( ( arg.find("-T",0) == 0 ) &&
  104. (i < args.size() -1) )
  105. {
  106. inst.m_DartMode = true;
  107. inst.SetTest(args[i+1].c_str());
  108. }
  109. if( ( arg.find("-M",0) == 0 || arg.find("--test-model",0) == 0 ) &&
  110. (i < args.size() -1) )
  111. {
  112. std::string& str = args[i+1];
  113. if ( str == "NIGHTLY" || str == "nightly" || str == "Nightly" )
  114. {
  115. inst.SetTestModel(cmCTest::NIGHTLY);
  116. }
  117. else if ( str == "CONTINUOUS" || str == "continuous" ||
  118. str == "Continuous" )
  119. {
  120. inst.SetTestModel(cmCTest::CONTINUOUS);
  121. std::cout << "Continuous" << std::endl;
  122. }
  123. else
  124. {
  125. inst.SetTestModel(cmCTest::EXPERIMENTAL);
  126. }
  127. }
  128. if(arg.find("-R",0) == 0 && i < args.size() - 1)
  129. {
  130. inst.m_UseIncludeRegExp = true;
  131. inst.m_IncludeRegExp = args[i+1];
  132. }
  133. if(arg.find("-E",0) == 0 && i < args.size() - 1)
  134. {
  135. inst.m_UseExcludeRegExp = true;
  136. inst.m_ExcludeRegExp = args[i+1];
  137. inst.m_UseExcludeRegExpFirst = inst.m_UseIncludeRegExp ? false : true;
  138. }
  139. if(arg.find("-h") == 0 ||
  140. arg.find("-help") == 0 ||
  141. arg.find("-H") == 0 ||
  142. arg.find("--help") == 0 ||
  143. arg.find("/H") == 0 ||
  144. arg.find("/HELP") == 0 ||
  145. arg.find("/?") == 0)
  146. {
  147. std::cerr << "Usage: " << argv[0] << " <options>" << std::endl
  148. << "\t -C type Specify config type" << std::endl
  149. << "\t -E test Specify regular expression for tests to exclude"
  150. << std::endl
  151. << "\t -R test Specify regular expression for tests to include"
  152. << std::endl
  153. << "\t -V Verbose testing" << std::endl
  154. << "\t -N Only show what would be done without this option"
  155. << std::endl
  156. << "\t -H Help page" << std::endl;
  157. return 1;
  158. }
  159. }
  160. // call process directory
  161. inst.Initialize();
  162. int res = inst.ProcessTests();
  163. inst.Finalize();
  164. return res;
  165. }