1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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
15 #include "cmCommand.h"
16 #include "cmDocumentGeneratorExpressions.h"
18 /** \class cmAddTestCommand
19 * \brief Add a test to the lists of tests to run.
21 * cmAddTestCommand adds a test to the list of tests to run .
23 class cmAddTestCommand : public cmCommand
27 * This is a virtual constructor for the command.
29 virtual cmCommand* Clone()
31 return new cmAddTestCommand;
35 * This is called when the command is first encountered in
36 * the CMakeLists.txt file.
38 virtual bool InitialPass(std::vector<std::string> const& args,
39 cmExecutionStatus &status);
42 * The name of the command as specified in CMakeList.txt.
44 virtual const char* GetName() const { return "add_test";}
47 * Succinct documentation.
49 virtual const char* GetTerseDocumentation() const
51 return "Add a test to the project with the specified arguments.";
57 virtual const char* GetFullDocumentation() const
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"
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."
85 "Arguments after COMMAND may use \"generator expressions\" with the "
87 CM_DOCUMENT_ADD_TEST_GENERATOR_EXPRESSIONS
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\"."
98 cmTypeMacro(cmAddTestCommand, cmCommand);
100 bool HandleNameMode(std::vector<std::string> const& args);