Skip to content

Commit ee3f22f

Browse files
committed
Allow faking GcovInfo to facilitate testing
1 parent 752833a commit ee3f22f

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/GcovImporter.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ GcovInfo::GcovInfo()
138138
}
139139
}
140140

141+
GcovInfo::GcovInfo(bool employBinning, bool jsonFormat,
142+
bool intermediateFormat)
143+
: employBinning(employBinning), jsonFormat(jsonFormat),
144+
intermediateFormat(intermediateFormat)
145+
{ }
146+
141147
std::function<GcovImporter::runner_f>
142148
GcovImporter::setRunner(std::function<runner_f> runner)
143149
{
@@ -149,8 +155,9 @@ GcovImporter::setRunner(std::function<runner_f> runner)
149155
GcovImporter::GcovImporter(const std::string &root,
150156
const std::string &covoutRoot,
151157
const std::vector<std::string> &exclude,
152-
const std::string &prefix)
153-
: rootDir(normalizePath(fs::absolute(root))),
158+
const std::string &prefix,
159+
GcovInfo gcovInfo)
160+
: gcovInfo(gcovInfo), rootDir(normalizePath(fs::absolute(root))),
154161
prefix(prefix)
155162
{
156163
for (const std::string &p : exclude) {

src/GcovImporter.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,18 @@
3333
class GcovInfo
3434
{
3535
public:
36+
/**
37+
* @brief Determines information about `gcov`.
38+
*/
3639
GcovInfo();
40+
/**
41+
* @brief Initializes data with predefined values.
42+
*
43+
* @param employBinning No calling `gcov` with identically named files.
44+
* @param jsonFormat If JSON format is available.
45+
* @param intermediateFormat If plain text format is available.
46+
*/
47+
GcovInfo(bool employBinning, bool jsonFormat, bool intermediateFormat);
3748

3849
public:
3950
/**
@@ -98,10 +109,11 @@ class GcovImporter
98109
* @param covoutRoot Root of subtree containing coverage data.
99110
* @param exclude List of paths to exclude.
100111
* @param prefix Prefix to be added to relative path of sources.
112+
* @param gcovInfo Information about `gcov` command.
101113
*/
102114
GcovImporter(const std::string &root, const std::string &covoutRoot,
103115
const std::vector<std::string> &exclude,
104-
const std::string &prefix);
116+
const std::string &prefix, GcovInfo gcovInfo = {});
105117

106118
public:
107119
/**

0 commit comments

Comments
 (0)