2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2002-12-17 05:19:21 +03:00
|
|
|
#include "cmCTest.h"
|
2002-05-22 17:47:41 +04:00
|
|
|
#include "cmSystemTools.h"
|
2002-10-07 04:36:52 +04:00
|
|
|
|
2003-08-06 23:03:56 +04:00
|
|
|
// Need these for documentation support.
|
|
|
|
#include "cmDocumentation.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
2003-08-06 23:03:56 +04:00
|
|
|
|
2009-02-11 19:31:25 +03:00
|
|
|
#include "CTest/cmCTestLaunch.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "CTest/cmCTestScriptHandler.h"
|
2013-12-19 01:38:56 +04:00
|
|
|
#include "cmsys/Encoding.hxx"
|
2009-02-11 19:31:25 +03:00
|
|
|
|
2013-09-16 22:04:39 +04:00
|
|
|
static const char * cmDocumentationName[][2] =
|
2003-08-06 23:03:56 +04:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2013-09-16 22:04:39 +04:00
|
|
|
" ctest - Testing driver provided by CMake."},
|
|
|
|
{0,0}
|
2003-08-06 23:03:56 +04:00
|
|
|
};
|
|
|
|
|
2013-09-16 22:04:39 +04:00
|
|
|
static const char * cmDocumentationUsage[][2] =
|
2003-08-06 23:03:56 +04:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2013-09-16 22:04:39 +04:00
|
|
|
" ctest [options]"},
|
|
|
|
{0,0}
|
2003-08-06 23:03:56 +04:00
|
|
|
};
|
|
|
|
|
2013-09-16 22:04:39 +04:00
|
|
|
static const char * cmDocumentationOptions[][2] =
|
2003-08-06 23:03:56 +04:00
|
|
|
{
|
2013-09-16 22:04:39 +04:00
|
|
|
{"-C <cfg>, --build-config <cfg>", "Choose configuration to test."},
|
|
|
|
{"-V,--verbose", "Enable verbose output from tests."},
|
|
|
|
{"-VV,--extra-verbose", "Enable more verbose output from tests."},
|
|
|
|
{"--debug", "Displaying more verbose internals of CTest."},
|
2014-06-05 14:35:14 +04:00
|
|
|
{"--output-on-failure", "Output anything outputted by the test program "
|
|
|
|
"if the test should fail."},
|
2015-09-17 18:06:27 +03:00
|
|
|
{"--test-output-size-passed <size>", "Limit the output for passed tests "
|
|
|
|
"to <size> bytes"},
|
|
|
|
{"--test-output-size-failed <size>", "Limit the output for failed tests "
|
|
|
|
"to <size> bytes"},
|
2013-09-16 22:04:39 +04:00
|
|
|
{"-F", "Enable failover."},
|
2014-09-01 11:18:51 +04:00
|
|
|
{"-j <jobs>, --parallel <jobs>", "Run the tests in parallel using the "
|
2013-09-16 22:04:39 +04:00
|
|
|
"given number of jobs."},
|
|
|
|
{"-Q,--quiet", "Make ctest quiet."},
|
|
|
|
{"-O <file>, --output-log <file>", "Output to log file"},
|
|
|
|
{"-N,--show-only", "Disable actual execution of tests."},
|
2009-05-08 02:22:54 +04:00
|
|
|
{"-L <regex>, --label-regex <regex>", "Run tests with labels matching "
|
2013-09-16 22:04:39 +04:00
|
|
|
"regular expression."},
|
2006-03-09 19:57:43 +03:00
|
|
|
{"-R <regex>, --tests-regex <regex>", "Run tests matching regular "
|
2013-09-16 22:04:39 +04:00
|
|
|
"expression."},
|
2006-03-09 19:57:43 +03:00
|
|
|
{"-E <regex>, --exclude-regex <regex>", "Exclude tests matching regular "
|
2013-09-16 22:04:39 +04:00
|
|
|
"expression."},
|
2009-05-08 02:22:54 +04:00
|
|
|
{"-LE <regex>, --label-exclude <regex>", "Exclude tests with labels "
|
2013-09-16 22:04:39 +04:00
|
|
|
"matching regular expression."},
|
|
|
|
{"-D <dashboard>, --dashboard <dashboard>", "Execute dashboard test"},
|
|
|
|
{"-D <var>:<type>=<value>", "Define a variable for script mode"},
|
|
|
|
{"-M <model>, --test-model <model>", "Sets the model for a dashboard"},
|
2006-03-09 19:57:43 +03:00
|
|
|
{"-T <action>, --test-action <action>", "Sets the dashboard action to "
|
2013-09-16 22:04:39 +04:00
|
|
|
"perform"},
|
|
|
|
{"--track <track>", "Specify the track to submit dashboard to"},
|
2006-03-09 19:57:43 +03:00
|
|
|
{"-S <script>, --script <script>", "Execute a dashboard for a "
|
2013-09-16 22:04:39 +04:00
|
|
|
"configuration"},
|
2006-04-04 21:04:28 +04:00
|
|
|
{"-SP <script>, --script-new-process <script>", "Execute a dashboard for a "
|
2013-09-16 22:04:39 +04:00
|
|
|
"configuration"},
|
|
|
|
{"-A <file>, --add-notes <file>", "Add a notes file with submission"},
|
2006-03-09 19:57:43 +03:00
|
|
|
{"-I [Start,End,Stride,test#,test#|Test file], --tests-information",
|
2013-09-16 22:04:39 +04:00
|
|
|
"Run a specific number of tests by number."},
|
|
|
|
{"-U, --union", "Take the Union of -I and -R"},
|
|
|
|
{"--rerun-failed", "Run only the tests that failed previously"},
|
2015-03-06 00:51:10 +03:00
|
|
|
{"--repeat-until-fail <n>", "Require each test to run <n> "
|
|
|
|
"times without failing in order to pass"},
|
2013-09-16 22:04:39 +04:00
|
|
|
{"--max-width <width>", "Set the max width for a test name to output"},
|
|
|
|
{"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1."},
|
|
|
|
{"--no-label-summary", "Disable timing summary information for labels."},
|
|
|
|
{"--build-and-test", "Configure, build and run a test."},
|
|
|
|
{"--build-target", "Specify a specific target to build."},
|
|
|
|
{"--build-nocmake", "Run the build without running cmake first."},
|
|
|
|
{"--build-run-dir", "Specify directory to run programs from."},
|
|
|
|
{"--build-two-config", "Run CMake twice"},
|
|
|
|
{"--build-exe-dir", "Specify the directory for the executable."},
|
|
|
|
{"--build-generator", "Specify the generator to use."},
|
2014-09-05 23:14:13 +04:00
|
|
|
{"--build-generator-platform", "Specify the generator-specific platform."},
|
2013-09-16 22:04:39 +04:00
|
|
|
{"--build-generator-toolset", "Specify the generator-specific toolset."},
|
|
|
|
{"--build-project", "Specify the name of the project to build."},
|
|
|
|
{"--build-makeprogram", "Specify the make program to use."},
|
|
|
|
{"--build-noclean", "Skip the make clean step."},
|
2011-10-13 21:51:18 +04:00
|
|
|
{"--build-config-sample",
|
2013-09-16 22:04:39 +04:00
|
|
|
"A sample executable to use to determine the configuration"},
|
|
|
|
{"--build-options", "Add extra options to the build step."},
|
2005-03-10 18:04:21 +03:00
|
|
|
|
2013-09-16 22:04:39 +04:00
|
|
|
{"--test-command", "The test to run with the --build-and-test option."},
|
|
|
|
{"--test-timeout", "The time limit in seconds, internal use only."},
|
2015-06-09 15:50:44 +03:00
|
|
|
{"--test-load", "CPU load threshold for starting new parallel tests."},
|
2013-09-16 22:04:39 +04:00
|
|
|
{"--tomorrow-tag", "Nightly or experimental starts with next day tag."},
|
2006-03-09 19:57:43 +03:00
|
|
|
{"--ctest-config", "The configuration file used to initialize CTest state "
|
2014-09-01 11:18:51 +04:00
|
|
|
"when submitting dashboards."},
|
2013-09-16 22:04:39 +04:00
|
|
|
{"--overwrite", "Overwrite CTest configuration option."},
|
|
|
|
{"--extra-submit <file>[;<file>]", "Submit extra files to the dashboard."},
|
|
|
|
{"--force-new-ctest-process", "Run child CTest instances as new processes"},
|
|
|
|
{"--schedule-random", "Use a random order for scheduling tests"},
|
|
|
|
{"--submit-index", "Submit individual dashboard tests with specific index"},
|
|
|
|
{"--timeout <seconds>", "Set a global timeout on all tests."},
|
|
|
|
{"--stop-time <time>",
|
|
|
|
"Set a time at which all tests should stop running."},
|
|
|
|
{"--http1.0", "Submit using HTTP 1.0."},
|
|
|
|
{"--no-compress-output", "Do not compress test output when submitting."},
|
|
|
|
{"--print-labels", "Print all available test labels."},
|
|
|
|
{0,0}
|
2003-08-06 23:03:56 +04:00
|
|
|
};
|
|
|
|
|
2002-12-17 05:19:21 +03:00
|
|
|
// this is a test driver program for cmCTest.
|
2013-12-19 01:38:56 +04:00
|
|
|
int main (int argc, char const* const* argv)
|
2001-08-23 19:12:19 +04:00
|
|
|
{
|
2013-12-19 01:38:56 +04:00
|
|
|
cmsys::Encoding::CommandLineArguments encoding_args =
|
|
|
|
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
|
|
|
argc = encoding_args.argc();
|
|
|
|
argv = encoding_args.argv();
|
|
|
|
|
2007-09-11 19:21:36 +04:00
|
|
|
cmSystemTools::DoNotInheritStdPipes();
|
2002-12-11 19:49:08 +03:00
|
|
|
cmSystemTools::EnableMSVCDebugHook();
|
2013-11-08 00:30:59 +04:00
|
|
|
cmSystemTools::FindCMakeResources(argv[0]);
|
2009-02-11 19:31:25 +03:00
|
|
|
|
|
|
|
// Dispatch 'ctest --launch' mode directly.
|
|
|
|
if(argc >= 2 && strcmp(argv[1], "--launch") == 0)
|
|
|
|
{
|
|
|
|
return cmCTestLaunch::Main(argc, argv);
|
|
|
|
}
|
|
|
|
|
2005-06-01 01:32:40 +04:00
|
|
|
cmCTest inst;
|
2004-04-21 18:34:08 +04:00
|
|
|
|
2015-01-15 02:31:49 +03:00
|
|
|
if (cmSystemTools::GetCurrentWorkingDirectory().empty())
|
2004-04-21 18:34:08 +04:00
|
|
|
{
|
2006-03-09 19:57:43 +03:00
|
|
|
cmCTestLog(&inst, ERROR_MESSAGE,
|
|
|
|
"Current working directory cannot be established." << std::endl);
|
2013-02-07 17:53:50 +04:00
|
|
|
return 1;
|
2004-04-21 18:34:08 +04:00
|
|
|
}
|
|
|
|
|
2003-08-06 23:03:56 +04:00
|
|
|
// If there is a testing input file, check for documentation options
|
|
|
|
// only if there are actually arguments. We want running without
|
|
|
|
// arguments to run tests.
|
2011-10-13 21:51:18 +04:00
|
|
|
if(argc > 1 || !(cmSystemTools::FileExists("CTestTestfile.cmake") ||
|
2008-01-31 19:43:44 +03:00
|
|
|
cmSystemTools::FileExists("DartTestfile.txt")))
|
2003-08-06 23:03:56 +04:00
|
|
|
{
|
2003-08-08 01:43:37 +04:00
|
|
|
if(argc == 1)
|
|
|
|
{
|
2006-03-09 19:57:43 +03:00
|
|
|
cmCTestLog(&inst, ERROR_MESSAGE, "*********************************"
|
|
|
|
<< std::endl
|
2005-06-01 01:32:40 +04:00
|
|
|
<< "No test configuration file found!" << std::endl
|
|
|
|
<< "*********************************" << std::endl);
|
2003-08-08 01:43:37 +04:00
|
|
|
}
|
2003-08-06 23:03:56 +04:00
|
|
|
cmDocumentation doc;
|
2011-11-14 01:44:53 +04:00
|
|
|
doc.addCTestStandardDocSections();
|
2013-02-07 17:53:50 +04:00
|
|
|
if(doc.CheckOptions(argc, argv))
|
2003-08-06 23:03:56 +04:00
|
|
|
{
|
2013-10-16 20:54:52 +04:00
|
|
|
cmake hcm;
|
2015-05-05 00:01:29 +03:00
|
|
|
hcm.SetHomeDirectory("");
|
|
|
|
hcm.SetHomeOutputDirectory("");
|
2013-10-16 20:54:52 +04:00
|
|
|
hcm.AddCMakePaths();
|
|
|
|
|
2003-08-06 23:03:56 +04:00
|
|
|
// Construct and print requested documentation.
|
2007-06-09 00:06:33 +04:00
|
|
|
cmCTestScriptHandler* ch =
|
|
|
|
static_cast<cmCTestScriptHandler*>(inst.GetHandler("script"));
|
|
|
|
ch->CreateCMake();
|
|
|
|
|
2009-11-24 19:46:06 +03:00
|
|
|
doc.SetShowGenerators(false);
|
2003-08-06 23:03:56 +04:00
|
|
|
doc.SetName("ctest");
|
2007-10-22 20:49:09 +04:00
|
|
|
doc.SetSection("Name",cmDocumentationName);
|
|
|
|
doc.SetSection("Usage",cmDocumentationUsage);
|
2011-10-12 18:24:04 +04:00
|
|
|
doc.PrependSection("Options",cmDocumentationOptions);
|
2005-06-01 01:32:40 +04:00
|
|
|
#ifdef cout
|
|
|
|
# undef cout
|
|
|
|
#endif
|
2003-08-06 23:03:56 +04:00
|
|
|
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
2005-06-01 01:32:40 +04:00
|
|
|
#define cout no_cout_use_cmCTestLog
|
2003-08-06 23:03:56 +04:00
|
|
|
}
|
|
|
|
}
|
2006-03-09 19:57:43 +03:00
|
|
|
|
2004-01-07 19:24:22 +03:00
|
|
|
// copy the args to a vector
|
|
|
|
std::vector<std::string> args;
|
|
|
|
for(int i =0; i < argc; ++i)
|
2003-12-02 03:25:51 +03:00
|
|
|
{
|
2004-01-07 19:24:22 +03:00
|
|
|
args.push_back(argv[i]);
|
2003-12-02 03:25:51 +03:00
|
|
|
}
|
2004-01-07 19:24:22 +03:00
|
|
|
// run ctest
|
2005-02-22 17:12:10 +03:00
|
|
|
std::string output;
|
|
|
|
int res = inst.Run(args,&output);
|
2005-06-01 01:32:40 +04:00
|
|
|
cmCTestLog(&inst, OUTPUT, output);
|
2004-10-03 15:14:05 +04:00
|
|
|
|
|
|
|
return res;
|
2001-08-23 19:12:19 +04:00
|
|
|
}
|
2002-10-07 04:36:52 +04:00
|
|
|
|