cmCTestCoverageCommand.cxx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  24. "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS");
  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. return handler;
  38. }
  39. //----------------------------------------------------------------------------
  40. bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
  41. {
  42. // Look for arguments specific to this command.
  43. if(arg == "LABELS")
  44. {
  45. this->ArgumentDoing = ArgumentDoingLabels;
  46. this->LabelsMentioned = true;
  47. return true;
  48. }
  49. // Look for other arguments.
  50. return this->Superclass::CheckArgumentKeyword(arg);
  51. }
  52. //----------------------------------------------------------------------------
  53. bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg)
  54. {
  55. // Handle states specific to this command.
  56. if(this->ArgumentDoing == ArgumentDoingLabels)
  57. {
  58. this->Labels.insert(arg);
  59. return true;
  60. }
  61. // Look for other arguments.
  62. return this->Superclass::CheckArgumentValue(arg);
  63. }