From 66900b1deb5137616137662a1163ce5d337f046b Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 9 Nov 2021 12:33:00 +0100 Subject: [PATCH] Autotest: Simplify ITestConfiguration::executableFilePath() Change-Id: I7a3cdcc896b073a5cc24d00487902f4baff8719c Reviewed-by: Christian Stenger --- src/plugins/autotest/testconfiguration.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp index 09f17670c9c..4599fc7606b 100644 --- a/src/plugins/autotest/testconfiguration.cpp +++ b/src/plugins/autotest/testconfiguration.cpp @@ -83,21 +83,9 @@ FilePath ITestConfiguration::executableFilePath() const if (!hasExecutable()) return {}; - if (m_runnable.command.executable().isExecutableFile() && m_runnable.command.executable().path() != ".") { - return m_runnable.command.executable().absoluteFilePath(); - } else if (m_runnable.command.executable().path() == "."){ - QString fullCommandFileName = m_runnable.command.executable().toString(); - // TODO: check if we can use searchInPath() from Utils::Environment - const QStringList &pathList = m_runnable.environment.toProcessEnvironment().value("PATH") - .split(HostOsInfo::pathListSeparator()); - - for (const QString &path : pathList) { - QString filePath(path + QDir::separator() + fullCommandFileName); - if (QFileInfo(filePath).isExecutable()) - return m_runnable.command.executable().absoluteFilePath(); - } - } - return {}; + const Environment env = m_runnable.environment.size() == 0 ? Environment::systemEnvironment() + : m_runnable.environment; + return env.searchInPath(m_runnable.command.executable().path()); } Environment ITestConfiguration::filteredEnvironment(const Environment &original) const