diff options
Diffstat (limited to 'Source/CTest/cmParseGTMCoverage.cxx')
-rw-r--r-- | Source/CTest/cmParseGTMCoverage.cxx | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index e4ee699c4..1dc5b7038 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -1,15 +1,17 @@ #include "cmParseGTMCoverage.h" -#include "cmCTest.h" -#include "cmCTestCoverageHandler.h" -#include "cmSystemTools.h" +#include <cstdio> +#include <cstdlib> +#include <map> +#include <vector> #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" -#include <map> -#include <stdio.h> -#include <stdlib.h> -#include <vector> + +#include "cmCTest.h" +#include "cmCTestCoverageHandler.h" +#include "cmStringAlgorithms.h" +#include "cmSystemTools.h" cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest) @@ -30,9 +32,7 @@ bool cmParseGTMCoverage::LoadCoverageData(const char* d) for (i = 0; i < numf; i++) { std::string file = dir.GetFile(i); if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) { - std::string path = d; - path += "/"; - path += file; + std::string path = cmStrCat(d, '/', file); if (cmSystemTools::GetFilenameLastExtension(path) == ".mcov") { if (!this->ReadMCovFile(path.c_str())) { return false; @@ -75,7 +75,8 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file) this->Coverage.TotalCoverage[lastpath][lastoffset + linenumber] += count; } else { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not find mumps file : " + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Can not find mumps file : " << lastroutine << " referenced in this line of mcov data:\n" "[" @@ -85,6 +86,10 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file) } // Find the full path to the file bool found = this->FindMumpsFile(routine, filepath); + if (!found && cmHasLiteralSuffix(routine, "%")) { + routine.erase(0, 1); + found = this->FindMumpsFile(routine, filepath); + } if (found) { int lineoffset = 0; if (this->FindFunctionInMumpsFile(filepath, function, lineoffset)) { @@ -93,7 +98,7 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file) // This section accounts for lines that were previously marked // as non-executable code (-1), if the parser comes back with // a non-zero count, increase the count by 1 to push the line - // into the executable code set in addtion to the count found. + // into the executable code set in addition to the count found. if (coverageVector[lineoffset + linenumber] == -1 && count > 0) { coverageVector[lineoffset + linenumber] += count + 1; } else { @@ -102,9 +107,11 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file) lastoffset = lineoffset; } } else { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not find mumps file : " - << routine << " referenced in this line of mcov data:\n" - "[" + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Can not find mumps file : " + << routine + << " referenced in this line of mcov data:\n" + "[" << line << "]\n"); } lastfunction = function; @@ -144,8 +151,9 @@ bool cmParseGTMCoverage::FindFunctionInMumpsFile(std::string const& filepath, linenum++; // move to next line count } lineoffset = 0; - cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not find entry point : " - << function << " in " << filepath << "\n"); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Could not find entry point : " << function << " in " << filepath + << "\n"); return false; } @@ -156,7 +164,7 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, { // this method parses lines from the .mcov file // each line has ^COVERAGE(...) in it, and there - // are several varients of coverage lines: + // are several variants of coverage lines: // // ^COVERAGE("DIC11","PR1",0)="2:0:0:0" // ( file , entry, line ) = "number_executed:timing_info" @@ -182,14 +190,14 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, // save the argument into the argument vector args.push_back(arg); // start on a new argument - arg = ""; + arg.clear(); // if we are at the end of the ), then finish while loop if (cur == ')') { done = true; } } else { - // all chars except ", (, and % get stored in the arg string - if (cur != '\"' && cur != '(' && cur != '%') { + // all chars except " and ( get stored in the arg string + if (cur != '\"' && cur != '(') { arg.append(1, line[pos]); } } @@ -221,8 +229,8 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, } // less then two arguments is an error if (args.size() < 2) { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing mcov line: [" - << line << "]\n"); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error parsing mcov line: [" << line << "]\n"); return false; } routine = args[0]; // the routine is the first argument @@ -233,8 +241,8 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, // To avoid double counting of line 0 of each entry point, // Don't count the lines that do not give an explicit line // number. - routine = ""; - function = ""; + routine.clear(); + function.clear(); } else { // this is the format for this line // ^COVERAGE("%RSEL","SRC",count) |