cmCTestCoverageCommand.cxx 2.3 KB

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