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

Method ShouldIDoCoverage

Source/CTest/cmCTestCoverageHandler.cxx:104–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
105 std::string const& srcDir,
106 std::string const& binDir)
107{
108 if (this->IsFilteredOut(file)) {
109 return false;
110 }
111
112 for (cmsys::RegularExpression& rx : this->CustomCoverageExcludeRegex) {
113 if (rx.find(file)) {
114 cmCTestOptionalLog(
115 this->CTest, HANDLER_VERBOSE_OUTPUT,
116 " File " << file << " is excluded in CTestCustom.ctest" << std::endl;
117 , this->Quiet);
118 return false;
119 }
120 }
121
122 std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir);
123 std::string fBinDir = cmSystemTools::CollapseFullPath(binDir);
124 std::string fFile = cmSystemTools::CollapseFullPath(file);
125 bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile, fSrcDir);
126 bool buildSubDir = cmSystemTools::IsSubDirectory(fFile, fBinDir);
127 // Always check parent directory of the file.
128 std::string fileDir = cmSystemTools::GetFilenamePath(fFile);
129 std::string checkDir;
130
131 // We also need to check the binary/source directory pair.
132 if (sourceSubDir && buildSubDir) {
133 if (fSrcDir.size() > fBinDir.size()) {
134 checkDir = fSrcDir;
135 } else {
136 checkDir = fBinDir;
137 }
138 } else if (sourceSubDir) {
139 checkDir = fSrcDir;
140 } else if (buildSubDir) {
141 checkDir = fBinDir;
142 }
143 std::string ndc = cmSystemTools::FileExistsInParentDirectories(
144 ".NoDartCoverage", fFile, checkDir);
145 if (!ndc.empty()) {
146 cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
147 "Found: " << ndc << " so skip coverage of " << file
148 << std::endl,
149 this->Quiet);
150 return false;
151 }
152
153 // By now checkDir should be set to parent directory of the file.
154 // Get the relative path to the file an apply it to the opposite directory.
155 // If it is the same as fileDir, then ignore, otherwise check.
156 std::string relPath;
157 if (!checkDir.empty()) {
158 relPath = cmSystemTools::RelativePath(checkDir, fFile);
159 } else {
160 relPath = fFile;
161 }

Callers 3

ProcessHandlerMethod · 0.95
FindUncoveredFilesMethod · 0.95

Calls 4

IsFilteredOutMethod · 0.95
findMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected