forked from AndersenSemenov/UTBotCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoverageTool.cpp
More file actions
44 lines (37 loc) · 1.69 KB
/
CoverageTool.cpp
File metadata and controls
44 lines (37 loc) · 1.69 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
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
*/
#include "CoverageTool.h"
#include "GcovCoverageTool.h"
#include "LlvmCoverageTool.h"
#include "exceptions/CoverageGenerationException.h"
#include "utils/CompilationUtils.h"
#include "utils/StringUtils.h"
#include "KcovCoverageTool.h"
using namespace CompilationUtils;
CoverageTool::CoverageTool(ProgressWriter const *progressWriter) : progressWriter(progressWriter) {
}
std::unique_ptr<CoverageTool> getCoverageTool(const std::string &compileCommandsJsonPath,
utbot::ProjectContext projectContext,
ProgressWriter const *progressWriter,
bool withKcov) {
if (withKcov) {
return std::make_unique<KcovCoverageTool>(projectContext, progressWriter);
}
auto compilationDatabase = CompilationUtils::getCompilationDatabase(compileCommandsJsonPath);
fs::path compilerPath = compilationDatabase->getBuildCompilerPath();
CompilerName compilerName = CompilationUtils::getCompilerName(compilerPath);
switch (compilerName) {
case CompilerName::GCC:
case CompilerName::GXX:
return std::make_unique<GcovCoverageTool>(projectContext, progressWriter);
case CompilerName::CLANG:
case CompilerName::CLANGXX:
return std::make_unique<LlvmCoverageTool>(projectContext, progressWriter);
default:
throw CoverageGenerationException("Coverage tool for your compiler is not implemented");
}
}
std::string CoverageTool::getTestFilter(const UnitTest &unitTest) const {
return StringUtils::stringFormat("--gtest_filter=*.%s", unitTest.testname);
}