forked from qt-creator/qt-creator
Squish: Correct handling of global scripts
Global scripts get registered to the server. If we have valid squish settings we are able to automatically re-open them. Change-Id: Iaeed2629dac30b786b6e8faf371bc6987a4a5681 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -444,6 +444,24 @@ void SquishFileHandler::addSharedFolder()
|
|||||||
emit testTreeItemCreated(item);
|
emit testTreeItemCreated(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SquishFileHandler::setSharedFolders(const Utils::FilePaths &folders)
|
||||||
|
{
|
||||||
|
emit clearedSharedFolders();
|
||||||
|
m_sharedFolders.clear();
|
||||||
|
|
||||||
|
for (const Utils::FilePath &folder : folders) {
|
||||||
|
if (m_sharedFolders.contains(folder))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
m_sharedFolders.append(folder);
|
||||||
|
SquishTestTreeItem *item = new SquishTestTreeItem(folder.toUserOutput(),
|
||||||
|
SquishTestTreeItem::SquishSharedFolder);
|
||||||
|
item->setFilePath(folder);
|
||||||
|
addAllEntriesRecursively(item);
|
||||||
|
emit testTreeItemCreated(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SquishFileHandler::removeSharedFolder(const Utils::FilePath &folder)
|
bool SquishFileHandler::removeSharedFolder(const Utils::FilePath &folder)
|
||||||
{
|
{
|
||||||
if (m_sharedFolders.contains(folder))
|
if (m_sharedFolders.contains(folder))
|
||||||
|
@@ -29,11 +29,13 @@ public:
|
|||||||
void runTestSuite(const QString &suiteName);
|
void runTestSuite(const QString &suiteName);
|
||||||
void recordTestCase(const QString &suiteName, const QString &testCaseName);
|
void recordTestCase(const QString &suiteName, const QString &testCaseName);
|
||||||
void addSharedFolder();
|
void addSharedFolder();
|
||||||
|
void setSharedFolders(const Utils::FilePaths &folders);
|
||||||
bool removeSharedFolder(const Utils::FilePath &folder);
|
bool removeSharedFolder(const Utils::FilePath &folder);
|
||||||
void removeAllSharedFolders();
|
void removeAllSharedFolders();
|
||||||
void openObjectsMap(const QString &suiteName);
|
void openObjectsMap(const QString &suiteName);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void clearedSharedFolders();
|
||||||
void testTreeItemCreated(SquishTestTreeItem *item);
|
void testTreeItemCreated(SquishTestTreeItem *item);
|
||||||
void suiteTreeItemRemoved(const QString &suiteName);
|
void suiteTreeItemRemoved(const QString &suiteName);
|
||||||
void suiteTreeItemModified(SquishTestTreeItem *item, const QString &displayName);
|
void suiteTreeItemModified(SquishTestTreeItem *item, const QString &displayName);
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
#include "squishplugin.h"
|
#include "squishplugin.h"
|
||||||
|
|
||||||
#include "objectsmapeditor.h"
|
#include "objectsmapeditor.h"
|
||||||
#include "squish/squishwizardpages.h"
|
#include "squishfilehandler.h"
|
||||||
#include "squishnavigationwidget.h"
|
#include "squishnavigationwidget.h"
|
||||||
#include "squishoutputpane.h"
|
#include "squishoutputpane.h"
|
||||||
#include "squishresultmodel.h"
|
#include "squishresultmodel.h"
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "squishtesttreemodel.h"
|
#include "squishtesttreemodel.h"
|
||||||
#include "squishtools.h"
|
#include "squishtools.h"
|
||||||
#include "squishtr.h"
|
#include "squishtr.h"
|
||||||
|
#include "squishwizardpages.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
@@ -21,6 +22,7 @@
|
|||||||
|
|
||||||
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/mimetypes/mimedatabase.h>
|
#include <utils/mimetypes/mimedatabase.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -39,6 +41,7 @@ public:
|
|||||||
~SquishPluginPrivate();
|
~SquishPluginPrivate();
|
||||||
|
|
||||||
void initializeMenuEntries();
|
void initializeMenuEntries();
|
||||||
|
bool initializeGlobalScripts();
|
||||||
|
|
||||||
SquishSettings m_squishSettings;
|
SquishSettings m_squishSettings;
|
||||||
SquishSettingsPage m_settingsPage{&m_squishSettings};
|
SquishSettingsPage m_settingsPage{&m_squishSettings};
|
||||||
@@ -102,6 +105,27 @@ void SquishPluginPrivate::initializeMenuEntries()
|
|||||||
toolsMenu->addMenu(menu);
|
toolsMenu->addMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SquishPluginPrivate::initializeGlobalScripts()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(dd->m_squishTools, return false);
|
||||||
|
|
||||||
|
const Utils::FilePath squishserver = dd->m_squishSettings.squishPath.filePath().pathAppended(
|
||||||
|
Utils::HostOsInfo::withExecutableSuffix("bin/squishserver"));
|
||||||
|
if (!squishserver.isExecutableFile())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
dd->m_squishTools->queryGlobalScripts([](const QString &output, const QString &error) {
|
||||||
|
if (output.isEmpty() || !error.isEmpty())
|
||||||
|
return; // ignore (for now?)
|
||||||
|
|
||||||
|
// FIXME? comma, special characters in paths
|
||||||
|
const Utils::FilePaths globalDirs = Utils::transform(
|
||||||
|
output.trimmed().split(',', Qt::SkipEmptyParts), &Utils::FilePath::fromString);
|
||||||
|
SquishFileHandler::instance()->setSharedFolders(globalDirs);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool SquishPlugin::initialize(const QStringList &, QString *)
|
bool SquishPlugin::initialize(const QStringList &, QString *)
|
||||||
{
|
{
|
||||||
dd = new SquishPluginPrivate;
|
dd = new SquishPluginPrivate;
|
||||||
@@ -109,6 +133,11 @@ bool SquishPlugin::initialize(const QStringList &, QString *)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SquishPlugin::delayedInitialize()
|
||||||
|
{
|
||||||
|
return dd->initializeGlobalScripts();
|
||||||
|
}
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag SquishPlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag SquishPlugin::aboutToShutdown()
|
||||||
{
|
{
|
||||||
if (dd->m_squishTools) {
|
if (dd->m_squishTools) {
|
||||||
|
@@ -23,6 +23,7 @@ public:
|
|||||||
static SquishSettings *squishSettings();
|
static SquishSettings *squishSettings();
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorString) override;
|
bool initialize(const QStringList &arguments, QString *errorString) override;
|
||||||
|
bool delayedInitialize() override;
|
||||||
ShutdownFlag aboutToShutdown() override;
|
ShutdownFlag aboutToShutdown() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -186,6 +186,9 @@ SquishTestTreeModel::SquishTestTreeModel(QObject *parent)
|
|||||||
&SquishFileHandler::suiteTreeItemRemoved,
|
&SquishFileHandler::suiteTreeItemRemoved,
|
||||||
this,
|
this,
|
||||||
&SquishTestTreeModel::onSuiteTreeItemRemoved);
|
&SquishTestTreeModel::onSuiteTreeItemRemoved);
|
||||||
|
connect(m_squishFileHandler,
|
||||||
|
&SquishFileHandler::clearedSharedFolders,
|
||||||
|
this, [this]() { m_squishSharedFolders->removeChildren(); });
|
||||||
|
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
}
|
}
|
||||||
|
@@ -260,11 +260,22 @@ void SquishTools::runTestCases(const FilePath &suitePath,
|
|||||||
startSquishServer(RunTestRequested);
|
startSquishServer(RunTestRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SquishTools::queryGlobalScripts(QueryCallback callback)
|
||||||
|
{
|
||||||
|
m_queryCallback = callback;
|
||||||
|
queryServer(GetGlobalScriptDirs);
|
||||||
|
}
|
||||||
|
|
||||||
void SquishTools::queryServerSettings(QueryCallback callback)
|
void SquishTools::queryServerSettings(QueryCallback callback)
|
||||||
|
{
|
||||||
|
m_queryCallback = callback;
|
||||||
|
queryServer(ServerInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SquishTools::queryServer(RunnerQuery query)
|
||||||
{
|
{
|
||||||
if (m_shutdownInitiated)
|
if (m_shutdownInitiated)
|
||||||
return;
|
return;
|
||||||
m_queryCallback = callback;
|
|
||||||
|
|
||||||
if (m_state != Idle) {
|
if (m_state != Idle) {
|
||||||
QMessageBox::critical(Core::ICore::dialogParent(),
|
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||||
@@ -276,6 +287,7 @@ void SquishTools::queryServerSettings(QueryCallback callback)
|
|||||||
}
|
}
|
||||||
m_perspective.setPerspectiveMode(SquishPerspective::Querying);
|
m_perspective.setPerspectiveMode(SquishPerspective::Querying);
|
||||||
m_fullRunnerOutput.clear();
|
m_fullRunnerOutput.clear();
|
||||||
|
m_query = query;
|
||||||
startSquishServer(RunnerQueryRequested);
|
startSquishServer(RunnerQueryRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,7 +675,18 @@ void SquishTools::executeRunnerQuery()
|
|||||||
if (!isValidToStartRunner() || !setupRunnerPath())
|
if (!isValidToStartRunner() || !setupRunnerPath())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setupAndStartSquishRunnerProcess({ "--port", QString::number(m_serverPort), "--info", "all"});
|
QStringList arguments = { "--port", QString::number(m_serverPort) };
|
||||||
|
switch (m_query) {
|
||||||
|
case ServerInfo:
|
||||||
|
arguments << "--info" << "all";
|
||||||
|
break;
|
||||||
|
case GetGlobalScriptDirs:
|
||||||
|
arguments << "--config" << "getGlobalScriptDirs";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
QTC_ASSERT(false, return);
|
||||||
|
}
|
||||||
|
setupAndStartSquishRunnerProcess(arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment SquishTools::squishEnvironment()
|
Environment SquishTools::squishEnvironment()
|
||||||
|
@@ -68,6 +68,7 @@ public:
|
|||||||
const QStringList &testCases = QStringList());
|
const QStringList &testCases = QStringList());
|
||||||
void recordTestCase(const Utils::FilePath &suitePath, const QString &testCaseName,
|
void recordTestCase(const Utils::FilePath &suitePath, const QString &testCaseName,
|
||||||
const SuiteConf &suiteConf);
|
const SuiteConf &suiteConf);
|
||||||
|
void queryGlobalScripts(QueryCallback callback);
|
||||||
void queryServerSettings(QueryCallback callback);
|
void queryServerSettings(QueryCallback callback);
|
||||||
void writeServerSettingsChanges(const QList<QStringList> &changes);
|
void writeServerSettingsChanges(const QList<QStringList> &changes);
|
||||||
void requestExpansion(const QString &name);
|
void requestExpansion(const QString &name);
|
||||||
@@ -98,6 +99,8 @@ private:
|
|||||||
KillOldBeforeQueryRunner
|
KillOldBeforeQueryRunner
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum RunnerQuery { ServerInfo, GetGlobalScriptDirs };
|
||||||
|
|
||||||
void setState(State state);
|
void setState(State state);
|
||||||
void handleSetStateStartAppRunner();
|
void handleSetStateStartAppRunner();
|
||||||
void handleSetStateQueryRunner();
|
void handleSetStateQueryRunner();
|
||||||
@@ -107,6 +110,7 @@ private:
|
|||||||
void startSquishRunner();
|
void startSquishRunner();
|
||||||
void setupAndStartRecorder();
|
void setupAndStartRecorder();
|
||||||
void stopRecorder();
|
void stopRecorder();
|
||||||
|
void queryServer(RunnerQuery query);
|
||||||
void executeRunnerQuery();
|
void executeRunnerQuery();
|
||||||
static Utils::Environment squishEnvironment();
|
static Utils::Environment squishEnvironment();
|
||||||
void onServerFinished();
|
void onServerFinished();
|
||||||
@@ -163,6 +167,7 @@ private:
|
|||||||
qint64 m_readResultsCount;
|
qint64 m_readResultsCount;
|
||||||
int m_autId = 0;
|
int m_autId = 0;
|
||||||
QueryCallback m_queryCallback;
|
QueryCallback m_queryCallback;
|
||||||
|
RunnerQuery m_query = ServerInfo;
|
||||||
bool m_shutdownInitiated = false;
|
bool m_shutdownInitiated = false;
|
||||||
bool m_closeRunnerOnEndRecord = false;
|
bool m_closeRunnerOnEndRecord = false;
|
||||||
bool m_licenseIssues = false;
|
bool m_licenseIssues = false;
|
||||||
|
Reference in New Issue
Block a user