forked from qt-creator/qt-creator
AutoTest: Avoid triggering run tests while building
Disable respective actions while a build is running to avoid strange side-effects or race conditions. Change-Id: Ifc8d1c9fc9fd4d705cabd148b145708e23029dba Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -46,8 +46,8 @@
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
@@ -102,6 +102,7 @@ void AutotestPlugin::initializeMenuEntries()
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+T,Alt+A")));
|
||||
connect(action, &QAction::triggered,
|
||||
this, &AutotestPlugin::onRunAllTriggered);
|
||||
action->setEnabled(false);
|
||||
menu->addAction(command);
|
||||
|
||||
action = new QAction(tr("&Run Selected Tests"), this);
|
||||
@@ -109,6 +110,7 @@ void AutotestPlugin::initializeMenuEntries()
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+T,Alt+R")));
|
||||
connect(action, &QAction::triggered,
|
||||
this, &AutotestPlugin::onRunSelectedTriggered);
|
||||
action->setEnabled(false);
|
||||
menu->addAction(command);
|
||||
|
||||
action = new QAction(tr("Re&scan Tests"), this);
|
||||
@@ -121,7 +123,12 @@ void AutotestPlugin::initializeMenuEntries()
|
||||
|
||||
ActionContainer *toolsMenu = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
||||
toolsMenu->addMenu(menu);
|
||||
connect(toolsMenu->menu(), &QMenu::aboutToShow,
|
||||
using namespace ProjectExplorer;
|
||||
connect(BuildManager::instance(), &BuildManager::buildStateChanged,
|
||||
this, &AutotestPlugin::updateMenuItemsEnabledState);
|
||||
connect(BuildManager::instance(), &BuildManager::buildQueueFinished,
|
||||
this, &AutotestPlugin::updateMenuItemsEnabledState);
|
||||
connect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged,
|
||||
this, &AutotestPlugin::updateMenuItemsEnabledState);
|
||||
}
|
||||
|
||||
@@ -176,7 +183,8 @@ void AutotestPlugin::onRunSelectedTriggered()
|
||||
|
||||
void AutotestPlugin::updateMenuItemsEnabledState()
|
||||
{
|
||||
const bool enabled = !TestRunner::instance()->isTestRunning()
|
||||
const bool enabled = !ProjectExplorer::BuildManager::isBuilding()
|
||||
&& !TestRunner::instance()->isTestRunning()
|
||||
&& TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle;
|
||||
const bool hasTests = TestTreeModel::instance()->hasTests();
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
void updateMenuItemsEnabledState();
|
||||
QList<QObject *> createTestObjects() const override;
|
||||
const QSharedPointer<TestSettings> m_settings;
|
||||
TestFrameworkManager *m_frameworkManager = 0;
|
||||
TestFrameworkManager *m_frameworkManager = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <utils/progressindicator.h>
|
||||
#include <utils/utilsicons.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
@@ -113,7 +114,8 @@ TestNavigationWidget::~TestNavigationWidget()
|
||||
|
||||
void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
const bool enabled = !TestRunner::instance()->isTestRunning()
|
||||
const bool enabled = !ProjectExplorer::BuildManager::isBuilding()
|
||||
&& !TestRunner::instance()->isTestRunning()
|
||||
&& m_model->parser()->state() == TestCodeParser::Idle;
|
||||
const bool hasTests = m_model->hasTests();
|
||||
|
||||
@@ -170,8 +172,6 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
connect(selectAll, &QAction::triggered, m_view, &TestTreeView::selectAll);
|
||||
connect(deselectAll, &QAction::triggered, m_view, &TestTreeView::deselectAll);
|
||||
|
||||
runAll->setEnabled(enabled && hasTests);
|
||||
runSelected->setEnabled(enabled && hasTests);
|
||||
selectAll->setEnabled(enabled && hasTests);
|
||||
deselectAll->setEnabled(enabled && hasTests);
|
||||
rescan->setEnabled(enabled);
|
||||
|
||||
@@ -33,12 +33,14 @@
|
||||
#include "testtreemodel.h"
|
||||
#include "testcodeparser.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
@@ -482,7 +484,9 @@ void TestResultsPane::onTestRunStarted()
|
||||
m_testRunning = true;
|
||||
m_stopTestRun->setEnabled(true);
|
||||
m_runAll->setEnabled(false);
|
||||
Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(false);
|
||||
m_runSelected->setEnabled(false);
|
||||
Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()->setEnabled(false);
|
||||
m_summaryWidget->setVisible(false);
|
||||
}
|
||||
|
||||
@@ -490,8 +494,14 @@ void TestResultsPane::onTestRunFinished()
|
||||
{
|
||||
m_testRunning = false;
|
||||
m_stopTestRun->setEnabled(false);
|
||||
m_runAll->setEnabled(true);
|
||||
m_runSelected->setEnabled(true);
|
||||
|
||||
const bool runEnabled = !ProjectExplorer::BuildManager::isBuilding()
|
||||
&& TestTreeModel::instance()->hasTests()
|
||||
&& TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle;
|
||||
m_runAll->setEnabled(runEnabled); // TODO unify Run* actions
|
||||
Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(runEnabled);
|
||||
m_runSelected->setEnabled(runEnabled);
|
||||
Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()->setEnabled(runEnabled);
|
||||
updateSummaryLabel();
|
||||
m_summaryWidget->setVisible(true);
|
||||
m_model->removeCurrentTestMessage();
|
||||
@@ -512,6 +522,7 @@ void TestResultsPane::updateRunActions()
|
||||
QString whyNot;
|
||||
TestTreeModel *model = TestTreeModel::instance();
|
||||
const bool enable = !m_testRunning && !model->parser()->isParsing() && model->hasTests()
|
||||
&& !ProjectExplorer::BuildManager::isBuilding()
|
||||
&& ProjectExplorer::ProjectExplorerPlugin::canRunStartupProject(
|
||||
ProjectExplorer::Constants::NORMAL_RUN_MODE, &whyNot);
|
||||
m_runAll->setEnabled(enable);
|
||||
|
||||
Reference in New Issue
Block a user