ctest.cxx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. // Need these for documentation support.
  16. #include "cmake.h"
  17. #include "cmDocumentation.h"
  18. //----------------------------------------------------------------------------
  19. static const cmDocumentationEntry cmDocumentationName[] =
  20. {
  21. {0,
  22. " ctest - Testing driver provided by CMake.", 0},
  23. {0,0,0}
  24. };
  25. //----------------------------------------------------------------------------
  26. static const cmDocumentationEntry cmDocumentationUsage[] =
  27. {
  28. {0,
  29. " ctest [options]", 0},
  30. {0,0,0}
  31. };
  32. //----------------------------------------------------------------------------
  33. static const cmDocumentationEntry cmDocumentationDescription[] =
  34. {
  35. {0,
  36. "The \"ctest\" executable is the CMake test driver program. "
  37. "CMake-generated build trees created for projects that use "
  38. "the ENABLE_TESTING and ADD_TEST commands have testing support. "
  39. "This program will run the tests and report results.", 0},
  40. CMAKE_STANDARD_INTRODUCTION,
  41. {0,0,0}
  42. };
  43. //----------------------------------------------------------------------------
  44. static const cmDocumentationEntry cmDocumentationOptions[] =
  45. {
  46. {"-C <config>", "Choose configuration to test.",
  47. "Some CMake-generated build trees can have multiple build configurations "
  48. "in the same tree. This option can be used to specify which one should "
  49. "be tested. Example configurations are \"Debug\" and \"Release\"."},
  50. {"-V,--verbose", "Enable verbose output from tests.",
  51. "Test output is normally suppressed and only summary information is "
  52. "displayed. This option will show all test output."},
  53. {"-N,--show-only", "Disable actual execution of tests.",
  54. "This option tells ctest to list the tests that would be run but not "
  55. "actually run them. Useful in conjunction with the -R and -E options."},
  56. {"-R <regex>", "Run tests matching regular expression.",
  57. "This option tells ctest to run only the tests whose names match the "
  58. "given regular expression."},
  59. {"-E <regex>", "Exclude tests matching regular expression.",
  60. "This option tells ctest to NOT run the tests whose names match the "
  61. "given regular expression."},
  62. {"-D <DashboardTest>", "Execute dashboard test",
  63. "This option tells ctest to perform act as a Dart client and perform "
  64. "a dashboard test. All tests are ModeTest, where Mode can be Experimental, "
  65. "Nightly, and Continuous, and Test can be Start, Update, Configure, "
  66. "Build, Test, Coverage, and Submit."},
  67. {"-S <ConfigScript>", "Execute a dashboard for a configuration",
  68. "This option tells ctest to load in a configuration script which sets "
  69. "a number of parameters such as the binary and source directories. Then "
  70. "ctest will do what is required to create and run a dashboard. This "
  71. "option basically sets up a dashboard and then runs ctest -D with the "
  72. "appropriate options."},
  73. {"-A <Notes file>", "Add a notes file with submission",
  74. "This option tells ctest to include a notes file when submitting dashboard. "},
  75. {0,0,0}
  76. };
  77. //----------------------------------------------------------------------------
  78. static const cmDocumentationEntry cmDocumentationSeeAlso[] =
  79. {
  80. {0, "cmake", 0},
  81. {0, "ccmake", 0},
  82. {0, 0, 0}
  83. };
  84. // this is a test driver program for cmCTest.
  85. int main (int argc, char *argv[])
  86. {
  87. cmSystemTools::EnableMSVCDebugHook();
  88. // If there is a testing input file, check for documentation options
  89. // only if there are actually arguments. We want running without
  90. // arguments to run tests.
  91. if(argc > 1 || !cmSystemTools::FileExists("DartTestfile.txt"))
  92. {
  93. if(argc == 1)
  94. {
  95. std::cout << "*********************************" << std::endl;
  96. std::cout << "No test configuration file found!" << std::endl;
  97. std::cout << "*********************************" << std::endl;
  98. }
  99. cmDocumentation doc;
  100. if(doc.CheckOptions(argc, argv))
  101. {
  102. // Construct and print requested documentation.
  103. doc.SetName("ctest");
  104. doc.SetNameSection(cmDocumentationName);
  105. doc.SetUsageSection(cmDocumentationUsage);
  106. doc.SetDescriptionSection(cmDocumentationDescription);
  107. doc.SetOptionsSection(cmDocumentationOptions);
  108. doc.SetSeeAlsoList(cmDocumentationSeeAlso);
  109. return doc.PrintRequestedDocumentation(std::cout)? 0:1;
  110. }
  111. }
  112. #ifdef _WIN32
  113. std::string comspec = "cmw9xcom.exe";
  114. cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
  115. #endif
  116. cmCTest inst;
  117. // copy the args to a vector
  118. std::vector<std::string> args;
  119. for(int i =0; i < argc; ++i)
  120. {
  121. args.push_back(argv[i]);
  122. }
  123. // run ctest
  124. return inst.Run(args);
  125. }