forked from qt-creator/qt-creator
Squish: Prepare handling of server settings
Change-Id: I3495eb82eb6c02901d4a05d40516c6088f9374dd Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -54,6 +54,8 @@ namespace Internal {
|
|||||||
static const QString resultsDirectory = QFileInfo(QDir::home(), ".squishQC/Test Results")
|
static const QString resultsDirectory = QFileInfo(QDir::home(), ".squishQC/Test Results")
|
||||||
.absoluteFilePath();
|
.absoluteFilePath();
|
||||||
|
|
||||||
|
static SquishTools *s_instance = nullptr;
|
||||||
|
|
||||||
SquishTools::SquishTools(QObject *parent)
|
SquishTools::SquishTools(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@@ -76,10 +78,17 @@ SquishTools::SquishTools(QObject *parent)
|
|||||||
this, &SquishTools::onServerErrorOutput);
|
this, &SquishTools::onServerErrorOutput);
|
||||||
connect(&m_serverProcess, &QtcProcess::done,
|
connect(&m_serverProcess, &QtcProcess::done,
|
||||||
this, &SquishTools::onServerFinished);
|
this, &SquishTools::onServerFinished);
|
||||||
|
s_instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SquishTools::~SquishTools() = default;
|
SquishTools::~SquishTools() = default;
|
||||||
|
|
||||||
|
SquishTools *SquishTools::instance()
|
||||||
|
{
|
||||||
|
QTC_CHECK(s_instance);
|
||||||
|
return s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
struct SquishToolsSettings
|
struct SquishToolsSettings
|
||||||
{
|
{
|
||||||
SquishToolsSettings() {}
|
SquishToolsSettings() {}
|
||||||
@@ -153,11 +162,25 @@ void SquishTools::runTestCases(const QString &suitePath,
|
|||||||
m_xmlOutputHandler.get(), &SquishXmlOutputHandler::outputAvailable,
|
m_xmlOutputHandler.get(), &SquishXmlOutputHandler::outputAvailable,
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
m_testRunning = true;
|
m_squishRunnerMode = TestingMode;
|
||||||
emit squishTestRunStarted();
|
emit squishTestRunStarted();
|
||||||
startSquishServer(RunTestRequested);
|
startSquishServer(RunTestRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SquishTools::queryServerSettings()
|
||||||
|
{
|
||||||
|
if (m_state != Idle) {
|
||||||
|
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||||
|
tr("Error"),
|
||||||
|
tr("Squish Tools in unexpected state (%1).\n"
|
||||||
|
"Refusing to run a test case.")
|
||||||
|
.arg(m_state));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_squishRunnerMode = QueryMode;
|
||||||
|
startSquishServer(RunnerQueryRequested);
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -171,7 +194,7 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
m_reportFiles.clear();
|
m_reportFiles.clear();
|
||||||
m_additionalRunnerArguments.clear();
|
m_additionalRunnerArguments.clear();
|
||||||
m_additionalServerArguments.clear();
|
m_additionalServerArguments.clear();
|
||||||
m_testRunning = false;
|
m_squishRunnerMode = NoMode;
|
||||||
m_currentResultsDirectory.clear();
|
m_currentResultsDirectory.clear();
|
||||||
m_lastTopLevelWindows.clear();
|
m_lastTopLevelWindows.clear();
|
||||||
break;
|
break;
|
||||||
@@ -180,6 +203,7 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
startSquishRunner();
|
startSquishRunner();
|
||||||
} else if (m_request == RecordTestRequested) {
|
} else if (m_request == RecordTestRequested) {
|
||||||
} else if (m_request == RunnerQueryRequested) {
|
} else if (m_request == RunnerQueryRequested) {
|
||||||
|
executeRunnerQuery();
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(false, qDebug() << m_state << m_request);
|
QTC_ASSERT(false, qDebug() << m_state << m_request);
|
||||||
}
|
}
|
||||||
@@ -187,9 +211,9 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
case ServerStartFailed:
|
case ServerStartFailed:
|
||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
m_request = None;
|
m_request = None;
|
||||||
if (m_testRunning) {
|
if (m_squishRunnerMode == TestingMode) {
|
||||||
emit squishTestRunFinished();
|
emit squishTestRunFinished();
|
||||||
m_testRunning = false;
|
m_squishRunnerMode = NoMode;
|
||||||
}
|
}
|
||||||
restoreQtCreatorWindows();
|
restoreQtCreatorWindows();
|
||||||
break;
|
break;
|
||||||
@@ -197,9 +221,9 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
if (m_request == ServerStopRequested) {
|
if (m_request == ServerStopRequested) {
|
||||||
m_request = None;
|
m_request = None;
|
||||||
if (m_testRunning) {
|
if (m_squishRunnerMode == TestingMode) {
|
||||||
emit squishTestRunFinished();
|
emit squishTestRunFinished();
|
||||||
m_testRunning = false;
|
m_squishRunnerMode = NoMode;
|
||||||
}
|
}
|
||||||
restoreQtCreatorWindows();
|
restoreQtCreatorWindows();
|
||||||
} else if (m_request == KillOldBeforeRunRunner) {
|
} else if (m_request == KillOldBeforeRunRunner) {
|
||||||
@@ -218,7 +242,10 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
break;
|
break;
|
||||||
case RunnerStartFailed:
|
case RunnerStartFailed:
|
||||||
case RunnerStopped:
|
case RunnerStopped:
|
||||||
if (m_testCases.isEmpty()) {
|
if (m_squishRunnerMode == QueryMode) {
|
||||||
|
m_request = ServerStopRequested;
|
||||||
|
stopSquishServer();
|
||||||
|
} else if (m_testCases.isEmpty()) {
|
||||||
m_request = ServerStopRequested;
|
m_request = ServerStopRequested;
|
||||||
stopSquishServer();
|
stopSquishServer();
|
||||||
QString error;
|
QString error;
|
||||||
@@ -292,10 +319,12 @@ void SquishTools::startSquishServer(Request request)
|
|||||||
}
|
}
|
||||||
toolsSettings.serverPath = squishServer;
|
toolsSettings.serverPath = squishServer;
|
||||||
|
|
||||||
if (true) // TODO squish setting of minimize QC on squish run/record
|
if (m_squishRunnerMode == TestingMode) {
|
||||||
minimizeQtCreatorWindows();
|
if (true) // TODO squish setting of minimize QC on squish run/record
|
||||||
else
|
minimizeQtCreatorWindows();
|
||||||
m_lastTopLevelWindows.clear();
|
else
|
||||||
|
m_lastTopLevelWindows.clear();
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -368,6 +397,14 @@ void SquishTools::startSquishRunner()
|
|||||||
setupAndStartSquishRunnerProcess(args, caseReportFilePath);
|
setupAndStartSquishRunnerProcess(args, caseReportFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SquishTools::executeRunnerQuery()
|
||||||
|
{
|
||||||
|
if (!isValidToStartRunner() || !setupRunnerPath())
|
||||||
|
return;
|
||||||
|
|
||||||
|
setupAndStartSquishRunnerProcess({ "--port", QString::number(m_serverPort), "--info", "all"});
|
||||||
|
}
|
||||||
|
|
||||||
Environment SquishTools::squishEnvironment()
|
Environment SquishTools::squishEnvironment()
|
||||||
{
|
{
|
||||||
Environment environment = Environment::systemEnvironment();
|
Environment environment = Environment::systemEnvironment();
|
||||||
@@ -385,6 +422,12 @@ void SquishTools::onServerFinished()
|
|||||||
|
|
||||||
void SquishTools::onRunnerFinished()
|
void SquishTools::onRunnerFinished()
|
||||||
{
|
{
|
||||||
|
if (m_squishRunnerMode == QueryMode) {
|
||||||
|
emit queryFinished(m_runnerProcess.readAllStandardOutput());
|
||||||
|
setState(RunnerStopped);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_resultsFileWatcher) {
|
if (m_resultsFileWatcher) {
|
||||||
delete m_resultsFileWatcher;
|
delete m_resultsFileWatcher;
|
||||||
m_resultsFileWatcher = nullptr;
|
m_resultsFileWatcher = nullptr;
|
||||||
@@ -480,6 +523,9 @@ static int positionAfterLastClosingTag(const QByteArray &text)
|
|||||||
|
|
||||||
void SquishTools::onRunnerOutput()
|
void SquishTools::onRunnerOutput()
|
||||||
{
|
{
|
||||||
|
if (m_request == RunnerQueryRequested) // only handle test runs here, query is handled on done
|
||||||
|
return;
|
||||||
|
|
||||||
// buffer for already read, but not processed content
|
// buffer for already read, but not processed content
|
||||||
static QByteArray buffer;
|
static QByteArray buffer;
|
||||||
const qint64 currentSize = m_currentResultsXML->size();
|
const qint64 currentSize = m_currentResultsXML->size();
|
||||||
|
@@ -51,6 +51,8 @@ public:
|
|||||||
explicit SquishTools(QObject *parent = nullptr);
|
explicit SquishTools(QObject *parent = nullptr);
|
||||||
~SquishTools() override;
|
~SquishTools() override;
|
||||||
|
|
||||||
|
static SquishTools *instance();
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
Idle,
|
Idle,
|
||||||
ServerStarting,
|
ServerStarting,
|
||||||
@@ -69,11 +71,14 @@ public:
|
|||||||
const QStringList &testCases = QStringList(),
|
const QStringList &testCases = QStringList(),
|
||||||
const QStringList &additionalServerArgs = QStringList(),
|
const QStringList &additionalServerArgs = QStringList(),
|
||||||
const QStringList &additionalRunnerArgs = QStringList());
|
const QStringList &additionalRunnerArgs = QStringList());
|
||||||
|
void queryServerSettings();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void logOutputReceived(const QString &output);
|
void logOutputReceived(const QString &output);
|
||||||
void squishTestRunStarted();
|
void squishTestRunStarted();
|
||||||
void squishTestRunFinished();
|
void squishTestRunFinished();
|
||||||
void resultOutputCreated(const QByteArray &output);
|
void resultOutputCreated(const QByteArray &output);
|
||||||
|
void queryFinished(const QByteArray &output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Request {
|
enum Request {
|
||||||
@@ -92,6 +97,7 @@ private:
|
|||||||
void startSquishServer(Request request);
|
void startSquishServer(Request request);
|
||||||
void stopSquishServer();
|
void stopSquishServer();
|
||||||
void startSquishRunner();
|
void startSquishRunner();
|
||||||
|
void executeRunnerQuery();
|
||||||
static Utils::Environment squishEnvironment();
|
static Utils::Environment squishEnvironment();
|
||||||
void onServerFinished();
|
void onServerFinished();
|
||||||
void onRunnerFinished();
|
void onRunnerFinished();
|
||||||
@@ -124,7 +130,7 @@ private:
|
|||||||
QStringList m_additionalServerArguments;
|
QStringList m_additionalServerArguments;
|
||||||
QStringList m_additionalRunnerArguments;
|
QStringList m_additionalRunnerArguments;
|
||||||
QWindowList m_lastTopLevelWindows;
|
QWindowList m_lastTopLevelWindows;
|
||||||
bool m_testRunning = false;
|
enum RunnerMode { NoMode, TestingMode, QueryMode} m_squishRunnerMode = NoMode;
|
||||||
qint64 m_readResultsCount;
|
qint64 m_readResultsCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user