CMake/Source/ctest.cxx

186 lines
8.2 KiB
C++
Raw Normal View History

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
2016-09-27 22:01:08 +03:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include <cmConfigure.h>
2003-08-06 23:03:56 +04:00
#include "CTest/cmCTestLaunch.h"
#include "CTest/cmCTestScriptHandler.h"
#include "cmCTest.h"
#include "cmDocumentation.h"
#include "cmSystemTools.h"
#include "cmake.h"
#include <cmsys/Encoding.hxx>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
static const char* cmDocumentationName[][2] = {
2016-06-27 23:44:16 +03:00
{ CM_NULLPTR, " ctest - Testing driver provided by CMake." },
{ CM_NULLPTR, CM_NULLPTR }
2003-08-06 23:03:56 +04:00
};
2016-06-27 23:44:16 +03:00
static const char* cmDocumentationUsage[][2] = { { CM_NULLPTR,
" ctest [options]" },
{ CM_NULLPTR, CM_NULLPTR } };
static const char* cmDocumentationOptions[][2] = {
{ "-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." },
{ "--output-on-failure", "Output anything outputted by the test program "
"if the test should fail." },
{ "--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" },
{ "-F", "Enable failover." },
{ "-j <jobs>, --parallel <jobs>", "Run the tests in parallel using the "
"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." },
{ "-L <regex>, --label-regex <regex>", "Run tests with labels matching "
"regular expression." },
{ "-R <regex>, --tests-regex <regex>", "Run tests matching regular "
"expression." },
{ "-E <regex>, --exclude-regex <regex>", "Exclude tests matching regular "
"expression." },
{ "-LE <regex>, --label-exclude <regex>", "Exclude tests with labels "
"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" },
{ "-T <action>, --test-action <action>", "Sets the dashboard action to "
"perform" },
{ "--track <track>", "Specify the track to submit dashboard to" },
{ "-S <script>, --script <script>", "Execute a dashboard for a "
"configuration" },
{ "-SP <script>, --script-new-process <script>", "Execute a dashboard for a "
"configuration" },
{ "-A <file>, --add-notes <file>", "Add a notes file with submission" },
{ "-I [Start,End,Stride,test#,test#|Test file], --tests-information",
"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" },
{ "--repeat-until-fail <n>", "Require each test to run <n> "
"times without failing in order to pass" },
{ "--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." },
{ "--build-generator-platform", "Specify the generator-specific platform." },
{ "--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." },
{ "--build-config-sample",
"A sample executable to use to determine the configuration" },
{ "--build-options", "Add extra options to the build step." },
{ "--test-command", "The test to run with the --build-and-test option." },
{ "--test-timeout", "The time limit in seconds, internal use only." },
{ "--test-load", "CPU load threshold for starting new parallel tests." },
{ "--tomorrow-tag", "Nightly or experimental starts with next day tag." },
{ "--ctest-config", "The configuration file used to initialize CTest state "
"when submitting dashboards." },
{ "--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." },
2016-06-27 23:44:16 +03:00
{ CM_NULLPTR, CM_NULLPTR }
2003-08-06 23:03:56 +04:00
};
2002-12-17 05:19:21 +03:00
// this is a test driver program for cmCTest.
int main(int argc, char const* const* argv)
2001-08-23 19:12:19 +04:00
{
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = encoding_args.argc();
argv = encoding_args.argv();
cmSystemTools::DoNotInheritStdPipes();
cmSystemTools::EnableMSVCDebugHook();
cmSystemTools::FindCMakeResources(argv[0]);
// Dispatch 'ctest --launch' mode directly.
if (argc >= 2 && strcmp(argv[1], "--launch") == 0) {
return cmCTestLaunch::Main(argc, argv);
}
cmCTest inst;
if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
2006-03-09 19:57:43 +03:00
cmCTestLog(&inst, ERROR_MESSAGE,
"Current working directory cannot be established."
<< std::endl);
return 1;
}
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.
if (argc > 1 ||
!(cmSystemTools::FileExists("CTestTestfile.cmake") ||
cmSystemTools::FileExists("DartTestfile.txt"))) {
if (argc == 1) {
2006-03-09 19:57:43 +03:00
cmCTestLog(&inst, ERROR_MESSAGE, "*********************************"
<< std::endl
<< "No test configuration file found!" << std::endl
<< "*********************************" << std::endl);
}
2003-08-06 23:03:56 +04:00
cmDocumentation doc;
doc.addCTestStandardDocSections();
if (doc.CheckOptions(argc, argv)) {
cmake hcm;
hcm.SetHomeDirectory("");
hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
2003-08-06 23:03:56 +04:00
// Construct and print requested documentation.
cmCTestScriptHandler* ch =
static_cast<cmCTestScriptHandler*>(inst.GetHandler("script"));
ch->CreateCMake();
doc.SetShowGenerators(false);
2003-08-06 23:03:56 +04:00
doc.SetName("ctest");
doc.SetSection("Name", cmDocumentationName);
doc.SetSection("Usage", cmDocumentationUsage);
doc.PrependSection("Options", cmDocumentationOptions);
#ifdef cout
#undef cout
#endif
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
#define cout no_cout_use_cmCTestLog
2003-08-06 23:03:56 +04:00
}
}
2006-03-09 19:57:43 +03:00
// copy the args to a vector
std::vector<std::string> args;
for (int i = 0; i < argc; ++i) {
args.push_back(argv[i]);
}
// run ctest
std::string output;
int res = inst.Run(args, &output);
cmCTestLog(&inst, OUTPUT, output);
2004-10-03 15:14:05 +04:00
return res;
2001-08-23 19:12:19 +04:00
}