cmCTestCoverageCommand.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #include "cmCTestCoverageCommand.h"
  4. #include <set>
  5. #include <utility>
  6. #include <cm/memory>
  7. #include <cmext/string_view>
  8. #include "cmArgumentParser.h"
  9. #include "cmCTest.h"
  10. #include "cmCTestCoverageHandler.h"
  11. #include "cmCTestGenericHandler.h"
  12. #include "cmExecutionStatus.h"
  13. class cmMakefile;
  14. std::unique_ptr<cmCTestGenericHandler>
  15. cmCTestCoverageCommand::InitializeHandler(HandlerArguments& arguments,
  16. cmExecutionStatus& status) const
  17. {
  18. cmMakefile& mf = status.GetMakefile();
  19. auto& args = static_cast<CoverageArguments&>(arguments);
  20. this->CTest->SetCTestConfigurationFromCMakeVariable(
  21. &mf, "CoverageCommand", "CTEST_COVERAGE_COMMAND", args.Quiet);
  22. this->CTest->SetCTestConfigurationFromCMakeVariable(
  23. &mf, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", args.Quiet);
  24. auto handler = cm::make_unique<cmCTestCoverageHandler>(this->CTest);
  25. // If a LABELS option was given, select only files with the labels.
  26. if (args.Labels) {
  27. handler->SetLabelFilter(
  28. std::set<std::string>(args.Labels->begin(), args.Labels->end()));
  29. }
  30. handler->SetQuiet(args.Quiet);
  31. return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
  32. }
  33. bool cmCTestCoverageCommand::InitialPass(std::vector<std::string> const& args,
  34. cmExecutionStatus& status) const
  35. {
  36. using Args = CoverageArguments;
  37. static auto const parser =
  38. cmArgumentParser<Args>{ MakeHandlerParser<Args>() } //
  39. .Bind("LABELS"_s, &CoverageArguments::Labels);
  40. return this->Invoke(parser, args, status, [&](CoverageArguments& a) {
  41. return this->ExecuteHandlerCommand(a, status);
  42. });
  43. }