Skip to content

Commit e768496

Browse files
authored
Test paths in makefiles have been replaced with relative ones (#681)
1 parent e2e08a0 commit e768496

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

server/src/printers/RelativeMakefilePrinter.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ RelativeMakefilePrinter::RelativeMakefilePrinter(PathToShellVariable pathToShell
1111
RelativeMakefilePrinter::RelativeMakefilePrinter(
1212
const fs::path &buildDirectory,
1313
const fs::path &buildDirectoryRelative,
14-
const fs::path &projectPath)
14+
const fs::path &projectPath,
15+
const fs::path &testsPath)
1516
: DefaultMakefilePrinter(),
1617
pathToShellVariable{{{buildDirectory, "$(BUILD_DIR)"},
18+
{testsPath, "$(TESTS_DIR)"},
1719
{projectPath, "$(PROJECT_DIR)"},
1820
{buildDirectoryRelative, "$(BUILD_RELATIVE)"}},
1921
[](const std::string& lhs, const std::string& rhs) -> bool {
@@ -23,6 +25,7 @@ RelativeMakefilePrinter::RelativeMakefilePrinter(
2325
return std::greater<>()(lhs, rhs);
2426
}},
2527
buildDirectoryRelative{buildDirectoryRelative},
28+
testsPath{testsPath},
2629
projectPath{projectPath} {
2730
initializePathsToShellVariables();
2831
}
@@ -71,6 +74,8 @@ std::string RelativeMakefilePrinter::getProjectStructureRelativeTo(const fs::pat
7174
printer.declareVariable("export PROJECT_DIR", "$(MAKEFILE_DIR)/$(PROJECT_DIR_RELATIVE_TO_MAKEFILE)");
7275
printer.declareVariable("export BUILD_RELATIVE", buildDirectoryRelative);
7376
printer.declareVariable("export BUILD_DIR", "$(PROJECT_DIR)/$(BUILD_RELATIVE)");
77+
printer.declareVariable("export TESTS_DIR_RELATIVE", fs::relative(testsPath, makefilePath.parent_path()));
78+
printer.declareVariable("export TESTS_DIR", "$(MAKEFILE_DIR)/$(TESTS_DIR_RELATIVE)");
7479
return printer.ss.str();
7580
}
7681

server/src/printers/RelativeMakefilePrinter.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class RelativeMakefilePrinter : public DefaultMakefilePrinter {
1212
RelativeMakefilePrinter(PathToShellVariable pathToShellVariable);
1313
RelativeMakefilePrinter(const fs::path &buildDirectory,
1414
const fs::path &buildDirectoryRelative,
15-
const fs::path &projectPath);
15+
const fs::path &projectPath,
16+
const fs::path &testsPath);
1617

1718
~RelativeMakefilePrinter() override = default;
1819

@@ -23,7 +24,7 @@ class RelativeMakefilePrinter : public DefaultMakefilePrinter {
2324
void initializePathsToShellVariables();
2425

2526
protected:
26-
fs::path buildDirectoryRelative, projectPath;
27+
fs::path buildDirectoryRelative, testsPath, projectPath;
2728

2829
// map variable with absolute path to $(someVar)
2930
std::map<std::string, fs::path, std::function<bool(const std::string&, const std::string&)>> pathToShellVariable;

server/src/printers/TestMakefilesPrinter.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ namespace printer {
4747
CollectionUtils::FileSet const *stubSources) :
4848
RelativeMakefilePrinter(Paths::getUTBotBuildDir(testGen->projectContext),
4949
Paths::getRelativeUtbotBuildDir(testGen->projectContext),
50-
testGen->projectContext.projectPath),
50+
testGen->projectContext.projectPath,
51+
testGen->projectContext.getTestDirAbsPath()),
5152
projectContext(testGen->projectContext),
5253
sharedMakefilePrinter(testGen, rootPath, primaryCompiler, stubSources, pathToShellVariable),
5354
objMakefilePrinter(testGen, rootPath, primaryCompiler, stubSources, pathToShellVariable) {

0 commit comments

Comments
 (0)