cmCTestCoverageCommand.cxx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCTestCoverageCommand.h"
  11. #include "cmCTest.h"
  12. #include "cmCTestCoverageHandler.h"
  13. class cmCTestGenericHandler;
  14. cmCTestCoverageCommand::cmCTestCoverageCommand()
  15. {
  16. this->LabelsMentioned = false;
  17. }
  18. cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
  19. {
  20. this->CTest->SetCTestConfigurationFromCMakeVariable(
  21. this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
  22. this->CTest->SetCTestConfigurationFromCMakeVariable(
  23. this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS",
  24. this->Quiet);
  25. cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
  26. this->CTest->GetInitializedHandler("coverage"));
  27. if (!handler) {
  28. this->SetError("internal CTest error. Cannot instantiate test handler");
  29. return CM_NULLPTR;
  30. }
  31. // If a LABELS option was given, select only files with the labels.
  32. if (this->LabelsMentioned) {
  33. handler->SetLabelFilter(this->Labels);
  34. }
  35. handler->SetQuiet(this->Quiet);
  36. return handler;
  37. }
  38. bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
  39. {
  40. // Look for arguments specific to this command.
  41. if (arg == "LABELS") {
  42. this->ArgumentDoing = ArgumentDoingLabels;
  43. this->LabelsMentioned = true;
  44. return true;
  45. }
  46. // Look for other arguments.
  47. return this->Superclass::CheckArgumentKeyword(arg);
  48. }
  49. bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg)
  50. {
  51. // Handle states specific to this command.
  52. if (this->ArgumentDoing == ArgumentDoingLabels) {
  53. this->Labels.insert(arg);
  54. return true;
  55. }
  56. // Look for other arguments.
  57. return this->Superclass::CheckArgumentValue(arg);
  58. }