ctest.cxx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. {"-I [Start,End,Stride,test#,test#|Test file]", "Run a specific number of tests by number.",
  76. "This option causes ctest to run tests starting at number Start, ending at number End, "
  77. "and incrementing by Stride. Any additional numbers after Stride are considered individual "
  78. "test numbers. Start, End,or stride can be empty. Optionally a file can be given that contains "
  79. "the same syntax as the command line."},
  80. {0,0,0}
  81. };
  82. //----------------------------------------------------------------------------
  83. static const cmDocumentationEntry cmDocumentationSeeAlso[] =
  84. {
  85. {0, "cmake", 0},
  86. {0, "ccmake", 0},
  87. {0, 0, 0}
  88. };
  89. // this is a test driver program for cmCTest.
  90. int main (int argc, char *argv[])
  91. {
  92. cmSystemTools::EnableMSVCDebugHook();
  93. int nocwd = 0;
  94. if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
  95. {
  96. std::cerr << "Current working directory cannot be established." << std::endl;
  97. nocwd = 1;
  98. }
  99. // If there is a testing input file, check for documentation options
  100. // only if there are actually arguments. We want running without
  101. // arguments to run tests.
  102. if(argc > 1 || !cmSystemTools::FileExists("DartTestfile.txt"))
  103. {
  104. if(argc == 1)
  105. {
  106. std::cout << "*********************************" << std::endl;
  107. std::cout << "No test configuration file found!" << std::endl;
  108. std::cout << "*********************************" << std::endl;
  109. }
  110. cmDocumentation doc;
  111. if(doc.CheckOptions(argc, argv) || nocwd)
  112. {
  113. // Construct and print requested documentation.
  114. doc.SetName("ctest");
  115. doc.SetNameSection(cmDocumentationName);
  116. doc.SetUsageSection(cmDocumentationUsage);
  117. doc.SetDescriptionSection(cmDocumentationDescription);
  118. doc.SetOptionsSection(cmDocumentationOptions);
  119. doc.SetSeeAlsoList(cmDocumentationSeeAlso);
  120. return doc.PrintRequestedDocumentation(std::cout)? 0:1;
  121. }
  122. }
  123. #ifdef _WIN32
  124. std::string comspec = "cmw9xcom.exe";
  125. cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
  126. #endif
  127. cmCTest inst;
  128. // copy the args to a vector
  129. std::vector<std::string> args;
  130. for(int i =0; i < argc; ++i)
  131. {
  132. args.push_back(argv[i]);
  133. }
  134. // run ctest
  135. return inst.Run(args);
  136. }