diff options
author | Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com> | 2016-06-21 00:37:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-07-05 15:19:00 (GMT) |
commit | 6d8b9aa65ab06300a50f6c23897b9e37cadccc47 (patch) | |
tree | 93172f529e5972168ca3d0dcbf93b948798dadc0 /Source | |
parent | 280d0a6947aee7d73404a3d5d0a795d490a781db (diff) | |
download | CMake-6d8b9aa65ab06300a50f6c23897b9e37cadccc47.zip CMake-6d8b9aa65ab06300a50f6c23897b9e37cadccc47.tar.gz CMake-6d8b9aa65ab06300a50f6c23897b9e37cadccc47.tar.bz2 |
cmCTest: Improve readability adding "HandleTest(Action|Model)Argument()"
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCTest.cxx | 108 | ||||
-rw-r--r-- | Source/cmCTest.h | 8 |
2 files changed, 73 insertions, 43 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 9c6117a..858808a 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2044,52 +2044,15 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output) this->AddVariableDefinition(input); } - if (this->CheckArgument(arg, "-T", "--test-action") && - (i < args.size() - 1)) { - this->ProduceXML = true; - i++; - if (!this->SetTest(args[i].c_str(), false)) { - executeTests = false; - cmCTestLog(this, ERROR_MESSAGE, - "CTest -T called with incorrect option: " << args[i] - << std::endl); - cmCTestLog(this, ERROR_MESSAGE, "Available options are:" - << std::endl - << " " << ctestExec << " -T all" << std::endl - << " " << ctestExec << " -T start" << std::endl - << " " << ctestExec << " -T update" << std::endl - << " " << ctestExec << " -T configure" << std::endl - << " " << ctestExec << " -T build" << std::endl - << " " << ctestExec << " -T test" << std::endl - << " " << ctestExec << " -T coverage" << std::endl - << " " << ctestExec << " -T memcheck" << std::endl - << " " << ctestExec << " -T notes" << std::endl - << " " << ctestExec << " -T submit" << std::endl); - } + // calls SetTest(<stage>, /*report=*/ false) to enable the corresponding + // stage. <stage> is a string like 'All', 'Start', or 'Udpate'. + if (!this->HandleTestActionArgument(ctestExec, i, args)) { + executeTests = false; } // what type of test model - if (this->CheckArgument(arg, "-M", "--test-model") && - (i < args.size() - 1)) { - i++; - std::string const& str = args[i]; - if (cmSystemTools::LowerCase(str) == "nightly") { - this->SetTestModel(cmCTest::NIGHTLY); - } else if (cmSystemTools::LowerCase(str) == "continuous") { - this->SetTestModel(cmCTest::CONTINUOUS); - } else if (cmSystemTools::LowerCase(str) == "experimental") { - this->SetTestModel(cmCTest::EXPERIMENTAL); - } else { - executeTests = false; - cmCTestLog(this, ERROR_MESSAGE, - "CTest -M called with incorrect option: " << str - << std::endl); - cmCTestLog(this, ERROR_MESSAGE, "Available options are:" - << std::endl - << " " << ctestExec << " -M Continuous" << std::endl - << " " << ctestExec << " -M Experimental" << std::endl - << " " << ctestExec << " -M Nightly" << std::endl); - } + if (!this->HandleTestModelArgument(ctestExec, i, args)) { + executeTests = false; } if (this->CheckArgument(arg, "--extra-submit") && i < args.size() - 1) { @@ -2144,6 +2107,65 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output) return 1; } +bool cmCTest::HandleTestActionArgument(const char* ctestExec, size_t& i, + const std::vector<std::string>& args) +{ + bool success = true; + std::string arg = args[i]; + if (this->CheckArgument(arg, "-T", "--test-action") && + (i < args.size() - 1)) { + this->ProduceXML = true; + i++; + if (!this->SetTest(args[i].c_str(), false)) { + success = false; + cmCTestLog(this, ERROR_MESSAGE, "CTest -T called with incorrect option: " + << args[i] << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Available options are:" + << std::endl + << " " << ctestExec << " -T all" << std::endl + << " " << ctestExec << " -T start" << std::endl + << " " << ctestExec << " -T update" << std::endl + << " " << ctestExec << " -T configure" << std::endl + << " " << ctestExec << " -T build" << std::endl + << " " << ctestExec << " -T test" << std::endl + << " " << ctestExec << " -T coverage" << std::endl + << " " << ctestExec << " -T memcheck" << std::endl + << " " << ctestExec << " -T notes" << std::endl + << " " << ctestExec << " -T submit" << std::endl); + } + } + return success; +} + +bool cmCTest::HandleTestModelArgument(const char* ctestExec, size_t& i, + const std::vector<std::string>& args) +{ + bool success = true; + std::string arg = args[i]; + if (this->CheckArgument(arg, "-M", "--test-model") && + (i < args.size() - 1)) { + i++; + std::string const& str = args[i]; + if (cmSystemTools::LowerCase(str) == "nightly") { + this->SetTestModel(cmCTest::NIGHTLY); + } else if (cmSystemTools::LowerCase(str) == "continuous") { + this->SetTestModel(cmCTest::CONTINUOUS); + } else if (cmSystemTools::LowerCase(str) == "experimental") { + this->SetTestModel(cmCTest::EXPERIMENTAL); + } else { + success = false; + cmCTestLog(this, ERROR_MESSAGE, "CTest -M called with incorrect option: " + << str << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Available options are:" + << std::endl + << " " << ctestExec << " -M Continuous" << std::endl + << " " << ctestExec << " -M Experimental" << std::endl + << " " << ctestExec << " -M Nightly" << std::endl); + } + } + return success; +} + int cmCTest::ExecuteTests() { int res; diff --git a/Source/cmCTest.h b/Source/cmCTest.h index d8e48b1..f42a274 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -579,6 +579,14 @@ private: //! Output errors from a test void OutputTestErrors(std::vector<char> const& process_output); + //! Handle the --test-action command line argument + bool HandleTestActionArgument(const char* ctestExec, size_t& i, + const std::vector<std::string>& args); + + //! Handle the --test-model command line argument + bool HandleTestModelArgument(const char* ctestExec, size_t& i, + const std::vector<std::string>& args); + int RunCMakeAndTest(std::string* output); int ExecuteTests(); |