cmAddTestCommand.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. /** \class cmAddTestCommand
  14. * \brief Add a test to the lists of tests to run.
  15. *
  16. * cmAddTestCommand adds a test to the list of tests to run .
  17. */
  18. class cmAddTestCommand : public cmCommand
  19. {
  20. public:
  21. /**
  22. * This is a virtual constructor for the command.
  23. */
  24. virtual cmCommand* Clone()
  25. {
  26. return new cmAddTestCommand;
  27. }
  28. /**
  29. * This is called when the command is first encountered in
  30. * the CMakeLists.txt file.
  31. */
  32. virtual bool InitialPass(std::vector<std::string> const& args,
  33. cmExecutionStatus &status);
  34. /**
  35. * The name of the command as specified in CMakeList.txt.
  36. */
  37. virtual const char* GetName() { return "add_test";}
  38. /**
  39. * Succinct documentation.
  40. */
  41. virtual const char* GetTerseDocumentation()
  42. {
  43. return "Add a test to the project with the specified arguments.";
  44. }
  45. /**
  46. * More documentation.
  47. */
  48. virtual const char* GetFullDocumentation()
  49. {
  50. return
  51. " add_test(testname Exename arg1 arg2 ...)\n"
  52. "If the ENABLE_TESTING command has been run, this command adds a "
  53. "test target to the current directory. If ENABLE_TESTING has not "
  54. "been run, this command does nothing. "
  55. "The tests are run by the testing subsystem by executing Exename "
  56. "with the specified arguments. Exename can be either an executable "
  57. "built by this project or an arbitrary executable on the "
  58. "system (like tclsh). The test will be run with the current working "
  59. "directory set to the CMakeList.txt files corresponding directory "
  60. "in the binary tree."
  61. "\n"
  62. " add_test(NAME <name> [CONFIGURATIONS [Debug|Release|...]]\n"
  63. " COMMAND <command> [arg1 [arg2 ...]])\n"
  64. "If COMMAND specifies an executable target (created by "
  65. "add_executable) it will automatically be replaced by the location "
  66. "of the executable created at build time. "
  67. "If a CONFIGURATIONS option is given then the test will be executed "
  68. "only when testing under one of the named configurations."
  69. "\n"
  70. "Arguments after COMMAND may use \"generator expressions\" with the "
  71. "syntax \"$<...>\". "
  72. "These expressions are evaluted during build system generation and "
  73. "produce information specific to each generated build configuration. "
  74. "Valid expressions are:\n"
  75. " $<CONFIGURATION> = configuration name\n"
  76. " $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a)\n"
  77. " $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so)\n"
  78. " $<TARGET_SONAME_FILE:tgt> = file with soname (.so.3)\n"
  79. "where \"tgt\" is the name of a target. "
  80. "Target file expressions produce a full path, but _DIR and _NAME "
  81. "versions can produce the directory and file name components:\n"
  82. " $<TARGET_FILE_DIR:tgt>/$<TARGET_FILE_NAME:tgt>\n"
  83. " $<TARGET_LINKER_FILE_DIR:tgt>/$<TARGET_LINKER_FILE_NAME:tgt>\n"
  84. " $<TARGET_SONAME_FILE_DIR:tgt>/$<TARGET_SONAME_FILE_NAME:tgt>\n"
  85. "Example usage:\n"
  86. " add_test(NAME mytest\n"
  87. " COMMAND testDriver --config $<CONFIGURATION>\n"
  88. " --exe $<TARGET_FILE:myexe>)\n"
  89. "This creates a test \"mytest\" whose command runs a testDriver "
  90. "tool passing the configuration name and the full path to the "
  91. "executable file produced by target \"myexe\"."
  92. ;
  93. }
  94. cmTypeMacro(cmAddTestCommand, cmCommand);
  95. private:
  96. bool HandleNameMode(std::vector<std::string> const& args);
  97. };
  98. #endif