cmCTestCoverageCommand.cxx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. //----------------------------------------------------------------------------
  14. cmCTestCoverageCommand::cmCTestCoverageCommand()
  15. {
  16. this->LabelsMentioned = false;
  17. }
  18. //----------------------------------------------------------------------------
  19. cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
  20. {
  21. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  22. "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
  23. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  24. "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", this->Quiet);
  25. cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
  26. this->CTest->GetInitializedHandler("coverage"));
  27. if ( !handler )
  28. {
  29. this->SetError("internal CTest error. Cannot instantiate test handler");
  30. return 0;
  31. }
  32. // If a LABELS option was given, select only files with the labels.
  33. if(this->LabelsMentioned)
  34. {
  35. handler->SetLabelFilter(this->Labels);
  36. }
  37. handler->SetQuiet(this->Quiet);
  38. return handler;
  39. }
  40. //----------------------------------------------------------------------------
  41. bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
  42. {
  43. // Look for arguments specific to this command.
  44. if(arg == "LABELS")
  45. {
  46. this->ArgumentDoing = ArgumentDoingLabels;
  47. this->LabelsMentioned = true;
  48. return true;
  49. }
  50. // Look for other arguments.
  51. return this->Superclass::CheckArgumentKeyword(arg);
  52. }
  53. //----------------------------------------------------------------------------
  54. bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg)
  55. {
  56. // Handle states specific to this command.
  57. if(this->ArgumentDoing == ArgumentDoingLabels)
  58. {
  59. this->Labels.insert(arg);
  60. return true;
  61. }
  62. // Look for other arguments.
  63. return this->Superclass::CheckArgumentValue(arg);
  64. }