Skip to content

Commit 1656423

Browse files
committed
Fixing generations for files that included in two targets
1 parent 6a86fef commit 1656423

21 files changed

+356
-137
lines changed

server/src/Paths.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Paths {
3232
CollectionUtils::FileSet filtered =
3333
CollectionUtils::filterOut(paths, [&dirPaths, &filter](const fs::path &path) {
3434
return !std::any_of(dirPaths.begin(), dirPaths.end(), [&](const fs::path &dirPath) {
35-
return path.parent_path() == dirPath && fs::exists(path) && filter(path);
35+
return isSubPathOf(dirPath, path) && fs::exists(path) && filter(path);
3636
});
3737
});
3838
return filtered;

server/src/Server.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,6 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
213213
Synchronizer synchronizer(&testGen, &stubGen, &sizeContext);
214214
synchronizer.synchronize(typesHandler);
215215

216-
if(testGen.settingsContext.useStubs) {
217-
testsWriter->writeStubs(testGen.synchronizedStubs);
218-
}
219-
220216
std::shared_ptr<LineInfo> lineInfo = nullptr;
221217
auto lineTestGen = dynamic_cast<LineTestGen *>(&testGen);
222218

server/src/Synchronizer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ void Synchronizer::synchronize(const types::TypesHandler &typesHandler) {
118118
return;
119119
}
120120
auto outdatedSourcePaths = getOutdatedSourcePaths();
121-
auto outdatedStubs = getStubSetFromSources(outdatedSourcePaths);
122-
synchronizeStubs(outdatedStubs, typesHandler);
121+
if (testGen->settingsContext.useStubs) {
122+
auto outdatedStubs = getStubSetFromSources(outdatedSourcePaths);
123+
synchronizeStubs(outdatedStubs, typesHandler);
124+
}
123125
synchronizeWrappers(outdatedSourcePaths);
124126
}
125127

server/src/building/BaseCommand.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
#include "tasks/ShellExecTask.h"
1212
#include "utils/CollectionUtils.h"
1313
#include "utils/StringUtils.h"
14+
#include "utils/path/FileSystemPath.h"
1415

1516
#include "loguru.h"
1617

1718
#include <algorithm>
18-
#include "utils/path/FileSystemPath.h"
1919
#include <iterator>
2020
#include <set>
2121
#include <utility>
@@ -25,6 +25,7 @@ namespace utbot {
2525
: commandLine(std::move(commandLine)), directory(std::move(directory)) {
2626
initOptimizationLevel();
2727
}
28+
2829
BaseCommand::BaseCommand(std::vector<std::string> commandLine, fs::path directory)
2930
: commandLine(commandLine.begin(), commandLine.end()), directory(std::move(directory)) {
3031
initOptimizationLevel();

server/src/building/Linker.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,12 @@ Result<Linker::LinkResult> Linker::linkWholeTarget(const fs::path &target) {
155155
insideFolder = false;
156156
}
157157
}
158-
if (testGen.buildDatabase->isFirstObjectFileForSource(objectFile) &&
159-
!CollectionUtils::contains(testedFiles, objectInfo->getSourcePath()) &&
160-
insideFolder) {
161-
filesToLink.insert(
162-
{ objectFile, objectInfo->kleeFilesInfo->getKleeBitcodeFile() });
158+
if (!CollectionUtils::contains(testedFiles, objectInfo->getSourcePath()) && insideFolder) {
159+
filesToLink.emplace(objectFile, objectInfo->kleeFilesInfo->getKleeBitcodeFile());
163160
} else {
164161
siblingObjectsToBuild.insert(objectInfo->getOutputFile());
165-
fs::path bitcodeFile =
166-
testGen.buildDatabase->getBitcodeForSource(objectInfo->getSourcePath());
167-
filesToLink.emplace(objectFile, bitcodeFile);
162+
filesToLink.emplace(objectFile, testGen.buildDatabase->getBitcodeForSource(
163+
objectInfo->getSourcePath()));
168164
}
169165
}
170166

@@ -673,7 +669,7 @@ Linker::getLinkActionsForExecutable(fs::path const &workingDir,
673669
CollectionUtils::MapFileTo<fs::path> const &dependencies,
674670
BuildDatabase::TargetInfo const &linkUnitInfo,
675671
fs::path const &output) {
676-
672+
677673
using namespace DynamicLibraryUtils;
678674

679675
auto commands = CollectionUtils::transform(

server/src/streams/tests/ServerTestsWriter.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,15 @@ void ServerTestsWriter::writeTestsWithProgress(tests::TestsMap &testMap,
2727
writeCompleted(testMap, totalTestsCounter);
2828
}
2929

30-
void ServerTestsWriter::writeStubs(const std::vector<Stubs> &synchronizedStubs) {
31-
testsgen::TestsResponse response;
32-
auto stubsResponse = std::make_unique<testsgen::StubsResponse>();
33-
for (auto const &synchronizedStub : synchronizedStubs) {
34-
auto sData = stubsResponse->add_stubsources();
35-
sData->set_filepath(synchronizedStub.filePath);
36-
if (synchronizeCode) {
37-
sData->set_code(synchronizedStub.code);
38-
}
39-
}
40-
response.set_allocated_stubs(stubsResponse.release());
41-
}
42-
4330
bool ServerTestsWriter::writeFileAndSendResponse(const tests::Tests &tests,
4431
const fs::path &testDirPath,
4532
const std::string &message,
4633
double percent,
4734
bool isCompleted) const {
4835
fs::path testFilePath = testDirPath / tests.relativeFileDir / tests.testFilename;
49-
FileSystemUtils::writeToFile(testFilePath, tests.code);
36+
if (!tests.code.empty()) {
37+
FileSystemUtils::writeToFile(testFilePath, tests.code);
38+
}
5039
if (!hasStream()) {
5140
return false;
5241
}

server/src/streams/tests/ServerTestsWriter.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ class ServerTestsWriter : public TestsWriter {
2222
const fs::path &testDirPath,
2323
std::function<void(tests::Tests &)> &&functor) override;
2424

25-
void writeStubs(const std::vector<Stubs> &synchronizedStubs) override;
26-
2725
private:
2826
[[nodiscard]] virtual bool writeFileAndSendResponse(const tests::Tests &tests,
2927
const fs::path &testDirPath,

server/src/streams/tests/TestsWriter.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ class TestsWriter : public utbot::ServerWriter<testsgen::TestsResponse> {
2424
const fs::path &testDirPath,
2525
std::function<void(tests::Tests &)> &&functor) = 0;
2626

27-
virtual void writeStubs(const std::vector<Stubs> &synchronizedStubs) {
28-
// Default implementation is empty.
29-
}
30-
3127
protected:
3228
void writeCompleted(tests::TestsMap const &testMap, int totalTestsCounter);
3329

server/test/framework/Server_Tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,10 +1524,10 @@ namespace {
15241524
}
15251525
};
15261526

1527-
const std::vector<ProjectInfo> testRelativeDirs = { { fs::path("executable"), 3 },
1528-
{ fs::path("static_library"), 3 },
1529-
{ fs::path("shared_library"), 3 },
1530-
{ fs::path("timeout"), 1 } };
1527+
const std::vector<ProjectInfo> testRelativeDirs = { { fs::path("executable"), 6 },
1528+
{ fs::path("static_library"), 6 },
1529+
{ fs::path("shared_library"), 6 },
1530+
{ fs::path("timeout"), 2 } };
15311531

15321532
INSTANTIATE_TEST_SUITE_P(
15331533
DifferentCompilersAndSuites,

0 commit comments

Comments
 (0)