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

Method HandleTracePyCoverage

Source/CTest/cmCTestCoverageHandler.cxx:1566–1671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1564}
1565
1566int cmCTestCoverageHandler::HandleTracePyCoverage(
1567 cmCTestCoverageHandlerContainer* cont)
1568{
1569 cmsys::Glob gl;
1570 gl.RecurseOn();
1571 gl.RecurseThroughSymlinksOff();
1572 std::string daGlob = cont->BinaryDir + "/*.cover";
1573 gl.FindFiles(daGlob);
1574 std::vector<std::string> files = gl.GetFiles();
1575
1576 if (files.empty()) {
1577 cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
1578 " Cannot find any Python Trace.py coverage files."
1579 << std::endl,
1580 this->Quiet);
1581 // No coverage files is a valid thing, so the exit code is 0
1582 return 0;
1583 }
1584
1585 std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
1586 std::string tempDir = testingDir + "/CoverageInfo";
1587 cmSystemTools::MakeDirectory(tempDir);
1588
1589 int file_count = 0;
1590 for (std::string const& file : files) {
1591 std::string fileName = this->FindFile(cont, file);
1592 if (fileName.empty()) {
1593 cmCTestLog(this->CTest, ERROR_MESSAGE,
1594 "Cannot find source Python file corresponding to: "
1595 << file << std::endl);
1596 continue;
1597 }
1598
1599 std::string actualSourceFile = cmSystemTools::CollapseFullPath(fileName);
1600 cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
1601 " Check coverage for file: " << actualSourceFile
1602 << std::endl,
1603 this->Quiet);
1604 cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec =
1605 &cont->TotalCoverage[actualSourceFile];
1606 cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
1607 " in file: " << file << std::endl, this->Quiet);
1608 cmsys::ifstream ifile(file.c_str());
1609 if (!ifile) {
1610 cmCTestLog(this->CTest, ERROR_MESSAGE,
1611 "Cannot open file: " << file << std::endl);
1612 } else {
1613 long cnt = -1;
1614 std::string nl;
1615 while (cmSystemTools::GetLineFromStream(ifile, nl)) {
1616 cnt++;
1617
1618 // Skip empty lines
1619 if (nl.empty()) {
1620 continue;
1621 }
1622
1623 // Skip unused lines

Callers 1

ProcessHandlerMethod · 0.95

Calls 9

FindFileMethod · 0.95
FindFilesMethod · 0.80
GetBinaryDirMethod · 0.80
c_strMethod · 0.80
push_backMethod · 0.80
GetFilesMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected