diff --git a/src/plugins/autotest/testconfiguration.h b/src/plugins/autotest/testconfiguration.h index 501168977da..d57416d0164 100644 --- a/src/plugins/autotest/testconfiguration.h +++ b/src/plugins/autotest/testconfiguration.h @@ -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 &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; diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 128f5736c21..76138a8ea4b 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -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(m_currentConfig); - commandFilePath = current->executableFilePath(); - } else { - TestToolConfiguration *current = static_cast(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(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(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); diff --git a/src/plugins/autotest/testrunner.h b/src/plugins/autotest/testrunner.h index f18797805d5..c96af56075f 100644 --- a/src/plugins/autotest/testrunner.h +++ b/src/plugins/autotest/testrunner.h @@ -62,7 +62,6 @@ private: int precheckTestConfigurations(); bool currentConfigValid(); - void setUpProcess(); void setUpProcessEnv(); void scheduleNext(); void cancelCurrent(CancelReason reason);