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