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 <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2016-12-12 09:35:49 +01:00
parent 6a1ead7abb
commit 69a94c2c28
13 changed files with 7 additions and 87 deletions

View File

@@ -141,8 +141,6 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
addAutoReleasedObject(new TestNavigationWidgetFactory); addAutoReleasedObject(new TestNavigationWidgetFactory);
addAutoReleasedObject(TestResultsPane::instance()); addAutoReleasedObject(TestResultsPane::instance());
if (m_settings->alwaysParse)
TestTreeModel::instance()->enableParsingFromSettings();
m_frameworkManager->activateFrameworksFromSettings(m_settings); m_frameworkManager->activateFrameworksFromSettings(m_settings);
TestTreeModel::instance()->syncTestFrameworks(); TestTreeModel::instance()->syncTestFrameworks();
@@ -178,7 +176,6 @@ void AutotestPlugin::onRunSelectedTriggered()
void AutotestPlugin::updateMenuItemsEnabledState() void AutotestPlugin::updateMenuItemsEnabledState()
{ {
const bool enabled = !TestRunner::instance()->isTestRunning() const bool enabled = !TestRunner::instance()->isTestRunning()
&& TestTreeModel::instance()->parser()->enabled()
&& TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle; && TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle;
const bool hasTests = TestTreeModel::instance()->hasTests(); const bool hasTests = TestTreeModel::instance()->hasTests();

View File

@@ -74,17 +74,10 @@ void AutoTestUnitTests::initTestCase()
QSKIP("This test requires that there is a kit with a toolchain."); QSKIP("This test requires that there is a kit with a toolchain.");
m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(QLatin1String(":/unit_test")); 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() void AutoTestUnitTests::cleanupTestCase()
{ {
AutotestPlugin::instance()->settings()->alwaysParse = m_originalAlwaysParse;
delete m_tmpDir; delete m_tmpDir;
} }

View File

@@ -57,7 +57,6 @@ private:
TestTreeModel *m_model; TestTreeModel *m_model;
CppTools::Tests::TemporaryCopiedDir *m_tmpDir; CppTools::Tests::TemporaryCopiedDir *m_tmpDir;
bool m_isQt4; bool m_isQt4;
bool m_originalAlwaysParse;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -81,7 +81,7 @@ TestCodeParser::~TestCodeParser()
void TestCodeParser::setState(State state) void TestCodeParser::setState(State state)
{ {
if (m_parserState == Shutdown || !m_enabled) if (m_parserState == Shutdown)
return; return;
qCDebug(LOG) << "setState(" << state << "), currentState:" << m_parserState; qCDebug(LOG) << "setState(" << state << "), currentState:" << m_parserState;
// avoid triggering parse before code model parsing has finished, but mark as dirty // 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) void TestCodeParser::syncTestFrameworks(const QVector<Core::Id> &frameworkIds)
{ {
if (m_enabled && m_parserState != Idle) { if (m_parserState != Idle) {
// there's a running parse // there's a running parse
m_fullUpdatePostponed = m_partialUpdatePostponed = false; m_fullUpdatePostponed = m_partialUpdatePostponed = false;
m_postponedFiles.clear(); m_postponedFiles.clear();
@@ -125,7 +125,6 @@ void TestCodeParser::syncTestFrameworks(const QVector<Core::Id> &frameworkIds)
QTC_ASSERT(testParser, continue); QTC_ASSERT(testParser, continue);
m_testCodeParsers.append(testParser); m_testCodeParsers.append(testParser);
} }
if (m_enabled)
updateTestTree(); updateTestTree();
} }
@@ -206,7 +205,7 @@ void TestCodeParser::onProjectPartsUpdated(ProjectExplorer::Project *project)
{ {
if (project != ProjectExplorer::SessionManager::startupProject()) if (project != ProjectExplorer::SessionManager::startupProject())
return; return;
if (m_codeModelParsing || !m_enabled) if (m_codeModelParsing)
m_fullUpdatePostponed = true; m_fullUpdatePostponed = true;
else else
emitUpdateTestTree(); emitUpdateTestTree();
@@ -291,21 +290,8 @@ static void parseFileForTests(const QVector<ITestParser *> &parsers,
void TestCodeParser::scanForTests(const QStringList &fileList) void TestCodeParser::scanForTests(const QStringList &fileList)
{ {
if (m_parserState == Shutdown) if (m_parserState == Shutdown || m_testCodeParsers.isEmpty())
return; 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);
}
return;
}
if (postponed(fileList)) if (postponed(fileList))
return; return;

View File

@@ -56,8 +56,6 @@ public:
virtual ~TestCodeParser(); virtual ~TestCodeParser();
void setState(State state); void setState(State state);
State state() const { return m_parserState; } 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; } bool isParsing() const { return m_parserState == PartialParse || m_parserState == FullParse; }
void setDirty() { m_dirty = true; } void setDirty() { m_dirty = true; }
void syncTestFrameworks(const QVector<Core::Id> &frameworkIds); void syncTestFrameworks(const QVector<Core::Id> &frameworkIds);
@@ -96,7 +94,6 @@ private:
TestTreeModel *m_model; TestTreeModel *m_model;
bool m_enabled = false;
bool m_codeModelParsing = false; bool m_codeModelParsing = false;
bool m_fullUpdatePostponed = false; bool m_fullUpdatePostponed = false;
bool m_partialUpdatePostponed = false; bool m_partialUpdatePostponed = false;

View File

@@ -109,13 +109,12 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
TestNavigationWidget::~TestNavigationWidget() TestNavigationWidget::~TestNavigationWidget()
{ {
m_model->disableParsing();
} }
void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event) void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
{ {
const bool enabled = !TestRunner::instance()->isTestRunning() 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(); const bool hasTests = m_model->hasTests();
QMenu menu; QMenu menu;
@@ -336,7 +335,6 @@ Core::NavigationView TestNavigationWidgetFactory::createWidget()
Core::NavigationView view; Core::NavigationView view;
view.widget = treeViewWidget; view.widget = treeViewWidget;
view.dockToolBarWidgets = treeViewWidget->createToolButtons(); view.dockToolBarWidgets = treeViewWidget->createToolButtons();
TestTreeModel::instance()->enableParsing();
return view; return view;
} }

View File

@@ -259,11 +259,9 @@ void TestResultsPane::visibilityChanged(bool visible)
this, &TestResultsPane::updateRunActions); this, &TestResultsPane::updateRunActions);
// make sure run/run all are in correct state // make sure run/run all are in correct state
updateRunActions(); updateRunActions();
TestTreeModel::instance()->enableParsing();
} else { } else {
disconnect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged, disconnect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged,
this, &TestResultsPane::updateRunActions); this, &TestResultsPane::updateRunActions);
TestTreeModel::instance()->disableParsing();
} }
m_wasVisibleBefore = visible; m_wasVisibleBefore = visible;
} }

View File

@@ -39,7 +39,6 @@ static const char omitInternalKey[] = "OmitInternal";
static const char omitRunConfigWarnKey[] = "OmitRCWarnings"; static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
static const char limitResultOutputKey[] = "LimitResultOutput"; static const char limitResultOutputKey[] = "LimitResultOutput";
static const char autoScrollKey[] = "AutoScrollResults"; static const char autoScrollKey[] = "AutoScrollResults";
static const char alwaysParseKey[] = "AlwaysParse";
static const int defaultTimeout = 60000; static const int defaultTimeout = 60000;
@@ -56,7 +55,6 @@ void TestSettings::toSettings(QSettings *s) const
s->setValue(omitRunConfigWarnKey, omitRunConfigWarn); s->setValue(omitRunConfigWarnKey, omitRunConfigWarn);
s->setValue(limitResultOutputKey, limitResultOutput); s->setValue(limitResultOutputKey, limitResultOutput);
s->setValue(autoScrollKey, autoScroll); s->setValue(autoScrollKey, autoScroll);
s->setValue(alwaysParseKey, alwaysParse);
// store frameworks and their current active state // store frameworks and their current active state
for (const Core::Id &id : frameworks.keys()) for (const Core::Id &id : frameworks.keys())
s->setValue(QLatin1String(id.name()), frameworks.value(id)); s->setValue(QLatin1String(id.name()), frameworks.value(id));
@@ -71,7 +69,6 @@ void TestSettings::fromSettings(QSettings *s)
omitRunConfigWarn = s->value(omitRunConfigWarnKey, false).toBool(); omitRunConfigWarn = s->value(omitRunConfigWarnKey, false).toBool();
limitResultOutput = s->value(limitResultOutputKey, true).toBool(); limitResultOutput = s->value(limitResultOutputKey, true).toBool();
autoScroll = s->value(autoScrollKey, true).toBool(); autoScroll = s->value(autoScrollKey, true).toBool();
alwaysParse = s->value(alwaysParseKey, true).toBool();
// try to get settings for registered frameworks // try to get settings for registered frameworks
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance(); TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
const QList<Core::Id> &registered = frameworkManager->registeredFrameworkIds(); const QList<Core::Id> &registered = frameworkManager->registeredFrameworkIds();

View File

@@ -47,7 +47,6 @@ struct TestSettings
bool omitRunConfigWarn = false; bool omitRunConfigWarn = false;
bool limitResultOutput = true; bool limitResultOutput = true;
bool autoScroll = true; bool autoScroll = true;
bool alwaysParse = true;
QHash<Core::Id, bool> frameworks; QHash<Core::Id, bool> frameworks;
}; };

View File

@@ -58,7 +58,6 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn); m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn);
m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput); m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput);
m_ui.autoScrollCB->setChecked(settings.autoScroll); m_ui.autoScrollCB->setChecked(settings.autoScroll);
m_ui.alwaysParseCB->setChecked(settings.alwaysParse);
populateFrameworksListWidget(settings.frameworks); populateFrameworksListWidget(settings.frameworks);
} }
@@ -70,7 +69,6 @@ TestSettings TestSettingsWidget::settings() const
result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked(); result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked();
result.limitResultOutput = m_ui.limitResultOutputCB->isChecked(); result.limitResultOutput = m_ui.limitResultOutputCB->isChecked();
result.autoScroll = m_ui.autoScrollCB->isChecked(); result.autoScroll = m_ui.autoScrollCB->isChecked();
result.alwaysParse = m_ui.alwaysParseCB->isChecked();
result.frameworks = frameworks(); result.frameworks = frameworks();
return result; return result;
} }
@@ -146,10 +144,6 @@ void TestSettingsPage::apply()
bool frameworkSyncNecessary = newSettings.frameworks != m_settings->frameworks; bool frameworkSyncNecessary = newSettings.frameworks != m_settings->frameworks;
*m_settings = newSettings; *m_settings = newSettings;
m_settings->toSettings(Core::ICore::settings()); m_settings->toSettings(Core::ICore::settings());
if (m_settings->alwaysParse)
TestTreeModel::instance()->enableParsingFromSettings();
else
TestTreeModel::instance()->disableParsingFromSettings();
TestFrameworkManager::instance()->activateFrameworksFromSettings(m_settings); TestFrameworkManager::instance()->activateFrameworksFromSettings(m_settings);
if (frameworkSyncNecessary) if (frameworkSyncNecessary)
TestTreeModel::instance()->syncTestFrameworks(); TestTreeModel::instance()->syncTestFrameworks();

View File

@@ -73,16 +73,6 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0"> <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0">
<property name="spacing"> <property name="spacing">

View File

@@ -53,6 +53,7 @@ TestTreeModel::TestTreeModel(QObject *parent) :
this, &TestTreeModel::sweep, Qt::QueuedConnection); this, &TestTreeModel::sweep, Qt::QueuedConnection);
connect(m_parser, &TestCodeParser::parsingFailed, connect(m_parser, &TestCodeParser::parsingFailed,
this, &TestTreeModel::sweep, Qt::QueuedConnection); this, &TestTreeModel::sweep, Qt::QueuedConnection);
setupParsingConnections();
} }
static TestTreeModel *m_instance = 0; static TestTreeModel *m_instance = 0;
@@ -74,23 +75,11 @@ TestTreeModel::~TestTreeModel()
m_instance = 0; m_instance = 0;
} }
void TestTreeModel::enableParsing()
{
m_refCounter.ref();
setupParsingConnections();
}
void TestTreeModel::enableParsingFromSettings()
{
setupParsingConnections();
}
void TestTreeModel::setupParsingConnections() void TestTreeModel::setupParsingConnections()
{ {
if (!m_connectionsInitialized) if (!m_connectionsInitialized)
m_parser->setDirty(); m_parser->setDirty();
m_parser->setEnabled(true);
m_parser->setState(TestCodeParser::Idle); m_parser->setState(TestCodeParser::Idle);
if (m_connectionsInitialized) if (m_connectionsInitialized)
return; return;
@@ -115,18 +104,6 @@ void TestTreeModel::setupParsingConnections()
m_connectionsInitialized = true; 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) bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
{ {
if (!index.isValid()) if (!index.isValid())

View File

@@ -46,10 +46,6 @@ class TestTreeModel : public Utils::TreeModel<>
public: public:
static TestTreeModel* instance(); static TestTreeModel* instance();
~TestTreeModel(); ~TestTreeModel();
void enableParsing();
void enableParsingFromSettings();
void disableParsing();
void disableParsingFromSettings();
bool setData(const QModelIndex &index, const QVariant &value, int role) override; bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Qt::ItemFlags flags(const QModelIndex &index) const override; Qt::ItemFlags flags(const QModelIndex &index) const override;
@@ -95,7 +91,6 @@ private:
TestCodeParser *m_parser; TestCodeParser *m_parser;
bool m_connectionsInitialized = false; bool m_connectionsInitialized = false;
QAtomicInt m_refCounter;
}; };
class TestTreeSortFilterModel : public QSortFilterProxyModel class TestTreeSortFilterModel : public QSortFilterProxyModel