ctest.cxx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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("-D",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("-T",0) == 0 || arg.find("--dart-mode",0) == 0 ) &&
  46. (i < args.size() -1) )
  47. {
  48. inst.m_DartMode = true;
  49. inst.SetTest(args[i+1].c_str());
  50. }
  51. if( ( arg.find("-M",0) == 0 || arg.find("--test-model",0) == 0 ) &&
  52. (i < args.size() -1) )
  53. {
  54. std::string& str = args[i+1];
  55. if ( str == "NIGHTLY" || str == "nightly" || str == "Nightly" )
  56. {
  57. inst.SetTestModel(cmCTest::NIGHTLY);
  58. }
  59. else if ( str == "CONTINUOUS" || str == "continuous" ||
  60. str == "Continuous" )
  61. {
  62. inst.SetTestModel(cmCTest::CONTINUOUS);
  63. std::cout << "Continuous" << std::endl;
  64. }
  65. else
  66. {
  67. inst.SetTestModel(cmCTest::EXPERIMENTAL);
  68. }
  69. }
  70. if(arg.find("-R",0) == 0 && i < args.size() - 1)
  71. {
  72. inst.m_UseIncludeRegExp = true;
  73. inst.m_IncludeRegExp = args[i+1];
  74. }
  75. if(arg.find("-E",0) == 0 && i < args.size() - 1)
  76. {
  77. inst.m_UseExcludeRegExp = true;
  78. inst.m_ExcludeRegExp = args[i+1];
  79. inst.m_UseExcludeRegExpFirst = inst.m_UseIncludeRegExp ? false : true;
  80. }
  81. if(arg.find("-h") == 0 ||
  82. arg.find("-help") == 0 ||
  83. arg.find("-H") == 0 ||
  84. arg.find("--help") == 0 ||
  85. arg.find("/H") == 0 ||
  86. arg.find("/HELP") == 0 ||
  87. arg.find("/?") == 0)
  88. {
  89. std::cerr << "Usage: " << argv[0] << " <options>" << std::endl
  90. << "\t -D type Specify config type" << std::endl
  91. << "\t -E test Specify regular expression for tests to exclude"
  92. << std::endl
  93. << "\t -R test Specify regular expression for tests to include"
  94. << std::endl
  95. << "\t -V Verbose testing" << std::endl
  96. << "\t -N Only show what would be done without this option"
  97. << std::endl
  98. << "\t -H Help page" << std::endl;
  99. return 1;
  100. }
  101. }
  102. // call process directory
  103. inst.Initialize();
  104. int res = inst.ProcessTests();
  105. inst.Finalize();
  106. return res;
  107. }