forked from qt-creator/qt-creator
Squish: Move normal run over to new approach
Change-Id: I31301ea1d019169923e534281457b01a4b0a5cd5 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -138,7 +138,9 @@ SquishTools::SquishTools(QObject *parent)
|
|||||||
this, [this] {
|
this, [this] {
|
||||||
logRunnerStateChange(m_squishRunnerState, RunnerState::InterruptRequested);
|
logRunnerStateChange(m_squishRunnerState, RunnerState::InterruptRequested);
|
||||||
m_squishRunnerState = RunnerState::InterruptRequested;
|
m_squishRunnerState = RunnerState::InterruptRequested;
|
||||||
if (m_runnerProcess.processId() != -1)
|
if (m_request == RunTestRequested && m_primaryRunner && m_primaryRunner->processId() != -1)
|
||||||
|
interruptRunner();
|
||||||
|
else if (m_runnerProcess.processId() != -1)
|
||||||
interruptRunner();
|
interruptRunner();
|
||||||
});
|
});
|
||||||
connect(&m_perspective, &SquishPerspective::stopRequested, this, [this] {
|
connect(&m_perspective, &SquishPerspective::stopRequested, this, [this] {
|
||||||
@@ -149,7 +151,9 @@ SquishTools::SquishTools(QObject *parent)
|
|||||||
m_squishRunnerState = state;
|
m_squishRunnerState = state;
|
||||||
if (interrupted)
|
if (interrupted)
|
||||||
handlePrompt();
|
handlePrompt();
|
||||||
else if (m_runnerProcess.processId() != -1)
|
else if (m_request == RunTestRequested && m_primaryRunner && m_primaryRunner->processId() != -1)
|
||||||
|
terminateRunner();
|
||||||
|
else if (m_request == RecordTestRequested && m_runnerProcess.processId() != -1)
|
||||||
terminateRunner();
|
terminateRunner();
|
||||||
});
|
});
|
||||||
connect(&m_perspective, &SquishPerspective::stopRecordRequested,
|
connect(&m_perspective, &SquishPerspective::stopRecordRequested,
|
||||||
@@ -256,6 +260,7 @@ void SquishTools::runTestCases(const FilePath &suitePath,
|
|||||||
|
|
||||||
m_perspective.setPerspectiveMode(SquishPerspective::Running);
|
m_perspective.setPerspectiveMode(SquishPerspective::Running);
|
||||||
emit squishTestRunStarted();
|
emit squishTestRunStarted();
|
||||||
|
setupRunnerForRun();
|
||||||
startSquishServer(RunTestRequested);
|
startSquishServer(RunTestRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,8 +708,14 @@ void SquishTools::executeRunnerQuery()
|
|||||||
QTC_ASSERT(m_primaryRunner, return);
|
QTC_ASSERT(m_primaryRunner, return);
|
||||||
m_primaryRunner->setCommand(cmdLine);
|
m_primaryRunner->setCommand(cmdLine);
|
||||||
m_primaryRunner->setEnvironment(squishEnvironment());
|
m_primaryRunner->setEnvironment(squishEnvironment());
|
||||||
setState(RunnerStarting);
|
|
||||||
|
|
||||||
|
startPrimaryRunner();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SquishTools::startPrimaryRunner()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_primaryRunner, return);
|
||||||
|
setState(RunnerStarting);
|
||||||
qCDebug(LOG) << "Runner starts:" << m_primaryRunner->commandLine().toUserOutput();
|
qCDebug(LOG) << "Runner starts:" << m_primaryRunner->commandLine().toUserOutput();
|
||||||
m_primaryRunner->start();
|
m_primaryRunner->start();
|
||||||
if (!m_primaryRunner->waitForStarted()) {
|
if (!m_primaryRunner->waitForStarted()) {
|
||||||
@@ -969,6 +980,7 @@ void SquishTools::onRunnerStdOutput(const QString &lineIn)
|
|||||||
// FIXME: enabled state of breakpoints
|
// FIXME: enabled state of breakpoints
|
||||||
Utils::Links SquishTools::setBreakpoints()
|
Utils::Links SquishTools::setBreakpoints()
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(m_primaryRunner, return {});
|
||||||
Utils::Links setBPs;
|
Utils::Links setBPs;
|
||||||
using namespace Debugger::Internal;
|
using namespace Debugger::Internal;
|
||||||
const GlobalBreakpoints globalBPs = BreakpointManager::globalBreakpoints();
|
const GlobalBreakpoints globalBPs = BreakpointManager::globalBreakpoints();
|
||||||
@@ -994,7 +1006,7 @@ Utils::Links SquishTools::setBreakpoints()
|
|||||||
cmd.append(QString::number(line));
|
cmd.append(QString::number(line));
|
||||||
cmd.append('\n');
|
cmd.append('\n');
|
||||||
qCInfo(LOG).noquote().nospace() << "Setting breakpoint: '" << cmd << "'";
|
qCInfo(LOG).noquote().nospace() << "Setting breakpoint: '" << cmd << "'";
|
||||||
m_runnerProcess.write(cmd);
|
m_primaryRunner->write(cmd);
|
||||||
setBPs.append({filePath, line});
|
setBPs.append({filePath, line});
|
||||||
}
|
}
|
||||||
return setBPs;
|
return setBPs;
|
||||||
@@ -1023,6 +1035,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTC_ASSERT(m_primaryRunner, return);
|
||||||
switch (m_squishRunnerState) {
|
switch (m_squishRunnerState) {
|
||||||
case RunnerState::Starting: {
|
case RunnerState::Starting: {
|
||||||
const Utils::Links setBPs = setBreakpoints();
|
const Utils::Links setBPs = setBreakpoints();
|
||||||
@@ -1034,7 +1047,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
m_squishRunnerState = RunnerState::Interrupted;
|
m_squishRunnerState = RunnerState::Interrupted;
|
||||||
restoreQtCreatorWindows();
|
restoreQtCreatorWindows();
|
||||||
// request local variables
|
// request local variables
|
||||||
m_runnerProcess.write("print variables\n");
|
m_primaryRunner->write("print variables\n");
|
||||||
const FilePath filePath = FilePath::fromString(fileName);
|
const FilePath filePath = FilePath::fromString(fileName);
|
||||||
Core::EditorManager::openEditorAt({filePath, line, column});
|
Core::EditorManager::openEditorAt({filePath, line, column});
|
||||||
updateLocationMarker(filePath, line);
|
updateLocationMarker(filePath, line);
|
||||||
@@ -1043,13 +1056,13 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
}
|
}
|
||||||
case RunnerState::CancelRequested:
|
case RunnerState::CancelRequested:
|
||||||
case RunnerState::CancelRequestedWhileInterrupted:
|
case RunnerState::CancelRequestedWhileInterrupted:
|
||||||
m_runnerProcess.write("exit\n");
|
m_primaryRunner->write("exit\n");
|
||||||
clearLocationMarker();
|
clearLocationMarker();
|
||||||
logRunnerStateChange(m_squishRunnerState, RunnerState::Canceling);
|
logRunnerStateChange(m_squishRunnerState, RunnerState::Canceling);
|
||||||
m_squishRunnerState = RunnerState::Canceling;
|
m_squishRunnerState = RunnerState::Canceling;
|
||||||
break;
|
break;
|
||||||
case RunnerState::Canceling:
|
case RunnerState::Canceling:
|
||||||
m_runnerProcess.write("quit\n");
|
m_primaryRunner->write("quit\n");
|
||||||
logRunnerStateChange(m_squishRunnerState, RunnerState::Canceled);
|
logRunnerStateChange(m_squishRunnerState, RunnerState::Canceled);
|
||||||
m_squishRunnerState = RunnerState::Canceled;
|
m_squishRunnerState = RunnerState::Canceled;
|
||||||
break;
|
break;
|
||||||
@@ -1064,10 +1077,10 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
restoreQtCreatorWindows();
|
restoreQtCreatorWindows();
|
||||||
// if we're returning from a function we might end up without a file information
|
// if we're returning from a function we might end up without a file information
|
||||||
if (fileName.isEmpty()) {
|
if (fileName.isEmpty()) {
|
||||||
m_runnerProcess.write("next\n");
|
m_primaryRunner->write("next\n");
|
||||||
} else {
|
} else {
|
||||||
// request local variables
|
// request local variables
|
||||||
m_runnerProcess.write("print variables\n");
|
m_primaryRunner->write("print variables\n");
|
||||||
const FilePath filePath = FilePath::fromString(fileName);
|
const FilePath filePath = FilePath::fromString(fileName);
|
||||||
Core::EditorManager::openEditorAt({filePath, line, column});
|
Core::EditorManager::openEditorAt({filePath, line, column});
|
||||||
updateLocationMarker(filePath, line);
|
updateLocationMarker(filePath, line);
|
||||||
@@ -1080,7 +1093,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
m_requestVarsTimer->setSingleShot(true);
|
m_requestVarsTimer->setSingleShot(true);
|
||||||
m_requestVarsTimer->setInterval(1000);
|
m_requestVarsTimer->setInterval(1000);
|
||||||
connect(m_requestVarsTimer, &QTimer::timeout, this, [this] {
|
connect(m_requestVarsTimer, &QTimer::timeout, this, [this] {
|
||||||
m_runnerProcess.write("print variables\n");
|
m_primaryRunner->write("print variables\n");
|
||||||
});
|
});
|
||||||
m_requestVarsTimer->start();
|
m_requestVarsTimer->start();
|
||||||
}
|
}
|
||||||
@@ -1090,19 +1103,24 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
|
|
||||||
void SquishTools::requestExpansion(const QString &name)
|
void SquishTools::requestExpansion(const QString &name)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(m_primaryRunner, return);
|
||||||
QTC_ASSERT(m_squishRunnerState == RunnerState::Interrupted, return);
|
QTC_ASSERT(m_squishRunnerState == RunnerState::Interrupted, return);
|
||||||
m_runnerProcess.write("print variables +" + name + "\n");
|
QtcProcess *process = m_request == RunTestRequested ? m_primaryRunner
|
||||||
|
: &m_runnerProcess;
|
||||||
|
process->write("print variables +" + name + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SquishTools::shutdown()
|
bool SquishTools::shutdown()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!m_shutdownInitiated, return true);
|
QTC_ASSERT(!m_shutdownInitiated, return true);
|
||||||
m_shutdownInitiated = true;
|
m_shutdownInitiated = true;
|
||||||
|
if (m_primaryRunner && m_primaryRunner->isRunning())
|
||||||
|
terminateRunner();
|
||||||
if (m_runnerProcess.isRunning())
|
if (m_runnerProcess.isRunning())
|
||||||
terminateRunner();
|
terminateRunner();
|
||||||
if (m_serverProcess.isRunning())
|
if (m_serverProcess.isRunning())
|
||||||
m_serverProcess.stop();
|
m_serverProcess.stop();
|
||||||
return !(m_serverProcess.isRunning() || m_runnerProcess.isRunning());
|
return !(m_serverProcess.isRunning() || m_runnerProcess.isRunning() || (m_primaryRunner && m_primaryRunner->isRunning()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishTools::onResultsDirChanged(const QString &filePath)
|
void SquishTools::onResultsDirChanged(const QString &filePath)
|
||||||
@@ -1200,14 +1218,17 @@ void SquishTools::onRunnerRunRequested(StepMode step)
|
|||||||
logRunnerStateChange(m_squishRunnerState, RunnerState::RunRequested);
|
logRunnerStateChange(m_squishRunnerState, RunnerState::RunRequested);
|
||||||
m_squishRunnerState = RunnerState::RunRequested;
|
m_squishRunnerState = RunnerState::RunRequested;
|
||||||
|
|
||||||
|
QtcProcess *process = m_request == RunTestRequested ? m_primaryRunner
|
||||||
|
: &m_runnerProcess;
|
||||||
|
QTC_ASSERT(process, return);
|
||||||
if (step == StepMode::Continue)
|
if (step == StepMode::Continue)
|
||||||
m_runnerProcess.write("continue\n");
|
process->write("continue\n");
|
||||||
else if (step == StepMode::StepIn)
|
else if (step == StepMode::StepIn)
|
||||||
m_runnerProcess.write("step\n");
|
process->write("step\n");
|
||||||
else if (step == StepMode::StepOver)
|
else if (step == StepMode::StepOver)
|
||||||
m_runnerProcess.write("next\n");
|
process->write("next\n");
|
||||||
else if (step == StepMode::StepOut)
|
else if (step == StepMode::StepOut)
|
||||||
m_runnerProcess.write("return\n");
|
process->write("return\n");
|
||||||
|
|
||||||
clearLocationMarker();
|
clearLocationMarker();
|
||||||
if (toolsSettings.minimizeIDE)
|
if (toolsSettings.minimizeIDE)
|
||||||
@@ -1223,8 +1244,9 @@ void SquishTools::onRunnerRunRequested(StepMode step)
|
|||||||
void SquishTools::interruptRunner()
|
void SquishTools::interruptRunner()
|
||||||
{
|
{
|
||||||
qCDebug(LOG) << "Interrupting runner";
|
qCDebug(LOG) << "Interrupting runner";
|
||||||
const CommandLine cmd(toolsSettings.processComPath,
|
qint64 processId = (m_request == RunTestRequested && m_primaryRunner)
|
||||||
{QString::number(m_runnerProcess.processId()), "break"});
|
? m_primaryRunner->processId() : m_runnerProcess.processId();
|
||||||
|
const CommandLine cmd(toolsSettings.processComPath, {QString::number(processId), "break"});
|
||||||
QtcProcess process;
|
QtcProcess process;
|
||||||
process.setCommand(cmd);
|
process.setCommand(cmd);
|
||||||
process.start();
|
process.start();
|
||||||
@@ -1238,8 +1260,9 @@ void SquishTools::terminateRunner()
|
|||||||
m_currentTestCasePath.clear();
|
m_currentTestCasePath.clear();
|
||||||
m_perspective.updateStatus(Tr::tr("User stop initiated."));
|
m_perspective.updateStatus(Tr::tr("User stop initiated."));
|
||||||
// should we terminate the AUT instead of the runner?!?
|
// should we terminate the AUT instead of the runner?!?
|
||||||
const CommandLine cmd(toolsSettings.processComPath,
|
qint64 processId = m_request == RunTestRequested ? m_primaryRunner->processId()
|
||||||
{QString::number(m_runnerProcess.processId()), "terminate"});
|
: m_runnerProcess.processId();
|
||||||
|
const CommandLine cmd(toolsSettings.processComPath, {QString::number(processId), "terminate"});
|
||||||
QtcProcess process;
|
QtcProcess process;
|
||||||
process.setCommand(cmd);
|
process.setCommand(cmd);
|
||||||
process.start();
|
process.start();
|
||||||
@@ -1398,9 +1421,17 @@ bool SquishTools::setupRunnerPath()
|
|||||||
|
|
||||||
void SquishTools::setupAndStartSquishRunnerProcess(const Utils::CommandLine &cmdLine)
|
void SquishTools::setupAndStartSquishRunnerProcess(const Utils::CommandLine &cmdLine)
|
||||||
{
|
{
|
||||||
m_runnerProcess.setCommand(cmdLine);
|
if (m_request == RecordTestRequested) {
|
||||||
m_runnerProcess.setEnvironment(squishEnvironment());
|
m_runnerProcess.close();
|
||||||
setState(RunnerStarting);
|
m_runnerProcess.setCommand(cmdLine);
|
||||||
|
m_runnerProcess.setEnvironment(squishEnvironment());
|
||||||
|
} else {
|
||||||
|
QTC_ASSERT(m_primaryRunner, return);
|
||||||
|
// avoid crashes on fast re-usage of QtcProcess
|
||||||
|
m_primaryRunner->close();
|
||||||
|
m_primaryRunner->setCommand(cmdLine);
|
||||||
|
m_primaryRunner->setEnvironment(squishEnvironment());
|
||||||
|
}
|
||||||
|
|
||||||
if (m_request == RunTestRequested) {
|
if (m_request == RunTestRequested) {
|
||||||
// set up the file system watcher for being able to read the results.xml file
|
// set up the file system watcher for being able to read the results.xml file
|
||||||
@@ -1417,9 +1448,11 @@ void SquishTools::setupAndStartSquishRunnerProcess(const Utils::CommandLine &cmd
|
|||||||
&SquishTools::onResultsDirChanged);
|
&SquishTools::onResultsDirChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
// especially when running multiple test cases we re-use the process fast and start the runner
|
if (m_request == RunTestRequested) {
|
||||||
// several times and may crash as the process may not have been cleanly destructed yet
|
startPrimaryRunner();
|
||||||
m_runnerProcess.close();
|
return;
|
||||||
|
}
|
||||||
|
setState(RunnerStarting);
|
||||||
qCDebug(LOG) << "Runner starts:" << m_runnerProcess.commandLine().toUserOutput();
|
qCDebug(LOG) << "Runner starts:" << m_runnerProcess.commandLine().toUserOutput();
|
||||||
m_runnerProcess.start();
|
m_runnerProcess.start();
|
||||||
if (!m_runnerProcess.waitForStarted()) {
|
if (!m_runnerProcess.waitForStarted()) {
|
||||||
@@ -1447,5 +1480,21 @@ void SquishTools::setupRunnerForQuery()
|
|||||||
this, &SquishTools::handleQueryDone);
|
this, &SquishTools::handleQueryDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SquishTools::setupRunnerForRun()
|
||||||
|
{
|
||||||
|
if (m_primaryRunner) {
|
||||||
|
m_primaryRunner->close();
|
||||||
|
delete m_primaryRunner;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_primaryRunner = new QtcProcess(this);
|
||||||
|
m_primaryRunner->setProcessMode(ProcessMode::Writer);
|
||||||
|
m_primaryRunner->setStdOutLineCallback([this](const QString &line){ onRunnerStdOutput(line); });
|
||||||
|
connect(m_primaryRunner, &QtcProcess::readyReadStandardError,
|
||||||
|
this, &SquishTools::onRunnerErrorOutput);
|
||||||
|
connect(m_primaryRunner, &QtcProcess::done,
|
||||||
|
this, &SquishTools::onRunnerFinished);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Squish
|
} // namespace Squish
|
||||||
|
@@ -126,6 +126,8 @@ private:
|
|||||||
bool setupRunnerPath();
|
bool setupRunnerPath();
|
||||||
void setupAndStartSquishRunnerProcess(const Utils::CommandLine &cmdLine);
|
void setupAndStartSquishRunnerProcess(const Utils::CommandLine &cmdLine);
|
||||||
void setupRunnerForQuery();
|
void setupRunnerForQuery();
|
||||||
|
void setupRunnerForRun();
|
||||||
|
void startPrimaryRunner();
|
||||||
|
|
||||||
SquishPerspective m_perspective;
|
SquishPerspective m_perspective;
|
||||||
std::unique_ptr<SquishXmlOutputHandler> m_xmlOutputHandler;
|
std::unique_ptr<SquishXmlOutputHandler> m_xmlOutputHandler;
|
||||||
|
Reference in New Issue
Block a user