From d005e71da0aa1b5983ac13fcbe828e409e68ef28 Mon Sep 17 00:00:00 2001 From: Petar Perisin Date: Thu, 8 Jul 2021 16:57:00 +0200 Subject: [PATCH] Autotest: Add more "without deployment" actions When debugging tests, if there was no change in code, user should be able to just rerun tests of his choice. However, currently there are not so many options to just rerun tests without the build. This patch adds more options to run tests without deployment, which can speed up development in some environments Change-Id: I9f998fee90f2e61a1623bd0840a9d5ddf8eb58d7 Reviewed-by: Christian Stenger --- src/plugins/autotest/autotestconstants.h | 42 +++++++------ src/plugins/autotest/autotestplugin.cpp | 62 ++++++++++++++++--- src/plugins/autotest/testnavigationwidget.cpp | 4 ++ src/plugins/autotest/testresultspane.cpp | 14 +++++ 4 files changed, 95 insertions(+), 27 deletions(-) diff --git a/src/plugins/autotest/autotestconstants.h b/src/plugins/autotest/autotestconstants.h index c90cc5269ff..2021f8e9776 100644 --- a/src/plugins/autotest/autotestconstants.h +++ b/src/plugins/autotest/autotestconstants.h @@ -30,25 +30,29 @@ namespace Autotest { namespace Constants { -const char ACTION_SCAN_ID[] = "AutoTest.ScanAction"; -const char ACTION_RUN_ALL_ID[] = "AutoTest.RunAll"; -const char ACTION_RUN_SELECTED_ID[] = "AutoTest.RunSelected"; -const char ACTION_RUN_FAILED_ID[] = "AutoTest.RunFailed"; -const char ACTION_RUN_FILE_ID[] = "AutoTest.RunFile"; -const char ACTION_RUN_UCURSOR[] = "AutoTest.RunUnderCursor"; -const char ACTION_RUN_DBG_UCURSOR[] = "AutoTest.RunDebugUnderCursor"; -const char MENU_ID[] = "AutoTest.Menu"; -const char AUTOTEST_ID[] = "AutoTest.ATP"; -const char AUTOTEST_CONTEXT[] = "Auto Tests"; -const char TASK_INDEX[] = "AutoTest.Task.Index"; -const char TASK_PARSE[] = "AutoTest.Task.Parse"; -const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests"; -const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Testing"); -const char FRAMEWORK_PREFIX[] = "AutoTest.Framework."; -const char SETTINGSPAGE_PREFIX[] = "A.AutoTest."; -const char SETTINGSGROUP[] = "Autotest"; -const char TASK_MARK_ID[] = "Autotest.TaskMark"; -const char SK_USE_GLOBAL[] = "AutoTest.UseGlobal"; +const char ACTION_SCAN_ID[] = "AutoTest.ScanAction"; +const char ACTION_RUN_ALL_ID[] = "AutoTest.RunAll"; +const char ACTION_RUN_ALL_NODEPLOY_ID[] = "AutoTest.RunAllNoDeploy"; +const char ACTION_RUN_SELECTED_ID[] = "AutoTest.RunSelected"; +const char ACTION_RUN_SELECTED_NODEPLOY_ID[] = "AutoTest.RunSelectedNoDeploy"; +const char ACTION_RUN_FAILED_ID[] = "AutoTest.RunFailed"; +const char ACTION_RUN_FILE_ID[] = "AutoTest.RunFile"; +const char ACTION_RUN_UCURSOR[] = "AutoTest.RunUnderCursor"; +const char ACTION_RUN_UCURSOR_NODEPLOY[] = "AutoTest.RunUnderCursorNoDeploy"; +const char ACTION_RUN_DBG_UCURSOR[] = "AutoTest.RunDebugUnderCursor"; +const char ACTION_RUN_DBG_UCURSOR_NODEPLOY[] = "AutoTest.RunDebugUnderCursorNoDeploy"; +const char MENU_ID[] = "AutoTest.Menu"; +const char AUTOTEST_ID[] = "AutoTest.ATP"; +const char AUTOTEST_CONTEXT[] = "Auto Tests"; +const char TASK_INDEX[] = "AutoTest.Task.Index"; +const char TASK_PARSE[] = "AutoTest.Task.Parse"; +const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests"; +const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Testing"); +const char FRAMEWORK_PREFIX[] = "AutoTest.Framework."; +const char SETTINGSPAGE_PREFIX[] = "A.AutoTest."; +const char SETTINGSGROUP[] = "Autotest"; +const char TASK_MARK_ID[] = "Autotest.TaskMark"; +const char SK_USE_GLOBAL[] = "AutoTest.UseGlobal"; } // namespace Constants enum class TestRunMode diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 6f26981bef6..38883879a30 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -99,8 +99,8 @@ public: QMap m_runconfigCache; void initializeMenuEntries(); - void onRunAllTriggered(); - void onRunSelectedTriggered(); + void onRunAllTriggered(TestRunMode mode); + void onRunSelectedTriggered(TestRunMode mode); void onRunFailedTriggered(); void onRunFileTriggered(); void onRunUnderCursorTriggered(TestRunMode mode); @@ -214,7 +214,19 @@ void AutotestPluginPrivate::initializeMenuEntries() Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_ID); command->setDefaultKeySequence( QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+A") : tr("Alt+Shift+T,Alt+A"))); - connect(action, &QAction::triggered, this, &AutotestPluginPrivate::onRunAllTriggered); + connect(action, &QAction::triggered, + std::bind(&AutotestPluginPrivate::onRunAllTriggered, this, TestRunMode::Run)); + action->setEnabled(false); + menu->addAction(command); + + action = new QAction(tr("Run All Tests Without Deployment"), this); + action->setIcon(Utils::Icons::RUN_SMALL.icon()); + action->setToolTip(tr("Run All Tests Without Deployment")); + command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_NODEPLOY_ID); + command->setDefaultKeySequence( + QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+E") : tr("Alt+Shift+T,Alt+E"))); + connect(action, &QAction::triggered, + std::bind(&AutotestPluginPrivate::onRunAllTriggered, this, TestRunMode::RunWithoutDeploy)); action->setEnabled(false); menu->addAction(command); @@ -224,7 +236,19 @@ void AutotestPluginPrivate::initializeMenuEntries() command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_ID); command->setDefaultKeySequence( QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+R") : tr("Alt+Shift+T,Alt+R"))); - connect(action, &QAction::triggered, this, &AutotestPluginPrivate::onRunSelectedTriggered); + connect(action, &QAction::triggered, + std::bind(&AutotestPluginPrivate::onRunSelectedTriggered, this, TestRunMode::Run)); + action->setEnabled(false); + menu->addAction(command); + + action = new QAction(tr("&Run Selected Tests Without Deployment"), this); + action->setIcon(Utils::Icons::RUN_SELECTED.icon()); + action->setToolTip(tr("Run Selected Tests")); + command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_NODEPLOY_ID); + command->setDefaultKeySequence( + QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+W") : tr("Alt+Shift+T,Alt+W"))); + connect(action, &QAction::triggered, + std::bind(&AutotestPluginPrivate::onRunSelectedTriggered, this, TestRunMode::RunWithoutDeploy)); action->setEnabled(false); menu->addAction(command); @@ -300,6 +324,15 @@ void AutotestPlugin::extensionsInitialized() contextMenu->addSeparator(); contextMenu->addAction(command); + action = new QAction(tr("Run Test Under Cursor Without Deployment"), this); + action->setEnabled(false); + action->setIcon(Utils::Icons::RUN_SMALL.icon()); + + command = ActionManager::registerAction(action, Constants::ACTION_RUN_UCURSOR_NODEPLOY); + connect(action, &QAction::triggered, + std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::RunWithoutDeploy)); + contextMenu->addAction(command); + action = new QAction(tr("&Debug Test Under Cursor"), this); action->setEnabled(false); action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon()); @@ -308,6 +341,15 @@ void AutotestPlugin::extensionsInitialized() connect(action, &QAction::triggered, std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::Debug)); contextMenu->addAction(command); + + action = new QAction(tr("Debug Test Under Cursor Without Deployment"), this); + action->setEnabled(false); + action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon()); + + command = ActionManager::registerAction(action, Constants::ACTION_RUN_DBG_UCURSOR_NODEPLOY); + connect(action, &QAction::triggered, + std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::DebugWithoutDeploy)); + contextMenu->addAction(command); contextMenu->addSeparator(); } @@ -318,16 +360,16 @@ ExtensionSystem::IPlugin::ShutdownFlag AutotestPlugin::aboutToShutdown() return SynchronousShutdown; } -void AutotestPluginPrivate::onRunAllTriggered() +void AutotestPluginPrivate::onRunAllTriggered(TestRunMode mode) { m_testRunner.setSelectedTests(m_testTreeModel.getAllTestCases()); - m_testRunner.prepareToRunTests(TestRunMode::Run); + m_testRunner.prepareToRunTests(mode); } -void AutotestPluginPrivate::onRunSelectedTriggered() +void AutotestPluginPrivate::onRunSelectedTriggered(TestRunMode mode) { m_testRunner.setSelectedTests(m_testTreeModel.getSelectedTests()); - m_testRunner.prepareToRunTests(TestRunMode::Run); + m_testRunner.prepareToRunTests(mode); } void AutotestPluginPrivate::onRunFailedTriggered() @@ -416,6 +458,8 @@ void AutotestPlugin::updateMenuItemsEnabledState() ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(canRun); ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()->setEnabled(canRun); + ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action()->setEnabled(canRun); + ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action()->setEnabled(canRun); ActionManager::command(Constants::ACTION_RUN_FAILED_ID)->action()->setEnabled(canRunFailed); ActionManager::command(Constants::ACTION_RUN_FILE_ID)->action()->setEnabled(canRun); ActionManager::command(Constants::ACTION_SCAN_ID)->action()->setEnabled(canScan); @@ -425,7 +469,9 @@ void AutotestPlugin::updateMenuItemsEnabledState() return; // When no context menu, actions do not exists ActionManager::command(Constants::ACTION_RUN_UCURSOR)->action()->setEnabled(canRun); + ActionManager::command(Constants::ACTION_RUN_UCURSOR_NODEPLOY)->action()->setEnabled(canRun); ActionManager::command(Constants::ACTION_RUN_DBG_UCURSOR)->action()->setEnabled(canRun); + ActionManager::command(Constants::ACTION_RUN_DBG_UCURSOR_NODEPLOY)->action()->setEnabled(canRun); } void AutotestPlugin::cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice) diff --git a/src/plugins/autotest/testnavigationwidget.cpp b/src/plugins/autotest/testnavigationwidget.cpp index 7a8e7576622..aca619786ba 100644 --- a/src/plugins/autotest/testnavigationwidget.cpp +++ b/src/plugins/autotest/testnavigationwidget.cpp @@ -176,6 +176,8 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event) QAction *runAll = Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action(); QAction *runSelected = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action(); + QAction *runAllNoDeploy = Core::ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action(); + QAction *runSelectedNoDeploy = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action(); QAction *selectAll = new QAction(tr("Select All"), &menu); QAction *deselectAll = new QAction(tr("Deselect All"), &menu); // TODO remove? @@ -196,7 +198,9 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event) menu.addSeparator(); menu.addAction(runAll); + menu.addAction(runAllNoDeploy); menu.addAction(runSelected); + menu.addAction(runSelectedNoDeploy); menu.addSeparator(); menu.addAction(selectAll); menu.addAction(deselectAll); diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index 4bbface7aa2..2a2c2fa0aba 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -648,6 +648,13 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos) }); menu.addAction(action); + action = new QAction(tr("Run This Test Without Deployment"), &menu); + action->setEnabled(correlatingItem && correlatingItem->canProvideTestConfiguration()); + connect(action, &QAction::triggered, this, [this, clicked] { + onRunThisTestTriggered(TestRunMode::RunWithoutDeploy, clicked); + }); + menu.addAction(action); + action = new QAction(tr("Debug This Test"), &menu); bool debugEnabled = false; if (correlatingItem) { @@ -662,6 +669,13 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos) }); menu.addAction(action); + action = new QAction(tr("Debug This Test Without Deployment"), &menu); + action->setEnabled(debugEnabled); + connect(action, &QAction::triggered, this, [this, clicked] { + onRunThisTestTriggered(TestRunMode::DebugWithoutDeploy, clicked); + }); + menu.addAction(action); + menu.exec(m_treeView->mapToGlobal(pos)); }