Skip to content

Commit d98a8b1

Browse files
authored
fix fetcher & tests unused (#454)
* unused fetcher field removed * useless unit test removed * bit fields tests updated
1 parent e0a7834 commit d98a8b1

File tree

11 files changed

+111
-132
lines changed

11 files changed

+111
-132
lines changed

server/src/ReturnTypesFetcher.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void ReturnTypesFetcher::fetch(ProgressWriter *const progressWriter,
1010
testsMap[filePath];
1111
}
1212
Fetcher(Fetcher::Options::Value::RETURN_TYPE_NAMES_ONLY,
13-
testGen->getTargetBuildDatabase()->compilationDatabase, testsMap, nullptr, nullptr, nullptr,
13+
testGen->getTargetBuildDatabase()->compilationDatabase, testsMap, nullptr, nullptr,
1414
testGen->compileCommandsJsonPath, false)
1515
.fetchWithProgress(progressWriter, "Fetching return types for functions", true);
1616
for (auto const &[sourceFilePath, test] : testsMap) {

server/src/Server.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
200200
LOG_S(DEBUG) << logMessage;
201201
Fetcher fetcher(Fetcher::Options::Value::ALL,
202202
testGen.getTargetBuildDatabase()->compilationDatabase, testGen.tests, &testGen.types,
203-
&sizeContext.pointerSize, &sizeContext.maximumAlignment,
203+
&sizeContext.maximumAlignment,
204204
testGen.compileCommandsJsonPath, false);
205205
fetcher.fetchWithProgress(testGen.progressWriter, logMessage);
206206
SourceToHeaderRewriter(testGen.projectContext, testGen.getTargetBuildDatabase()->compilationDatabase,
@@ -552,7 +552,7 @@ Status Server::TestsGenServiceImpl::ProcessProjectStubsRequest(BaseTestGen *test
552552
LOG_S(DEBUG) << logMessage;
553553
Fetcher fetcher(Fetcher::Options::Value::TYPE | Fetcher::Options::Value::FUNCTION,
554554
testGen->getTargetBuildDatabase()->compilationDatabase, testGen->tests, &testGen->types,
555-
&sizeContext.pointerSize, &sizeContext.maximumAlignment,
555+
&sizeContext.maximumAlignment,
556556
testGen->compileCommandsJsonPath, false);
557557

558558
fetcher.fetchWithProgress(testGen->progressWriter, logMessage);

server/src/Synchronizer.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,
136136
auto filesInFolder = Paths::findFilesInFolder(stubDirPath);
137137
auto presentStubs = CollectionUtils::transformTo<StubSet>(
138138
dropHeaders(filesInFolder), [this](const fs::path &stubPath) {
139-
return StubOperator(Paths::stubPathToSourcePath(this->testGen->projectContext, stubPath), Paths::isHeaderFile(stubPath));
139+
return StubOperator(Paths::stubPathToSourcePath(this->testGen->projectContext, stubPath),
140+
Paths::isHeaderFile(stubPath));
140141
});
141142
StubSet stubFiles = CollectionUtils::unionSet(allStubs, presentStubs);
142143
tests::TestsMap stubFilesMap, sourceFilesMap;
@@ -153,11 +154,10 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,
153154

154155
auto stubFetcher =
155156
Fetcher(options, testGen->getProjectBuildDatabase()->compilationDatabase, sourceFilesMap, &testGen->types,
156-
&sizeContext->pointerSize, &sizeContext->maximumAlignment,
157+
&sizeContext->maximumAlignment,
157158
testGen->compileCommandsJsonPath, false);
158159

159-
stubFetcher.fetchWithProgress(testGen->progressWriter, "Finding source files required for stubs",
160-
true);
160+
stubFetcher.fetchWithProgress(testGen->progressWriter, "Finding source files required for stubs", true);
161161

162162
fs::path ccJsonStubDirPath =
163163
Paths::getUtbotBuildDir(testGen->projectContext) / "stubs_build_files";

server/src/fetchers/Fetcher.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ Fetcher::Fetcher(Options options,
2424
const std::shared_ptr<CompilationDatabase> &compilationDatabase,
2525
tests::TestsMap &tests,
2626
types::TypeMaps *types,
27-
size_t *pointerSize,
2827
size_t *maximumAlignment,
2928
const fs::path &compileCommandsJsonPath,
3029
bool fetchFunctionBodies)
31-
: options(options), projectTests(&tests), projectTypes(types),
32-
pointerSize(pointerSize), maximumAlignment(maximumAlignment),
33-
fetchFunctionBodies(fetchFunctionBodies), clangToolRunner(compilationDatabase) {
30+
: options(options), projectTests(&tests), projectTypes(types),
31+
maximumAlignment(maximumAlignment), fetchFunctionBodies(fetchFunctionBodies),
32+
clangToolRunner(compilationDatabase) {
3433
buildRootPath = Paths::subtractPath(compileCommandsJsonPath.string(), CompilationUtils::UTBOT_BUILD_DIR_NAME);
3534
if (options.has(Options::Value::TYPE)) {
3635
addMatcher<TypeDeclsMatchCallback>(anyTypeDeclarationMatcher);
@@ -83,6 +82,7 @@ void Fetcher::fetchWithProgress(const ProgressWriter *progressWriter,
8382

8483
void Fetcher::postProcess() const {
8584
if (options.has(Options::Value::FUNCTION) && maximumAlignment != nullptr) {
85+
// TODO maybe this is useless?
8686
for (auto projectTestsIterator = projectTests->begin();
8787
projectTestsIterator != projectTests->end(); projectTestsIterator++) {
8888
tests::Tests &tests = projectTestsIterator.value();

server/src/fetchers/Fetcher.h

-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class Fetcher {
5959
const std::shared_ptr<CompilationDatabase> &compilationDatabase,
6060
tests::TestsMap &tests,
6161
types::TypeMaps *types,
62-
size_t *pointerSize,
6362
size_t *maximumAlignment,
6463
const fs::path &compileCommandsJsonPath,
6564
bool fetchFunctionBodies);
@@ -76,7 +75,6 @@ class Fetcher {
7675

7776
tests::TestsMap *const projectTests;
7877
types::TypeMaps *const projectTypes;
79-
size_t *const pointerSize;
8078
size_t *const maximumAlignment;
8179
fs::path buildRootPath;
8280

server/src/fetchers/TypeDeclsMatchCallback.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ TypeDeclsMatchCallback::TypeDeclsMatchCallback(const Fetcher *parent)
1414
void TypeDeclsMatchCallback::run(const MatchFinder::MatchResult &Result) {
1515
QualType pointerType = Result.Context->getPointerType(Result.Context->getWideCharType());
1616
uint64_t pointerSize = Result.Context->getTypeSize(pointerType) / 8;
17-
*parent->pointerSize = pointerSize;
1817

1918
ExecUtils::throwIfCancelled();
2019
checkStructDecl(Result);

server/src/stubs/StubGen.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ StubGen::findStubFilesBySignatures(const std::vector<tests::Tests::MethodDescrip
4343
stubFilesMap[file].sourceFilePath = file;
4444
}
4545
Fetcher::Options::Value options = Fetcher::Options::Value::FUNCTION_NAMES_ONLY;
46-
Fetcher fetcher(options, stubsCdb, stubFilesMap, nullptr,
47-
nullptr, nullptr, ccJsonDirPath, true);
46+
Fetcher fetcher(options, stubsCdb, stubFilesMap, nullptr, nullptr, ccJsonDirPath, true);
4847
fetcher.fetchWithProgress(testGen.progressWriter, "Finding stub files", true);
4948
CollectionUtils::FileSet stubFilesSet;
5049
auto signatureNamesSet = CollectionUtils::transformTo<std::unordered_set<std::string>>(

server/test/framework/Regression_Tests.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -197,21 +197,6 @@ namespace {
197197
"ret");
198198
}
199199

200-
TEST_F(Regression_Test, Unnamed_Bit_Field) {
201-
fs::path source = getTestFilePath("PR124.c");
202-
auto [testGen, status] = createTestForFunction(source, 8);
203-
204-
ASSERT_TRUE(status.ok()) << status.error_message();
205-
206-
checkTestCasePredicates(
207-
testGen.tests.at(source).methods.begin().value().testCases,
208-
std::vector<TestCasePredicate>(
209-
{ [](const tests::Tests::MethodTestCase &testCase) {
210-
return !testCase.isError();
211-
} }),
212-
"bpf_xdp_attach");
213-
}
214-
215200
TEST_F(Regression_Test, VaList_In_Function_Pointer_Type) {
216201
fs::path source = getTestFilePath("PR123.c");
217202
auto [testGen, status] = createTestForFunction(source, 7);

0 commit comments

Comments
 (0)