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 <christian.stenger@qt.io>
This commit is contained in:
Petar Perisin
2021-07-08 16:57:00 +02:00
parent 622a03f63c
commit d005e71da0
4 changed files with 95 additions and 27 deletions

View File

@@ -30,25 +30,29 @@
namespace Autotest { namespace Autotest {
namespace Constants { namespace Constants {
const char ACTION_SCAN_ID[] = "AutoTest.ScanAction"; const char ACTION_SCAN_ID[] = "AutoTest.ScanAction";
const char ACTION_RUN_ALL_ID[] = "AutoTest.RunAll"; const char ACTION_RUN_ALL_ID[] = "AutoTest.RunAll";
const char ACTION_RUN_SELECTED_ID[] = "AutoTest.RunSelected"; const char ACTION_RUN_ALL_NODEPLOY_ID[] = "AutoTest.RunAllNoDeploy";
const char ACTION_RUN_FAILED_ID[] = "AutoTest.RunFailed"; const char ACTION_RUN_SELECTED_ID[] = "AutoTest.RunSelected";
const char ACTION_RUN_FILE_ID[] = "AutoTest.RunFile"; const char ACTION_RUN_SELECTED_NODEPLOY_ID[] = "AutoTest.RunSelectedNoDeploy";
const char ACTION_RUN_UCURSOR[] = "AutoTest.RunUnderCursor"; const char ACTION_RUN_FAILED_ID[] = "AutoTest.RunFailed";
const char ACTION_RUN_DBG_UCURSOR[] = "AutoTest.RunDebugUnderCursor"; const char ACTION_RUN_FILE_ID[] = "AutoTest.RunFile";
const char MENU_ID[] = "AutoTest.Menu"; const char ACTION_RUN_UCURSOR[] = "AutoTest.RunUnderCursor";
const char AUTOTEST_ID[] = "AutoTest.ATP"; const char ACTION_RUN_UCURSOR_NODEPLOY[] = "AutoTest.RunUnderCursorNoDeploy";
const char AUTOTEST_CONTEXT[] = "Auto Tests"; const char ACTION_RUN_DBG_UCURSOR[] = "AutoTest.RunDebugUnderCursor";
const char TASK_INDEX[] = "AutoTest.Task.Index"; const char ACTION_RUN_DBG_UCURSOR_NODEPLOY[] = "AutoTest.RunDebugUnderCursorNoDeploy";
const char TASK_PARSE[] = "AutoTest.Task.Parse"; const char MENU_ID[] = "AutoTest.Menu";
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests"; const char AUTOTEST_ID[] = "AutoTest.ATP";
const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Testing"); const char AUTOTEST_CONTEXT[] = "Auto Tests";
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework."; const char TASK_INDEX[] = "AutoTest.Task.Index";
const char SETTINGSPAGE_PREFIX[] = "A.AutoTest."; const char TASK_PARSE[] = "AutoTest.Task.Parse";
const char SETTINGSGROUP[] = "Autotest"; const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
const char TASK_MARK_ID[] = "Autotest.TaskMark"; const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Testing");
const char SK_USE_GLOBAL[] = "AutoTest.UseGlobal"; 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 } // namespace Constants
enum class TestRunMode enum class TestRunMode

View File

@@ -99,8 +99,8 @@ public:
QMap<QString, ChoicePair> m_runconfigCache; QMap<QString, ChoicePair> m_runconfigCache;
void initializeMenuEntries(); void initializeMenuEntries();
void onRunAllTriggered(); void onRunAllTriggered(TestRunMode mode);
void onRunSelectedTriggered(); void onRunSelectedTriggered(TestRunMode mode);
void onRunFailedTriggered(); void onRunFailedTriggered();
void onRunFileTriggered(); void onRunFileTriggered();
void onRunUnderCursorTriggered(TestRunMode mode); void onRunUnderCursorTriggered(TestRunMode mode);
@@ -214,7 +214,19 @@ void AutotestPluginPrivate::initializeMenuEntries()
Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_ID); Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_ID);
command->setDefaultKeySequence( command->setDefaultKeySequence(
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+A") : tr("Alt+Shift+T,Alt+A"))); 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); action->setEnabled(false);
menu->addAction(command); menu->addAction(command);
@@ -224,7 +236,19 @@ void AutotestPluginPrivate::initializeMenuEntries()
command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_ID); command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_ID);
command->setDefaultKeySequence( command->setDefaultKeySequence(
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+R") : tr("Alt+Shift+T,Alt+R"))); 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); action->setEnabled(false);
menu->addAction(command); menu->addAction(command);
@@ -300,6 +324,15 @@ void AutotestPlugin::extensionsInitialized()
contextMenu->addSeparator(); contextMenu->addSeparator();
contextMenu->addAction(command); 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 = new QAction(tr("&Debug Test Under Cursor"), this);
action->setEnabled(false); action->setEnabled(false);
action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon()); action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon());
@@ -308,6 +341,15 @@ void AutotestPlugin::extensionsInitialized()
connect(action, &QAction::triggered, connect(action, &QAction::triggered,
std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::Debug)); std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::Debug));
contextMenu->addAction(command); 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(); contextMenu->addSeparator();
} }
@@ -318,16 +360,16 @@ ExtensionSystem::IPlugin::ShutdownFlag AutotestPlugin::aboutToShutdown()
return SynchronousShutdown; return SynchronousShutdown;
} }
void AutotestPluginPrivate::onRunAllTriggered() void AutotestPluginPrivate::onRunAllTriggered(TestRunMode mode)
{ {
m_testRunner.setSelectedTests(m_testTreeModel.getAllTestCases()); 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.setSelectedTests(m_testTreeModel.getSelectedTests());
m_testRunner.prepareToRunTests(TestRunMode::Run); m_testRunner.prepareToRunTests(mode);
} }
void AutotestPluginPrivate::onRunFailedTriggered() 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_ALL_ID)->action()->setEnabled(canRun);
ActionManager::command(Constants::ACTION_RUN_SELECTED_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_FAILED_ID)->action()->setEnabled(canRunFailed);
ActionManager::command(Constants::ACTION_RUN_FILE_ID)->action()->setEnabled(canRun); ActionManager::command(Constants::ACTION_RUN_FILE_ID)->action()->setEnabled(canRun);
ActionManager::command(Constants::ACTION_SCAN_ID)->action()->setEnabled(canScan); 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 return; // When no context menu, actions do not exists
ActionManager::command(Constants::ACTION_RUN_UCURSOR)->action()->setEnabled(canRun); 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)->action()->setEnabled(canRun);
ActionManager::command(Constants::ACTION_RUN_DBG_UCURSOR_NODEPLOY)->action()->setEnabled(canRun);
} }
void AutotestPlugin::cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice) void AutotestPlugin::cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice)

View File

@@ -176,6 +176,8 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
QAction *runAll = Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action(); QAction *runAll = Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action();
QAction *runSelected = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_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 *selectAll = new QAction(tr("Select All"), &menu);
QAction *deselectAll = new QAction(tr("Deselect All"), &menu); QAction *deselectAll = new QAction(tr("Deselect All"), &menu);
// TODO remove? // TODO remove?
@@ -196,7 +198,9 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
menu.addSeparator(); menu.addSeparator();
menu.addAction(runAll); menu.addAction(runAll);
menu.addAction(runAllNoDeploy);
menu.addAction(runSelected); menu.addAction(runSelected);
menu.addAction(runSelectedNoDeploy);
menu.addSeparator(); menu.addSeparator();
menu.addAction(selectAll); menu.addAction(selectAll);
menu.addAction(deselectAll); menu.addAction(deselectAll);

View File

@@ -648,6 +648,13 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
}); });
menu.addAction(action); 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); action = new QAction(tr("Debug This Test"), &menu);
bool debugEnabled = false; bool debugEnabled = false;
if (correlatingItem) { if (correlatingItem) {
@@ -662,6 +669,13 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
}); });
menu.addAction(action); 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)); menu.exec(m_treeView->mapToGlobal(pos));
} }