1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: ctest.cxx,v $
6 Date: $Date: 2008-01-17 17:44:59 $
7 Version: $Revision: 1.101 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
18 #include "cmSystemTools.h"
20 // Need these for documentation support.
22 #include "cmDocumentation.h"
24 #include "CTest/cmCTestScriptHandler.h"
25 //----------------------------------------------------------------------------
26 static const char * cmDocumentationName
[][3] =
29 " ctest - Testing driver provided by CMake.", 0},
33 //----------------------------------------------------------------------------
34 static const char * cmDocumentationUsage
[][3] =
37 " ctest [options]", 0},
41 //----------------------------------------------------------------------------
42 static const char * cmDocumentationDescription
[][3] =
45 "The \"ctest\" executable is the CMake test driver program. "
46 "CMake-generated build trees created for projects that use "
47 "the ENABLE_TESTING and ADD_TEST commands have testing support. "
48 "This program will run the tests and report results.", 0},
52 //----------------------------------------------------------------------------
53 static const char * cmDocumentationOptions
[][3] =
55 {"-C <cfg>, --build-config <cfg>", "Choose configuration to test.",
56 "Some CMake-generated build trees can have multiple build configurations "
57 "in the same tree. This option can be used to specify which one should "
58 "be tested. Example configurations are \"Debug\" and \"Release\"."},
59 {"-V,--verbose", "Enable verbose output from tests.",
60 "Test output is normally suppressed and only summary information is "
61 "displayed. This option will show all test output."},
62 {"-VV,--extra-verbose", "Enable more verbose output from tests.",
63 "Test output is normally suppressed and only summary information is "
64 "displayed. This option will show even more test output."},
65 {"--debug", "Displaying more verbose internals of CTest.",
66 "This feature will result in large number of output that is mostly "
67 "useful for debugging dashboard problems."},
68 {"-Q,--quiet", "Make ctest quiet.",
69 "This option will suppress all the output. The output log file will "
70 "still be generated if the --output-log is specified. Options such "
71 "as --verbose, --extra-verbose, and --debug are ignored if --quiet is "
73 {"-O <file>, --output-log <file>", "Output to log file",
74 "This option tells ctest to write all its output to a log file."},
75 {"-N,--show-only", "Disable actual execution of tests.",
76 "This option tells ctest to list the tests that would be run but not "
77 "actually run them. Useful in conjunction with the -R and -E options."},
78 {"-R <regex>, --tests-regex <regex>", "Run tests matching regular "
80 "This option tells ctest to run only the tests whose names match the "
81 "given regular expression."},
82 {"-E <regex>, --exclude-regex <regex>", "Exclude tests matching regular "
84 "This option tells ctest to NOT run the tests whose names match the "
85 "given regular expression."},
86 {"-D <dashboard>, --dashboard <dashboard>", "Execute dashboard test",
87 "This option tells ctest to perform act as a Dart client and perform "
88 "a dashboard test. All tests are <Mode><Test>, where Mode can be "
89 "Experimental, Nightly, and Continuous, and Test can be Start, Update, "
90 "Configure, Build, Test, Coverage, and Submit."},
91 {"-M <model>, --test-model <model>", "Sets the model for a dashboard",
92 "This option tells ctest to act as a Dart client "
93 "where the TestModel can be Experimental, "
94 "Nightly, and Continuous. Combining -M and -T is similar to -D"},
95 {"-T <action>, --test-action <action>", "Sets the dashboard action to "
97 "This option tells ctest to act as a Dart client "
98 "and perform some action such as start, build, test etc. "
99 "Combining -M and -T is similar to -D"},
100 {"--track <track>", "Specify the track to submit dashboard to",
101 "Submit dashboard to specified track instead of default one. By "
102 "default, the dashboard is submitted to Nightly, Experimental, or "
103 "Continuous track, but by specifying this option, the track can be "
105 {"-S <script>, --script <script>", "Execute a dashboard for a "
107 "This option tells ctest to load in a configuration script which sets "
108 "a number of parameters such as the binary and source directories. Then "
109 "ctest will do what is required to create and run a dashboard. This "
110 "option basically sets up a dashboard and then runs ctest -D with the "
111 "appropriate options."},
112 {"-SP <script>, --script-new-process <script>", "Execute a dashboard for a "
114 "This option does the same operations as -S but it will do them in a "
115 "seperate process. This is primarily useful in cases where the script "
116 "may modify the environment and you do not want the modified enviroment "
117 "to impact other -S scripts."},
118 {"-A <file>, --add-notes <file>", "Add a notes file with submission",
119 "This option tells ctest to include a notes file when submitting "
121 {"-I [Start,End,Stride,test#,test#|Test file], --tests-information",
122 "Run a specific number of tests by number.",
123 "This option causes ctest to run tests starting at number Start, ending "
124 "at number End, and incrementing by Stride. Any additional numbers after "
125 "Stride are considered individual test numbers. Start, End,or stride "
126 "can be empty. Optionally a file can be given that contains the same "
127 "syntax as the command line."},
128 {"-U, --union", "Take the Union of -I and -R",
129 "When both -R and -I are specified by default the intersection of "
130 "tests are run. By specifying -U the union of tests is run instead."},
131 {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1.",
133 "This option causes ctest to run tests in either an interactive mode or "
134 "a non-interactive mode. On Windows this means that in non-interactive "
135 "mode, all system debug pop up windows are blocked. In dashboard mode "
136 "(Experimental, Nightly, Continuous), the default is non-interactive. "
137 "When just running tests not for a dashboard the default is to allow "
138 "popups and interactive "
140 {"--build-and-test", "Configure, build and run a test.",
141 "This option tells ctest to configure (i.e. run cmake on), build, and or "
142 "execute a test. The configure and test steps are optional. The arguments "
143 "to this command line are the source and binary directories. By default "
144 "this will run CMake on the Source/Bin directories specified unless "
145 "--build-nocmake is specified. Both --build-makeprogram and "
146 "--build-generator MUST be provided to use --built-and-test. If "
147 "--test-command is specified then that will be run after the build is "
148 "complete. Other options that affect this mode are --build-target "
149 "--build-nocmake, --build-run-dir, "
150 "--build-two-config, --build-exe-dir, --build-project,"
151 "--build-noclean, --build-options"},
152 {"--build-target", "Specify a specific target to build.",
153 "This option goes with the --build-and-test option, if left out the all "
154 "target is built." },
155 {"--build-nocmake", "Run the build without running cmake first.",
156 "Skip the cmake step." },
157 {"--build-run-dir", "Specify directory to run programs from.",
158 "Directory where programs will be after it has been compiled." },
159 {"--build-two-config", "Run CMake twice", "" },
160 {"--build-exe-dir", "Specify the directory for the executable.", "" },
161 {"--build-generator", "Specify the generator to use.", "" },
162 {"--build-project", "Specify the name of the project to build.", "" },
163 {"--build-makeprogram", "Specify the make program to use.", "" },
164 {"--build-noclean", "Skip the make clean step.", "" },
165 {"--build-config-sample",
166 "A sample executable to use to determine the configuraiton",
167 "A sample executable to use to determine the configuraiton that "
168 "should be used. e.g. Debug/Release/etc" },
169 {"--build-options", "Add extra options to the build step.",
170 "This option must be the last option with the exception of --test-command"
173 {"--test-command", "The test to run with the --build-and-test option.", ""
175 {"--test-timeout", "The time limit in seconds, internal use only.", ""
177 {"--tomorrow-tag", "Nightly or experimental starts with next day tag.",
178 "This is useful if the build will not finish in one day." },
179 {"--ctest-config", "The configuration file used to initialize CTest state "
180 "when submitting dashboards.",
181 "This option tells CTest to use different initialization file instead of "
182 "CTestConfiguration.tcl. This way multiple initialization files can be "
183 "used for example to submit to multiple dashboards." },
184 {"--overwrite", "Overwrite CTest configuration option.",
185 "By default ctest uses configuration options from configuration file. "
186 "This option will overwrite the configuration option." },
187 {"--extra-submit <file>[;<file>]", "Submit extra files to the dashboard.",
188 "This option will submit extra files to the dashboard." },
189 {"--force-new-ctest-process", "Run child CTest instances as new processes",
190 "By default CTest will run child CTest instances within the same process. "
191 "If this behavior is not desired, this argument will enforce new "
192 "processes for child CTest processes." },
193 {"--submit-index", "Submit individual dashboard tests with specific index",
194 "This option allows performing the same CTest action (such as test) "
195 "multiple times and submit all stages to the same dashboard (Dart2 "
196 "required). Each execution requires different index." },
200 //----------------------------------------------------------------------------
201 static const char * cmDocumentationSeeAlso
[][3] =
208 // this is a test driver program for cmCTest.
209 int main (int argc
, char *argv
[])
211 cmSystemTools::DoNotInheritStdPipes();
212 cmSystemTools::EnableMSVCDebugHook();
213 cmSystemTools::FindExecutableDirectory(argv
[0]);
217 if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
219 cmCTestLog(&inst
, ERROR_MESSAGE
,
220 "Current working directory cannot be established." << std::endl
);
224 // If there is a testing input file, check for documentation options
225 // only if there are actually arguments. We want running without
226 // arguments to run tests.
227 if(argc
> 1 || !cmSystemTools::FileExists("CTestTestfile.cmake"))
231 cmCTestLog(&inst
, ERROR_MESSAGE
, "*********************************"
233 << "No test configuration file found!" << std::endl
234 << "*********************************" << std::endl
);
237 if(doc
.CheckOptions(argc
, argv
) || nocwd
)
239 // Construct and print requested documentation.
240 std::vector
<cmDocumentationEntry
> commands
;
241 cmCTestScriptHandler
* ch
=
242 static_cast<cmCTestScriptHandler
*>(inst
.GetHandler("script"));
244 ch
->GetCommandDocumentation(commands
);
246 doc
.SetName("ctest");
247 doc
.SetSection("Name",cmDocumentationName
);
248 doc
.SetSection("Usage",cmDocumentationUsage
);
249 doc
.SetSection("Description",cmDocumentationDescription
);
250 doc
.SetSection("Options",cmDocumentationOptions
);
251 doc
.SetSection("Commands",commands
);
252 doc
.SetSeeAlsoList(cmDocumentationSeeAlso
);
256 return doc
.PrintRequestedDocumentation(std::cout
)? 0:1;
257 #define cout no_cout_use_cmCTestLog
262 std::string comspec
= "cmw9xcom.exe";
263 cmSystemTools::SetWindows9xComspecSubstitute(comspec
.c_str());
265 // copy the args to a vector
266 std::vector
<std::string
> args
;
267 for(int i
=0; i
< argc
; ++i
)
269 args
.push_back(argv
[i
]);
273 int res
= inst
.Run(args
,&output
);
274 cmCTestLog(&inst
, OUTPUT
, output
);