| 847 | return static_cast<int>(cont->TotalCoverage.size()); |
| 848 | } |
| 849 | int 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); |
no test coverage detected