cmAddTestCommand.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmAddTestCommand_h
  11. #define cmAddTestCommand_h
  12. #include "cmCommand.h"
  13. #include "cmDocumentGeneratorExpressions.h"
  14. /** \class cmAddTestCommand
  15. * \brief Add a test to the lists of tests to run.
  16. *
  17. * cmAddTestCommand adds a test to the list of tests to run .
  18. */
  19. class cmAddTestCommand : public cmCommand
  20. {
  21. public:
  22. /**
  23. * This is a virtual constructor for the command.
  24. */
  25. virtual cmCommand* Clone()
  26. {
  27. return new cmAddTestCommand;
  28. }
  29. /**
  30. * This is called when the command is first encountered in
  31. * the CMakeLists.txt file.
  32. */
  33. virtual bool InitialPass(std::vector<std::string> const& args,
  34. cmExecutionStatus &status);
  35. /**
  36. * The name of the command as specified in CMakeList.txt.
  37. */
  38. virtual const char* GetName() const { return "add_test";}
  39. /**
  40. * Succinct documentation.
  41. */
  42. virtual const char* GetTerseDocumentation() const
  43. {
  44. return "Add a test to the project with the specified arguments.";
  45. }
  46. /**
  47. * More documentation.
  48. */
  49. virtual const char* GetFullDocumentation() const
  50. {
  51. return
  52. " add_test(testname Exename arg1 arg2 ... )\n"
  53. "If the ENABLE_TESTING command has been run, this command adds a "
  54. "test target to the current directory. If ENABLE_TESTING has not "
  55. "been run, this command does nothing. "
  56. "The tests are run by the testing subsystem by executing Exename "
  57. "with the specified arguments. Exename can be either an executable "
  58. "built by this project or an arbitrary executable on the "
  59. "system (like tclsh). The test will be run with the current working "
  60. "directory set to the CMakeList.txt files corresponding directory "
  61. "in the binary tree. Tests added using this signature do not support "
  62. "generator expressions.\n"
  63. "\n"
  64. " add_test(NAME <name> [CONFIGURATIONS [Debug|Release|...]]\n"
  65. " [WORKING_DIRECTORY dir]\n"
  66. " COMMAND <command> [arg1 [arg2 ...]])\n"
  67. "Add a test called <name>. "
  68. "The test name may not contain spaces, quotes, or other characters "
  69. "special in CMake syntax. "
  70. "If COMMAND specifies an executable target (created by "
  71. "add_executable) it will automatically be replaced by the location "
  72. "of the executable created at build time. "
  73. "If a CONFIGURATIONS option is given then the test will be executed "
  74. "only when testing under one of the named configurations. "
  75. "If a WORKING_DIRECTORY option is given then the test will be executed "
  76. "in the given directory."
  77. "\n"
  78. "Arguments after COMMAND may use \"generator expressions\" with the "
  79. "syntax \"$<...>\". "
  80. CM_DOCUMENT_ADD_TEST_GENERATOR_EXPRESSIONS
  81. "Example usage:\n"
  82. " add_test(NAME mytest\n"
  83. " COMMAND testDriver --config $<CONFIGURATION>\n"
  84. " --exe $<TARGET_FILE:myexe>)\n"
  85. "This creates a test \"mytest\" whose command runs a testDriver "
  86. "tool passing the configuration name and the full path to the "
  87. "executable file produced by target \"myexe\"."
  88. ;
  89. }
  90. cmTypeMacro(cmAddTestCommand, cmCommand);
  91. private:
  92. bool HandleNameMode(std::vector<std::string> const& args);
  93. };
  94. #endif