Commit 69a94c2c authored by Christian Stenger's avatar Christian Stenger

AutoTest: Always parse if plugin is enabled

Remove the 'Always parse' setting and respective special handling.
This simplifies the handling of parsing for tests and removes
strange special handling that was introduced in earlier versions
and led more to confusion on the user side.

Change-Id: Ia4d122ed448244f3cb3876dda9930864afde9c28
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 6a1ead7a
......@@ -141,8 +141,6 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
addAutoReleasedObject(new TestNavigationWidgetFactory);
addAutoReleasedObject(TestResultsPane::instance());
if (m_settings->alwaysParse)
TestTreeModel::instance()->enableParsingFromSettings();
m_frameworkManager->activateFrameworksFromSettings(m_settings);
TestTreeModel::instance()->syncTestFrameworks();
......@@ -178,7 +176,6 @@ void AutotestPlugin::onRunSelectedTriggered()
void AutotestPlugin::updateMenuItemsEnabledState()
{
const bool enabled = !TestRunner::instance()->isTestRunning()
&& TestTreeModel::instance()->parser()->enabled()
&& TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle;
const bool hasTests = TestTreeModel::instance()->hasTests();
......
......@@ -74,17 +74,10 @@ void AutoTestUnitTests::initTestCase()
QSKIP("This test requires that there is a kit with a toolchain.");
m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(QLatin1String(":/unit_test"));
m_originalAlwaysParse = AutotestPlugin::instance()->settings()->alwaysParse;
if (!m_originalAlwaysParse) {
AutotestPlugin::instance()->settings()->alwaysParse = true;
TestTreeModel::instance()->enableParsingFromSettings();
}
}
void AutoTestUnitTests::cleanupTestCase()
{
AutotestPlugin::instance()->settings()->alwaysParse = m_originalAlwaysParse;
delete m_tmpDir;
}
......
......@@ -57,7 +57,6 @@ private:
TestTreeModel *m_model;
CppTools::Tests::TemporaryCopiedDir *m_tmpDir;
bool m_isQt4;
bool m_originalAlwaysParse;
};
} // namespace Internal
......
......@@ -81,7 +81,7 @@ TestCodeParser::~TestCodeParser()
void TestCodeParser::setState(State state)
{
if (m_parserState == Shutdown || !m_enabled)
if (m_parserState == Shutdown)
return;
qCDebug(LOG) << "setState(" << state << "), currentState:" << m_parserState;
// avoid triggering parse before code model parsing has finished, but mark as dirty
......@@ -111,7 +111,7 @@ void TestCodeParser::setState(State state)
void TestCodeParser::syncTestFrameworks(const QVector<Core::Id> &frameworkIds)
{
if (m_enabled && m_parserState != Idle) {
if (m_parserState != Idle) {
// there's a running parse
m_fullUpdatePostponed = m_partialUpdatePostponed = false;
m_postponedFiles.clear();
......@@ -125,8 +125,7 @@ void TestCodeParser::syncTestFrameworks(const QVector<Core::Id> &frameworkIds)
QTC_ASSERT(testParser, continue);
m_testCodeParsers.append(testParser);
}
if (m_enabled)
updateTestTree();
updateTestTree();
}
void TestCodeParser::emitUpdateTestTree()
......@@ -206,7 +205,7 @@ void TestCodeParser::onProjectPartsUpdated(ProjectExplorer::Project *project)
{
if (project != ProjectExplorer::SessionManager::startupProject())
return;
if (m_codeModelParsing || !m_enabled)
if (m_codeModelParsing)
m_fullUpdatePostponed = true;
else
emitUpdateTestTree();
......@@ -291,21 +290,8 @@ static void parseFileForTests(const QVector<ITestParser *> &parsers,
void TestCodeParser::scanForTests(const QStringList &fileList)
{
if (m_parserState == Shutdown)
return;
if (!m_enabled) {
m_dirty = true;
if (fileList.isEmpty()) {
m_fullUpdatePostponed = true;
m_partialUpdatePostponed = false;
m_postponedFiles.clear();
} else if (!m_fullUpdatePostponed) {
m_partialUpdatePostponed = true;
foreach (const QString &file, fileList)
m_postponedFiles.insert(file);
}
if (m_parserState == Shutdown || m_testCodeParsers.isEmpty())
return;
}
if (postponed(fileList))
return;
......
......@@ -56,8 +56,6 @@ public:
virtual ~TestCodeParser();
void setState(State state);
State state() const { return m_parserState; }
void setEnabled(bool enabled) { m_enabled = enabled; }
bool enabled() const { return m_enabled; }
bool isParsing() const { return m_parserState == PartialParse || m_parserState == FullParse; }
void setDirty() { m_dirty = true; }
void syncTestFrameworks(const QVector<Core::Id> &frameworkIds);
......@@ -96,7 +94,6 @@ private:
TestTreeModel *m_model;
bool m_enabled = false;
bool m_codeModelParsing = false;
bool m_fullUpdatePostponed = false;
bool m_partialUpdatePostponed = false;
......
......@@ -109,13 +109,12 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
TestNavigationWidget::~TestNavigationWidget()
{
m_model->disableParsing();
}
void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
{
const bool enabled = !TestRunner::instance()->isTestRunning()
&& m_model->parser()->enabled() && m_model->parser()->state() == TestCodeParser::Idle;
&& m_model->parser()->state() == TestCodeParser::Idle;
const bool hasTests = m_model->hasTests();
QMenu menu;
......@@ -336,7 +335,6 @@ Core::NavigationView TestNavigationWidgetFactory::createWidget()
Core::NavigationView view;
view.widget = treeViewWidget;
view.dockToolBarWidgets = treeViewWidget->createToolButtons();
TestTreeModel::instance()->enableParsing();
return view;
}
......
......@@ -259,11 +259,9 @@ void TestResultsPane::visibilityChanged(bool visible)
this, &TestResultsPane::updateRunActions);
// make sure run/run all are in correct state
updateRunActions();
TestTreeModel::instance()->enableParsing();
} else {
disconnect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged,
this, &TestResultsPane::updateRunActions);
TestTreeModel::instance()->disableParsing();
}
m_wasVisibleBefore = visible;
}
......
......@@ -39,7 +39,6 @@ static const char omitInternalKey[] = "OmitInternal";
static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
static const char limitResultOutputKey[] = "LimitResultOutput";
static const char autoScrollKey[] = "AutoScrollResults";
static const char alwaysParseKey[] = "AlwaysParse";
static const int defaultTimeout = 60000;
......@@ -56,7 +55,6 @@ void TestSettings::toSettings(QSettings *s) const
s->setValue(omitRunConfigWarnKey, omitRunConfigWarn);
s->setValue(limitResultOutputKey, limitResultOutput);
s->setValue(autoScrollKey, autoScroll);
s->setValue(alwaysParseKey, alwaysParse);
// store frameworks and their current active state
for (const Core::Id &id : frameworks.keys())
s->setValue(QLatin1String(id.name()), frameworks.value(id));
......@@ -71,7 +69,6 @@ void TestSettings::fromSettings(QSettings *s)
omitRunConfigWarn = s->value(omitRunConfigWarnKey, false).toBool();
limitResultOutput = s->value(limitResultOutputKey, true).toBool();
autoScroll = s->value(autoScrollKey, true).toBool();
alwaysParse = s->value(alwaysParseKey, true).toBool();
// try to get settings for registered frameworks
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
const QList<Core::Id> &registered = frameworkManager->registeredFrameworkIds();
......
......@@ -47,7 +47,6 @@ struct TestSettings
bool omitRunConfigWarn = false;
bool limitResultOutput = true;
bool autoScroll = true;
bool alwaysParse = true;
QHash<Core::Id, bool> frameworks;
};
......
......@@ -58,7 +58,6 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn);
m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput);
m_ui.autoScrollCB->setChecked(settings.autoScroll);
m_ui.alwaysParseCB->setChecked(settings.alwaysParse);
populateFrameworksListWidget(settings.frameworks);
}
......@@ -70,7 +69,6 @@ TestSettings TestSettingsWidget::settings() const
result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked();
result.limitResultOutput = m_ui.limitResultOutputCB->isChecked();
result.autoScroll = m_ui.autoScrollCB->isChecked();
result.alwaysParse = m_ui.alwaysParseCB->isChecked();
result.frameworks = frameworks();
return result;
}
......@@ -146,10 +144,6 @@ void TestSettingsPage::apply()
bool frameworkSyncNecessary = newSettings.frameworks != m_settings->frameworks;
*m_settings = newSettings;
m_settings->toSettings(Core::ICore::settings());
if (m_settings->alwaysParse)
TestTreeModel::instance()->enableParsingFromSettings();
else
TestTreeModel::instance()->disableParsingFromSettings();
TestFrameworkManager::instance()->activateFrameworksFromSettings(m_settings);
if (frameworkSyncNecessary)
TestTreeModel::instance()->syncTestFrameworks();
......
......@@ -73,16 +73,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="alwaysParseCB">
<property name="toolTip">
<string>Parses for tests even when no Tests related widget is displayed.</string>
</property>
<property name="text">
<string>Always parse current project for tests</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0">
<property name="spacing">
......
......@@ -53,6 +53,7 @@ TestTreeModel::TestTreeModel(QObject *parent) :
this, &TestTreeModel::sweep, Qt::QueuedConnection);
connect(m_parser, &TestCodeParser::parsingFailed,
this, &TestTreeModel::sweep, Qt::QueuedConnection);
setupParsingConnections();
}
static TestTreeModel *m_instance = 0;
......@@ -74,23 +75,11 @@ TestTreeModel::~TestTreeModel()
m_instance = 0;
}
void TestTreeModel::enableParsing()
{
m_refCounter.ref();
setupParsingConnections();
}
void TestTreeModel::enableParsingFromSettings()
{
setupParsingConnections();
}
void TestTreeModel::setupParsingConnections()
{
if (!m_connectionsInitialized)
m_parser->setDirty();
m_parser->setEnabled(true);
m_parser->setState(TestCodeParser::Idle);
if (m_connectionsInitialized)
return;
......@@ -115,18 +104,6 @@ void TestTreeModel::setupParsingConnections()
m_connectionsInitialized = true;
}
void TestTreeModel::disableParsing()
{
if (!m_refCounter.deref() && !AutotestPlugin::instance()->settings()->alwaysParse)
m_parser->setEnabled(false);
}
void TestTreeModel::disableParsingFromSettings()
{
if (!m_refCounter.load())
m_parser->setEnabled(false);
}
bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!index.isValid())
......
......@@ -46,10 +46,6 @@ class TestTreeModel : public Utils::TreeModel<>
public:
static TestTreeModel* instance();
~TestTreeModel();
void enableParsing();
void enableParsingFromSettings();
void disableParsing();
void disableParsingFromSettings();
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
......@@ -95,7 +91,6 @@ private:
TestCodeParser *m_parser;
bool m_connectionsInitialized = false;
QAtomicInt m_refCounter;
};
class TestTreeSortFilterModel : public QSortFilterProxyModel
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment