ITestConfiguration: Introduce testExecutable() helper

Reuse it in TestRunner.

Change-Id: I59ffd256a7e84f0d0726261496d73bc4f622d666
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-01-16 23:41:47 +01:00
parent 040ef3b7d3
commit 49f3b8efd7
3 changed files with 18 additions and 36 deletions

View File

@@ -38,6 +38,7 @@ public:
Utils::FilePath workingDirectory() const;
bool hasExecutable() const;
Utils::FilePath executableFilePath() const;
virtual Utils::FilePath testExecutable() const { return executableFilePath(); };
virtual TestOutputReader *createOutputReader(const QFutureInterface<TestResult> &fi,
Utils::QtcProcess *app) const = 0;
@@ -124,6 +125,7 @@ public:
explicit TestToolConfiguration(ITestBase *testBase) : ITestConfiguration(testBase) {}
Utils::CommandLine commandLine() const { return m_commandLine; }
void setCommandLine(const Utils::CommandLine &cmdline) { m_commandLine = cmdline; }
virtual Utils::FilePath testExecutable() const override { return m_commandLine.executable(); };
private:
Utils::CommandLine m_commandLine;

View File

@@ -146,15 +146,10 @@ static QString constructOmittedVariablesDetailsString(const EnvironmentItems &di
bool TestRunner::currentConfigValid()
{
FilePath commandFilePath;
if (m_currentConfig->testBase()->type() == ITestBase::Framework) {
TestConfiguration *current = static_cast<TestConfiguration *>(m_currentConfig);
commandFilePath = current->executableFilePath();
} else {
TestToolConfiguration *current = static_cast<TestToolConfiguration *>(m_currentConfig);
commandFilePath = current->commandLine().executable();
}
if (commandFilePath.isEmpty()) {
const FilePath commandFilePath = m_currentConfig->testExecutable();
if (!commandFilePath.isEmpty())
return true;
reportResult(ResultType::MessageFatal,
Tr::tr("Executable path is empty. (%1)").arg(m_currentConfig->displayName()));
delete m_currentConfig;
@@ -167,21 +162,6 @@ bool TestRunner::currentConfigValid()
onProcessDone();
}
return false;
}
return true;
}
void TestRunner::setUpProcess()
{
QTC_ASSERT(m_currentConfig, return);
m_currentProcess = new QtcProcess;
if (m_currentConfig->testBase()->type() == ITestBase::Framework) {
TestConfiguration *current = static_cast<TestConfiguration *>(m_currentConfig);
m_currentProcess->setCommand({current->executableFilePath(), {}});
} else {
TestToolConfiguration *current = static_cast<TestToolConfiguration *>(m_currentConfig);
m_currentProcess->setCommand({current->commandLine().executable(), {}});
}
}
void TestRunner::setUpProcessEnv()
@@ -232,8 +212,9 @@ void TestRunner::scheduleNext()
if (!m_currentConfig->project())
onProcessDone();
setUpProcess();
QTC_ASSERT(m_currentProcess, onProcessDone(); return);
m_currentProcess = new QtcProcess;
m_currentProcess->setCommand({m_currentConfig->testExecutable(), {}});
QTC_ASSERT(!m_currentOutputReader, delete m_currentOutputReader);
m_currentOutputReader = m_currentConfig->createOutputReader(*m_fakeFutureInterface, m_currentProcess);
QTC_ASSERT(m_currentOutputReader, onProcessDone(); return);

View File

@@ -62,7 +62,6 @@ private:
int precheckTestConfigurations();
bool currentConfigValid();
void setUpProcess();
void setUpProcessEnv();
void scheduleNext();
void cancelCurrent(CancelReason reason);