cmCTestCoverageCommand.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCTestCoverageCommand.h"
  4. #include "cmCTest.h"
  5. #include "cmCTestCoverageHandler.h"
  6. class cmCTestGenericHandler;
  7. cmCTestCoverageCommand::cmCTestCoverageCommand()
  8. {
  9. this->LabelsMentioned = false;
  10. }
  11. cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
  12. {
  13. this->CTest->SetCTestConfigurationFromCMakeVariable(
  14. this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
  15. this->CTest->SetCTestConfigurationFromCMakeVariable(
  16. this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS",
  17. this->Quiet);
  18. cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
  19. this->CTest->GetInitializedHandler("coverage"));
  20. if (!handler) {
  21. this->SetError("internal CTest error. Cannot instantiate test handler");
  22. return nullptr;
  23. }
  24. // If a LABELS option was given, select only files with the labels.
  25. if (this->LabelsMentioned) {
  26. handler->SetLabelFilter(this->Labels);
  27. }
  28. handler->SetQuiet(this->Quiet);
  29. return handler;
  30. }
  31. bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
  32. {
  33. // Look for arguments specific to this command.
  34. if (arg == "LABELS") {
  35. this->ArgumentDoing = ArgumentDoingLabels;
  36. this->LabelsMentioned = true;
  37. return true;
  38. }
  39. // Look for other arguments.
  40. return this->Superclass::CheckArgumentKeyword(arg);
  41. }
  42. bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg)
  43. {
  44. // Handle states specific to this command.
  45. if (this->ArgumentDoing == ArgumentDoingLabels) {
  46. this->Labels.insert(arg);
  47. return true;
  48. }
  49. // Look for other arguments.
  50. return this->Superclass::CheckArgumentValue(arg);
  51. }