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

@@ -146,42 +146,22 @@ 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()) {
reportResult(ResultType::MessageFatal,
Tr::tr("Executable path is empty. (%1)").arg(m_currentConfig->displayName()));
delete m_currentConfig;
m_currentConfig = nullptr;
if (m_selectedTests.isEmpty()) {
if (m_fakeFutureInterface)
m_fakeFutureInterface->reportFinished();
onFinished();
} else {
onProcessDone();
}
return false;
}
return true;
}
const FilePath commandFilePath = m_currentConfig->testExecutable();
if (!commandFilePath.isEmpty())
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(), {}});
reportResult(ResultType::MessageFatal,
Tr::tr("Executable path is empty. (%1)").arg(m_currentConfig->displayName()));
delete m_currentConfig;
m_currentConfig = nullptr;
if (m_selectedTests.isEmpty()) {
if (m_fakeFutureInterface)
m_fakeFutureInterface->reportFinished();
onFinished();
} else {
TestToolConfiguration *current = static_cast<TestToolConfiguration *>(m_currentConfig);
m_currentProcess->setCommand({current->commandLine().executable(), {}});
onProcessDone();
}
return false;
}
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);