forked from qt-creator/qt-creator
Squish: Write server config changes
Change-Id: I74242e88b9a7ba7b2c6f815efc1dd4e8cdca9df1 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -29,6 +29,8 @@
|
|||||||
#include "squishtools.h"
|
#include "squishtools.h"
|
||||||
#include "squishtr.h"
|
#include "squishtr.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/basetreeview.h>
|
#include <utils/basetreeview.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
@@ -40,6 +42,7 @@
|
|||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@@ -335,6 +338,7 @@ class SquishServerSettingsWidget : public QWidget
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit SquishServerSettingsWidget(QWidget *parent = nullptr);
|
explicit SquishServerSettingsWidget(QWidget *parent = nullptr);
|
||||||
|
QList<QStringList> toConfigChangeArguments() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void repopulateApplicationView();
|
void repopulateApplicationView();
|
||||||
@@ -344,6 +348,8 @@ private:
|
|||||||
void addAttachableAut(TreeItem *categoryItem, SquishServerItem *original);
|
void addAttachableAut(TreeItem *categoryItem, SquishServerItem *original);
|
||||||
void editApplicationOrPath();
|
void editApplicationOrPath();
|
||||||
void removeApplicationOrPath();
|
void removeApplicationOrPath();
|
||||||
|
|
||||||
|
SquishServerSettings m_originalSettings;
|
||||||
SquishServerSettings m_serverSettings;
|
SquishServerSettings m_serverSettings;
|
||||||
BaseTreeView m_applicationsView;
|
BaseTreeView m_applicationsView;
|
||||||
TreeModel<SquishServerItem> m_model;
|
TreeModel<SquishServerItem> m_model;
|
||||||
@@ -414,6 +420,7 @@ SquishServerSettingsWidget::SquishServerSettingsWidget(QWidget *parent)
|
|||||||
connect(squishTools, &SquishTools::queryFinished, this,
|
connect(squishTools, &SquishTools::queryFinished, this,
|
||||||
[this, progress] (const QByteArray &out) {
|
[this, progress] (const QByteArray &out) {
|
||||||
m_serverSettings.setFromXmlOutput(out);
|
m_serverSettings.setFromXmlOutput(out);
|
||||||
|
m_originalSettings.setFromXmlOutput(out);
|
||||||
repopulateApplicationView();
|
repopulateApplicationView();
|
||||||
progress->hide();
|
progress->hide();
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
@@ -576,6 +583,61 @@ void SquishServerSettingsWidget::removeApplicationOrPath()
|
|||||||
m_model.destroyItem(item);
|
m_model.destroyItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QStringList> SquishServerSettingsWidget::toConfigChangeArguments() const
|
||||||
|
{
|
||||||
|
QList<QStringList> result;
|
||||||
|
for (auto it = m_originalSettings.mappedAuts.begin(),
|
||||||
|
end = m_originalSettings.mappedAuts.end(); it != end; ++it) {
|
||||||
|
const QString value = m_serverSettings.mappedAuts.value(it.key());
|
||||||
|
if (value == it.value())
|
||||||
|
continue;
|
||||||
|
if (value.isEmpty())
|
||||||
|
result.append({"removeAUT", it.key(), it.value()});
|
||||||
|
else
|
||||||
|
result.append({"addAUT", it.key(), value});
|
||||||
|
}
|
||||||
|
for (auto it = m_serverSettings.mappedAuts.begin(),
|
||||||
|
end = m_serverSettings.mappedAuts.end(); it != end; ++it) {
|
||||||
|
if (!m_originalSettings.mappedAuts.contains(it.key()))
|
||||||
|
result.append({"addAUT", it.key(), it.value()});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto it = m_originalSettings.attachableAuts.begin(),
|
||||||
|
end = m_originalSettings.attachableAuts.end(); it != end; ++it) {
|
||||||
|
const QString value = m_serverSettings.attachableAuts.value(it.key());
|
||||||
|
if (value == it.value())
|
||||||
|
continue;
|
||||||
|
if (value.isEmpty())
|
||||||
|
result.append({"removeAttachableAUT", it.key(), it.value()});
|
||||||
|
else
|
||||||
|
result.append({"addAttachableAUT", it.key(), value});
|
||||||
|
}
|
||||||
|
for (auto it = m_serverSettings.attachableAuts.begin(),
|
||||||
|
end = m_serverSettings.attachableAuts.end(); it != end; ++it) {
|
||||||
|
if (!m_originalSettings.attachableAuts.contains(it.key()))
|
||||||
|
result.append({"addAttachableAUT", it.key(), it.value()});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &path : qAsConst(m_originalSettings.autPaths)) {
|
||||||
|
if (!m_serverSettings.autPaths.contains(path))
|
||||||
|
result.append({"removeAppPath", path});
|
||||||
|
}
|
||||||
|
for (auto &path : qAsConst(m_serverSettings.autPaths)) {
|
||||||
|
if (!m_originalSettings.autPaths.contains(path))
|
||||||
|
result.append({"addAppPath", path});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_originalSettings.autTimeout.value() != m_serverSettings.autTimeout.value())
|
||||||
|
result.append({"setAUTTimeout", QString::number(m_serverSettings.autTimeout.value())});
|
||||||
|
if (m_originalSettings.responseTimeout.value() != m_serverSettings.responseTimeout.value())
|
||||||
|
result.append({"setResponseTimeout", QString::number(m_serverSettings.responseTimeout.value())});
|
||||||
|
if (m_originalSettings.postMortemWaitTime.value() != m_serverSettings.postMortemWaitTime.value())
|
||||||
|
result.append({"setAUTPostMortemTimeout", QString::number(m_serverSettings.postMortemWaitTime.value())});
|
||||||
|
if (m_originalSettings.animatedCursor.value() != m_serverSettings.animatedCursor.value())
|
||||||
|
result.append({"setCursorAnimation", m_serverSettings.animatedCursor.value() ? QString("on") : QString("off")});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void SquishServerSettingsWidget::editApplicationOrPath()
|
void SquishServerSettingsWidget::editApplicationOrPath()
|
||||||
{
|
{
|
||||||
const QModelIndex &idx = m_applicationsView.currentIndex();
|
const QModelIndex &idx = m_applicationsView.currentIndex();
|
||||||
@@ -603,21 +665,37 @@ SquishServerSettingsDialog::SquishServerSettingsDialog(QWidget *parent)
|
|||||||
{
|
{
|
||||||
setWindowTitle(Tr::tr("Squish Server Settings"));
|
setWindowTitle(Tr::tr("Squish Server Settings"));
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||||
mainLayout->addWidget(new SquishServerSettingsWidget);
|
auto settingsWidget = new SquishServerSettingsWidget(this);
|
||||||
auto buttonBox = new QDialogButtonBox(/*QDialogButtonBox::Apply|*/QDialogButtonBox::Cancel, this);
|
mainLayout->addWidget(settingsWidget);
|
||||||
|
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
|
||||||
mainLayout->addWidget(buttonBox);
|
mainLayout->addWidget(buttonBox);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
// connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
|
||||||
// this, &SquishServerSettingsDialog::onApply);
|
this, [this, settingsWidget, buttonBox] {
|
||||||
|
const QList<QStringList> configChanges = settingsWidget->toConfigChangeArguments();
|
||||||
|
if (configChanges.isEmpty()) {
|
||||||
|
accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(SquishTools::instance(), &SquishTools::configChangesFailed,
|
||||||
|
this, &SquishServerSettingsDialog::configWriteFailed);
|
||||||
|
connect(SquishTools::instance(), &SquishTools::configChangesWritten,
|
||||||
|
this, &QDialog::accept);
|
||||||
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
|
SquishTools::instance()->writeServerSettingsChanges(configChanges);
|
||||||
|
});
|
||||||
connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||||
this, &QDialog::reject);
|
this, &QDialog::reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishServerSettingsDialog::onApply()
|
void SquishServerSettingsDialog::configWriteFailed(QProcess::ProcessError error)
|
||||||
{
|
{
|
||||||
// TODO write settings to server
|
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||||
accept();
|
Tr::tr("Error"),
|
||||||
|
Tr::tr("Failed to write configuration changes.\n"
|
||||||
|
"Squish server finished with process error %1.").arg(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
@@ -63,7 +64,7 @@ public:
|
|||||||
explicit SquishServerSettingsDialog(QWidget *parent = nullptr);
|
explicit SquishServerSettingsDialog(QWidget *parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onApply();
|
void configWriteFailed(QProcess::ProcessError error);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -184,6 +184,20 @@ void SquishTools::queryServerSettings()
|
|||||||
startSquishServer(RunnerQueryRequested);
|
startSquishServer(RunnerQueryRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SquishTools::writeServerSettingsChanges(const QList<QStringList> &changes)
|
||||||
|
{
|
||||||
|
if (m_state != Idle) {
|
||||||
|
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||||
|
Tr::tr("Error"),
|
||||||
|
Tr::tr("Squish Tools in unexpected state (%1).\n"
|
||||||
|
"Refusing to write configuration changes.").arg(m_state));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_serverConfigChanges = changes;
|
||||||
|
startSquishServer(ServerConfigChangeRequested);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SquishTools::setState(SquishTools::State state)
|
void SquishTools::setState(SquishTools::State state)
|
||||||
{
|
{
|
||||||
// TODO check whether state transition is legal
|
// TODO check whether state transition is legal
|
||||||
@@ -207,6 +221,7 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
} else if (m_request == RecordTestRequested) {
|
} else if (m_request == RecordTestRequested) {
|
||||||
} else if (m_request == RunnerQueryRequested) {
|
} else if (m_request == RunnerQueryRequested) {
|
||||||
executeRunnerQuery();
|
executeRunnerQuery();
|
||||||
|
} else if (m_request == ServerConfigChangeRequested) { // nothing to do here
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(false, qDebug() << m_state << m_request);
|
QTC_ASSERT(false, qDebug() << m_state << m_request);
|
||||||
}
|
}
|
||||||
@@ -222,7 +237,18 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
break;
|
break;
|
||||||
case ServerStopped:
|
case ServerStopped:
|
||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
if (m_request == ServerStopRequested) {
|
if (m_request == ServerConfigChangeRequested) {
|
||||||
|
if (m_serverProcess.result() == ProcessResult::FinishedWithError) {
|
||||||
|
emit configChangesFailed(m_serverProcess.error());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_serverConfigChanges.removeFirst();
|
||||||
|
if (!m_serverConfigChanges.isEmpty())
|
||||||
|
startSquishServer(ServerConfigChangeRequested);
|
||||||
|
else
|
||||||
|
emit configChangesWritten();
|
||||||
|
} else if (m_request == ServerStopRequested) {
|
||||||
m_request = None;
|
m_request = None;
|
||||||
if (m_squishRunnerMode == TestingMode) {
|
if (m_squishRunnerMode == TestingMode) {
|
||||||
emit squishTestRunFinished();
|
emit squishTestRunFinished();
|
||||||
@@ -331,13 +357,20 @@ void SquishTools::startSquishServer(Request request)
|
|||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
// TODO if isLocalServer is false we should start a squishserver on remote device
|
// TODO if isLocalServer is false we should start a squishserver on remote device
|
||||||
if (toolsSettings.isLocalServer)
|
if (toolsSettings.isLocalServer) {
|
||||||
|
if (m_request != ServerConfigChangeRequested)
|
||||||
arguments << "--local"; // for now - although Squish Docs say "don't use it"
|
arguments << "--local"; // for now - although Squish Docs say "don't use it"
|
||||||
else
|
} else {
|
||||||
arguments << "--port" << QString::number(toolsSettings.serverPort);
|
arguments << "--port" << QString::number(toolsSettings.serverPort);
|
||||||
|
}
|
||||||
if (toolsSettings.verboseLog)
|
if (toolsSettings.verboseLog)
|
||||||
arguments << "--verbose";
|
arguments << "--verbose";
|
||||||
|
|
||||||
|
if (m_request == ServerConfigChangeRequested && QTC_GUARD(!m_serverConfigChanges.isEmpty())) {
|
||||||
|
arguments.append("--config");
|
||||||
|
arguments.append(m_serverConfigChanges.first());
|
||||||
|
}
|
||||||
|
|
||||||
m_serverProcess.setCommand({toolsSettings.serverPath, arguments});
|
m_serverProcess.setCommand({toolsSettings.serverPath, arguments});
|
||||||
m_serverProcess.setEnvironment(squishEnvironment());
|
m_serverProcess.setEnvironment(squishEnvironment());
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public:
|
|||||||
const QStringList &additionalServerArgs = QStringList(),
|
const QStringList &additionalServerArgs = QStringList(),
|
||||||
const QStringList &additionalRunnerArgs = QStringList());
|
const QStringList &additionalRunnerArgs = QStringList());
|
||||||
void queryServerSettings();
|
void queryServerSettings();
|
||||||
|
void writeServerSettingsChanges(const QList<QStringList> &changes);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void logOutputReceived(const QString &output);
|
void logOutputReceived(const QString &output);
|
||||||
@@ -79,12 +80,14 @@ signals:
|
|||||||
void squishTestRunFinished();
|
void squishTestRunFinished();
|
||||||
void resultOutputCreated(const QByteArray &output);
|
void resultOutputCreated(const QByteArray &output);
|
||||||
void queryFinished(const QByteArray &output);
|
void queryFinished(const QByteArray &output);
|
||||||
|
void configChangesFailed(QProcess::ProcessError error);
|
||||||
|
void configChangesWritten();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Request {
|
enum Request {
|
||||||
None,
|
None,
|
||||||
ServerStopRequested,
|
ServerStopRequested,
|
||||||
ServerQueryRequested,
|
ServerConfigChangeRequested,
|
||||||
RunnerQueryRequested,
|
RunnerQueryRequested,
|
||||||
RunTestRequested,
|
RunTestRequested,
|
||||||
RecordTestRequested,
|
RecordTestRequested,
|
||||||
@@ -129,6 +132,7 @@ private:
|
|||||||
QFileSystemWatcher *m_resultsFileWatcher = nullptr;
|
QFileSystemWatcher *m_resultsFileWatcher = nullptr;
|
||||||
QStringList m_additionalServerArguments;
|
QStringList m_additionalServerArguments;
|
||||||
QStringList m_additionalRunnerArguments;
|
QStringList m_additionalRunnerArguments;
|
||||||
|
QList<QStringList> m_serverConfigChanges;
|
||||||
QWindowList m_lastTopLevelWindows;
|
QWindowList m_lastTopLevelWindows;
|
||||||
enum RunnerMode { NoMode, TestingMode, QueryMode} m_squishRunnerMode = NoMode;
|
enum RunnerMode { NoMode, TestingMode, QueryMode} m_squishRunnerMode = NoMode;
|
||||||
qint64 m_readResultsCount;
|
qint64 m_readResultsCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user