src: switch from Qt to boost implementation of executeProcess (#1145)

* changed implementation of executeProcess
* unified all different implementations of executeProcess
* separated arg list from command for all calls of executeProcess (this also required to remove quotes that were added to path args because otherwise the Python indexer would mistake absolute paths for relative paths.)
* update expected output for custom command tests
This commit is contained in:
Malte Langkabel
2021-02-22 16:00:32 +01:00
committed by GitHub
parent 9a13c194df
commit 3c1638da25
28 changed files with 430 additions and 417 deletions
+37 -16
View File
@@ -11,7 +11,8 @@ IndexerCommandType IndexerCommandCustom::getStaticIndexerCommandType()
}
IndexerCommandCustom::IndexerCommandCustom(
const std::wstring& customCommand,
const std::wstring& command,
const std::vector<std::wstring>& arguments,
const FilePath& projectFilePath,
const FilePath& databaseFilePath,
const std::wstring& databaseVersion,
@@ -19,7 +20,8 @@ IndexerCommandCustom::IndexerCommandCustom(
bool runInParallel)
: IndexerCommand(sourceFilePath)
, m_type(getStaticIndexerCommandType())
, m_customCommand(customCommand)
, m_command(command)
, m_arguments(arguments)
, m_projectFilePath(projectFilePath)
, m_databaseFilePath(databaseFilePath)
, m_databaseVersion(databaseVersion)
@@ -29,7 +31,8 @@ IndexerCommandCustom::IndexerCommandCustom(
IndexerCommandCustom::IndexerCommandCustom(
IndexerCommandType type,
const std::wstring& customCommand,
const std::wstring& command,
const std::vector<std::wstring>& arguments,
const FilePath& projectFilePath,
const FilePath& databaseFilePath,
const std::wstring& databaseVersion,
@@ -37,7 +40,8 @@ IndexerCommandCustom::IndexerCommandCustom(
bool runInParallel)
: IndexerCommand(sourceFilePath)
, m_type(type)
, m_customCommand(customCommand)
, m_command(command)
, m_arguments(arguments)
, m_projectFilePath(projectFilePath)
, m_databaseFilePath(databaseFilePath)
, m_databaseVersion(databaseVersion)
@@ -67,19 +71,19 @@ void IndexerCommandCustom::setDatabaseFilePath(const FilePath& databaseFilePath)
m_databaseFilePath = databaseFilePath;
}
std::wstring IndexerCommandCustom::getCustomCommand() const
std::wstring IndexerCommandCustom::getCommand() const
{
std::wstring command = m_customCommand;
return replaceVariables(m_command);
}
command = utility::replace(
command, L"%{PROJECT_FILE_PATH}", L'\"' + m_projectFilePath.wstr() + L'\"');
command = utility::replace(
command, L"%{DATABASE_FILE_PATH}", L'\"' + m_databaseFilePath.wstr() + L'\"');
command = utility::replace(command, L"%{DATABASE_VERSION}", L'\"' + m_databaseVersion + L'\"');
command = utility::replace(
command, L"%{SOURCE_FILE_PATH}", L'\"' + getSourceFilePath().wstr() + L'\"');
return command;
std::vector<std::wstring> IndexerCommandCustom::getArguments() const
{
std::vector<std::wstring> args;
for (const std::wstring& argument: m_arguments)
{
args.push_back(replaceVariables(argument));
}
return args;
}
bool IndexerCommandCustom::getRunInParallel() const
@@ -92,7 +96,15 @@ QJsonObject IndexerCommandCustom::doSerialize() const
QJsonObject jsonObject = IndexerCommand::doSerialize();
{
jsonObject["custom_command"] = QString::fromStdWString(m_customCommand);
jsonObject["command"] = QString::fromStdWString(m_command);
}
{
QJsonArray argumentsArray;
for (const std::wstring& argument: m_arguments)
{
argumentsArray.append(QString::fromStdWString(argument));
}
jsonObject["arguments"] = argumentsArray;
}
{
jsonObject["run_in_parallel"] = m_runInParallel;
@@ -100,3 +112,12 @@ QJsonObject IndexerCommandCustom::doSerialize() const
return jsonObject;
}
std::wstring IndexerCommandCustom::replaceVariables(std::wstring s) const
{
s = utility::replace(s, L"%{PROJECT_FILE_PATH}", m_projectFilePath.wstr());
s = utility::replace(s, L"%{DATABASE_FILE_PATH}", m_databaseFilePath.wstr());
s = utility::replace(s, L"%{DATABASE_VERSION}", m_databaseVersion);
s = utility::replace(s, L"%{SOURCE_FILE_PATH}", getSourceFilePath().wstr());
return s;
}