From 69a94c2c28480cab58ea7eb565a1869a62fb1152 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 12 Dec 2016 09:35:49 +0100 Subject: [PATCH] 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 --- src/plugins/autotest/autotestplugin.cpp | 3 --- src/plugins/autotest/autotestunittests.cpp | 7 ------ src/plugins/autotest/autotestunittests.h | 1 - src/plugins/autotest/testcodeparser.cpp | 24 ++++-------------- src/plugins/autotest/testcodeparser.h | 3 --- src/plugins/autotest/testnavigationwidget.cpp | 4 +-- src/plugins/autotest/testresultspane.cpp | 2 -- src/plugins/autotest/testsettings.cpp | 3 --- src/plugins/autotest/testsettings.h | 1 - src/plugins/autotest/testsettingspage.cpp | 6 ----- src/plugins/autotest/testsettingspage.ui | 10 -------- src/plugins/autotest/testtreemodel.cpp | 25 +------------------ src/plugins/autotest/testtreemodel.h | 5 ---- 13 files changed, 7 insertions(+), 87 deletions(-) diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index f6e12685fb4..b2af4863694 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -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(); diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index 60aecc79534..369df6b7145 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -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; } diff --git a/src/plugins/autotest/autotestunittests.h b/src/plugins/autotest/autotestunittests.h index 74d47539dda..bca21e86baa 100644 --- a/src/plugins/autotest/autotestunittests.h +++ b/src/plugins/autotest/autotestunittests.h @@ -57,7 +57,6 @@ private: TestTreeModel *m_model; CppTools::Tests::TemporaryCopiedDir *m_tmpDir; bool m_isQt4; - bool m_originalAlwaysParse; }; } // namespace Internal diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index dab7f80f672..22ddbd31520 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -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 &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 &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 &parsers, void TestCodeParser::scanForTests(const QStringList &fileList) { - if (m_parserState == Shutdown) + if (m_parserState == Shutdown || m_testCodeParsers.isEmpty()) 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)) return; diff --git a/src/plugins/autotest/testcodeparser.h b/src/plugins/autotest/testcodeparser.h index 2c68d143f2f..8f9cc0a4fd4 100644 --- a/src/plugins/autotest/testcodeparser.h +++ b/src/plugins/autotest/testcodeparser.h @@ -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 &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; diff --git a/src/plugins/autotest/testnavigationwidget.cpp b/src/plugins/autotest/testnavigationwidget.cpp index 1972638714b..cf6a2b4b80a 100644 --- a/src/plugins/autotest/testnavigationwidget.cpp +++ b/src/plugins/autotest/testnavigationwidget.cpp @@ -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; } diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index d2a8781bcf5..ac17f9662ed 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -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; } diff --git a/src/plugins/autotest/testsettings.cpp b/src/plugins/autotest/testsettings.cpp index 13d302f901e..c3f0b1bda00 100644 --- a/src/plugins/autotest/testsettings.cpp +++ b/src/plugins/autotest/testsettings.cpp @@ -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 ®istered = frameworkManager->registeredFrameworkIds(); diff --git a/src/plugins/autotest/testsettings.h b/src/plugins/autotest/testsettings.h index e35833defe7..5d0f6400f54 100644 --- a/src/plugins/autotest/testsettings.h +++ b/src/plugins/autotest/testsettings.h @@ -47,7 +47,6 @@ struct TestSettings bool omitRunConfigWarn = false; bool limitResultOutput = true; bool autoScroll = true; - bool alwaysParse = true; QHash frameworks; }; diff --git a/src/plugins/autotest/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp index bfc39f2048e..3006eee7a3f 100644 --- a/src/plugins/autotest/testsettingspage.cpp +++ b/src/plugins/autotest/testsettingspage.cpp @@ -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(); diff --git a/src/plugins/autotest/testsettingspage.ui b/src/plugins/autotest/testsettingspage.ui index 69d67fc5d58..4e4a39cfb49 100644 --- a/src/plugins/autotest/testsettingspage.ui +++ b/src/plugins/autotest/testsettingspage.ui @@ -73,16 +73,6 @@ - - - - Parses for tests even when no Tests related widget is displayed. - - - Always parse current project for tests - - - diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 6aba8e413c4..6d53f31baaa 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -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()) diff --git a/src/plugins/autotest/testtreemodel.h b/src/plugins/autotest/testtreemodel.h index bc2185d6386..7f5080f3fef 100644 --- a/src/plugins/autotest/testtreemodel.h +++ b/src/plugins/autotest/testtreemodel.h @@ -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