MCPcopy Create free account
hub / github.com/Kitware/CMake / HandleGCovCoverage

Method HandleGCovCoverage

Source/CTest/cmCTestCoverageHandler.cxx:849–1246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847 return static_cast<int>(cont->TotalCoverage.size());
848}
849int cmCTestCoverageHandler::HandleGCovCoverage(
850 cmCTestCoverageHandlerContainer* cont)
851{
852 std::string gcovCommand =
853 this->CTest->GetCTestConfiguration("CoverageCommand");
854 if (gcovCommand.empty()) {
855 cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
856 "Could not find gcov." << std::endl, this->Quiet);
857 return 0;
858 }
859 std::string gcovExtraFlags =
860 this->CTest->GetCTestConfiguration("CoverageExtraFlags");
861
862 // Immediately skip to next coverage option since codecov is only for Intel
863 // compiler
864 if (gcovCommand == "codecov") {
865 return 0;
866 }
867
868 // Style 1
869 std::string st1gcovOutputRex1 =
870 "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$";
871 std::string st1gcovOutputRex2 = "^Creating (.*\\.gcov)\\.";
872 cmsys::RegularExpression st1re1(st1gcovOutputRex1.c_str());
873 cmsys::RegularExpression st1re2(st1gcovOutputRex2.c_str());
874
875 // Style 2
876 std::string st2gcovOutputRex1 = "^File *[`'](.*)'$";
877 std::string st2gcovOutputRex2 =
878 "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$";
879 std::string st2gcovOutputRex3 = "^(.*)reating [`'](.*\\.gcov)'";
880 std::string st2gcovOutputRex4 = "^(.*):unexpected EOF *$";
881 std::string st2gcovOutputRex5 = "^(.*):cannot open source file*$";
882 std::string st2gcovOutputRex6 =
883 "^(.*):source file is newer than graph file `(.*)'$";
884 cmsys::RegularExpression st2re1(st2gcovOutputRex1.c_str());
885 cmsys::RegularExpression st2re2(st2gcovOutputRex2.c_str());
886 cmsys::RegularExpression st2re3(st2gcovOutputRex3.c_str());
887 cmsys::RegularExpression st2re4(st2gcovOutputRex4.c_str());
888 cmsys::RegularExpression st2re5(st2gcovOutputRex5.c_str());
889 cmsys::RegularExpression st2re6(st2gcovOutputRex6.c_str());
890
891 std::vector<std::string> files;
892 this->FindGCovFiles(files);
893
894 if (files.empty()) {
895 cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
896 " Cannot find any GCov coverage files." << std::endl,
897 this->Quiet);
898 // No coverage files is a valid thing, so the exit code is 0
899 return 0;
900 }
901
902 std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
903 std::string tempDir = testingDir + "/CoverageInfo";
904 if (!cmSystemTools::MakeDirectory(tempDir)) {
905 cmCTestLog(this->CTest, ERROR_MESSAGE,
906 "Unable to make directory: " << tempDir << std::endl);

Callers 1

ProcessHandlerMethod · 0.95

Calls 15

FindGCovFilesMethod · 0.95
joinCommandLineFunction · 0.85
cmHasLiteralPrefixFunction · 0.85
IsFileInDirFunction · 0.85
GetCTestConfigurationMethod · 0.80
c_strMethod · 0.80
GetBinaryDirMethod · 0.80
emplace_backMethod · 0.80
push_backMethod · 0.80
emptyMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected