forked from AndersenSemenov/UTBotCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoverageTool.h
More file actions
60 lines (45 loc) · 1.92 KB
/
Copy pathCoverageTool.h
File metadata and controls
60 lines (45 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
*/
#ifndef UNITTESTBOT_COVERAGETOOL_H
#define UNITTESTBOT_COVERAGETOOL_H
#include "Coverage.h"
#include "ProjectContext.h"
#include "UnitTest.h"
#include "streams/IStreamWriter.h"
#include "streams/WriterUtils.h"
#include "utils/MakefileUtils.h"
#include <string>
#include <vector>
struct BuildRunCommand {
UnitTest unitTest;
MakefileUtils::MakefileCommand buildCommand;
MakefileUtils::MakefileCommand runCommand;
};
class CoverageTool {
protected:
ProgressWriter const *progressWriter;
[[nodiscard]] std::string getTestFilter(UnitTest const &unitTest) const;
public:
explicit CoverageTool(ProgressWriter const *progressWriter);
[[nodiscard]] virtual std::vector<BuildRunCommand>
getBuildRunCommands(const std::vector<UnitTest> &testsToLaunch, bool withCoverage) = 0;
[[nodiscard]] virtual std::vector<ShellExecTask>
getCoverageCommands(const std::vector<UnitTest> &testsToLaunch) = 0;
[[nodiscard]] virtual Coverage::CoverageMap getCoverageInfo() const = 0;
/**
* Get coverage rate in percents for all processed files.
* Coverage rates for gcov are more accurate because the
* calculation ignores UTBot wrappers that boost project rates.
* @return json with coverage rates. llvm-cov returns line, function
* and region cover percentages, gcov calculates line coverage only.
*/
[[nodiscard]] virtual nlohmann::json getTotals() const = 0;
virtual void cleanCoverage() const = 0;
virtual ~CoverageTool() = default;
};
std::unique_ptr<CoverageTool> getCoverageTool(const std::string &compileCommandsJsonPath,
utbot::ProjectContext projectContext,
const ProgressWriter *progressWriter,
bool withKcov);
#endif // UNITTESTBOT_COVERAGETOOL_H